private static ImmutableArray <ImmutableArray <string> > GetGroupedImportStrings(Compilation compilation, string methodName, out ImmutableArray <string> externAliasStrings) { Assert.NotNull(compilation); Assert.NotNull(methodName); using (var exebits = new MemoryStream()) { using (var pdbbits = new MemoryStream()) { compilation.Emit(exebits, pdbbits); exebits.Position = 0; using (var module = new PEModule(new PEReader(exebits, PEStreamOptions.LeaveOpen), metadataOpt: IntPtr.Zero, metadataSizeOpt: 0)) { var metadataReader = module.MetadataReader; MethodDefinitionHandle methodHandle = metadataReader.MethodDefinitions.Single(mh => metadataReader.GetString(metadataReader.GetMethodDefinition(mh).Name) == methodName); int methodToken = metadataReader.GetToken(methodHandle); // Create a SymReader, rather than a raw COM object, because // SymReader implements ISymUnmanagedReader3 and the COM object // might not. pdbbits.Position = 0; using (var reader = new SymReader(pdbbits.ToArray())) { return(reader.GetCSharpGroupedImportStrings(methodToken, methodVersion: 1, externAliasStrings: out externAliasStrings)); } } } } }
private void TestGetDocument(SymReader symReader, string name, string expectedUrl) { ISymUnmanagedDocument document; if (expectedUrl != null) { // guids are ignored Assert.Equal(HResult.S_OK, symReader.GetDocument(name, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), out document)); ValidateDocumentUrl(document, expectedUrl); } else { // guids are ignored Assert.Equal(HResult.S_FALSE, symReader.GetDocument(name, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), out document)); Assert.Null(document); } }
internal SymScope(SymReader reader, ISymUnmanagedScope scope) { _reader = reader; _scope = scope; }
internal SymMethod(SymReader reader, ISymUnmanagedMethod method) { _reader = reader; _method = method; }
/// <summary> /// Load the PDB given the parameters at the ctor and spew it out to the XmlWriter specified /// at the ctor. /// </summary> private static void ToXml(TextWriter xmlWriter, Stream pdbStream, MetadataReader metadataReaderOpt, PdbToXmlOptions options, IEnumerable<MethodDefinitionHandle> methodHandles) { Debug.Assert(pdbStream != null); Debug.Assert((options & PdbToXmlOptions.ResolveTokens) == 0 || metadataReaderOpt != null); XmlDocument doc = new XmlDocument(); XmlWriter writer = doc.CreateNavigator().AppendChild(); using (SymReader symReader = new SymReader(pdbStream, metadataReaderOpt)) { var converter = new PdbToXmlConverter(writer, symReader, metadataReaderOpt, options); converter.WriteRoot(methodHandles ?? metadataReaderOpt.MethodDefinitions); } writer.Close(); // Save xml to disk doc.Save(xmlWriter); }