/// <summary> /// Gets information about the source if it is available. /// </summary> private bool GetSourceReference() { try { ISymbolReader sr = SymUtil.GetSymbolReaderForFile(_method.Module.Assembly.Location, null); ISymbolMethod sm = sr.GetMethod(new SymbolToken(_method.MetadataToken)); _count = sm.SequencePointCount; _offsets = new int[_count]; _documents = new ISymbolDocument[_count]; _startColumns = new int[_count]; _endColumns = new int[_count]; _startRows = new int[_count]; _endRows = new int[_count]; sm.GetSequencePoints(_offsets, _documents, _startRows, _startColumns, _endRows, _endColumns); return(true); } catch { _count = 0; _offsets = null; _documents = null; _startColumns = null; _endColumns = null; _startRows = null; _endRows = null; return(false); } }
/// <summary> /// Indicates whether the source is available for the assembly. /// </summary> public static bool IsSourceAvailable(Assembly assembly) { bool sourceIsAvailable = true; try { ISymbolReader sr = SymUtil.GetSymbolReaderForFile(assembly.Location, null); } catch { sourceIsAvailable = false; } return(sourceIsAvailable); }
/// <summary> /// Load the PDB given the parameters at the ctor and spew it out to the XmlWriter specified /// at the ctor. /// </summary> public void ReadPdbAndWriteToXml() { // Actually load the files ISymbolReader reader = SymUtil.GetSymbolReaderForFile(m_fileName, null); m_assembly = Assembly.ReflectionOnlyLoadFrom(m_fileName); // Begin writing XML. m_writer.WriteStartDocument(); m_writer.WriteComment("This is an XML file representing the PDB for '" + m_fileName + "'"); m_writer.WriteStartElement("symbols"); // Record what input file these symbols are for. m_writer.WriteAttributeString("file", m_fileName); WriteDocList(reader); WriteEntryPoint(reader); WriteAllMethods(reader); m_writer.WriteEndElement(); // "Symbols"; }
/// <summary> /// Wrapper. /// </summary> public static ISymbolReader GetSymbolReaderForFile(string pathModule, string searchPath) { return(SymUtil.GetSymbolReaderForFile(new SymbolBinder(), pathModule, searchPath)); }