public void GetReaderForFile_SearchPaths() { var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll)); string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString()); string searchDir = Path.Combine(tempDir, "Dir"); string peFilePath = Path.Combine(tempDir, "Documents.dll"); string pdbFilePath = Path.Combine(searchDir, "Documents.pdb"); Directory.CreateDirectory(tempDir); Directory.CreateDirectory(searchDir); PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll); PortableShim.File.WriteAllBytes(pdbFilePath, TestResources.Documents.PortablePdb); string searchPath = searchDir; ISymUnmanagedReader symReader; Assert.Equal(HResult.S_OK, SymBinder.GetReaderForFile(importer, peFilePath, searchPath, out symReader)); int actualCount; Assert.Equal(HResult.S_OK, symReader.GetDocuments(0, out actualCount, null)); Assert.Equal(13, actualCount); ((ISymUnmanagedDispose)symReader).Destroy(); Directory.Delete(tempDir, recursive: true); }
public void GetReaderFromStream() { var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.Dll)); var stream = new MemoryStream(TestResources.Documents.Pdb); var wrapper = new ComStreamWrapper(stream); ISymUnmanagedReader symReader; Assert.Equal(HResult.S_OK, SymBinder.GetReaderFromStream(importer, wrapper, out symReader)); int actualCount; Assert.Equal(HResult.S_OK, symReader.GetDocuments(0, out actualCount, null)); Assert.Equal(11, actualCount); Assert.Equal(HResult.S_FALSE, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Equal(HResult.S_OK, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Throws<ObjectDisposedException>(() => symReader.GetDocuments(0, out actualCount, null)); }
public void GetReaderForFile() { var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.Dll)); string filePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); File.WriteAllBytes(filePath, TestResources.Documents.Pdb); string searchPath = null; ISymUnmanagedReader symReader; Assert.Equal(HResult.S_OK, SymBinder.GetReaderForFile(importer, filePath, searchPath, out symReader)); int actualCount; Assert.Equal(HResult.S_OK, symReader.GetDocuments(0, out actualCount, null)); Assert.Equal(11, actualCount); Assert.Equal(HResult.S_FALSE, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Equal(HResult.S_OK, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Throws<ObjectDisposedException>(() => symReader.GetDocuments(0, out actualCount, null)); File.Delete(filePath); }
public void GetReaderForFile_MatchingNotFound() { var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.PortableDll)); string tempDir = Path.Combine(Path.GetDirectoryName(PortableShim.Path.GetTempFileName()), Guid.NewGuid().ToString()); string searchDir = Path.Combine(tempDir, "Dir"); string peFilePath = Path.Combine(tempDir, "Documents.dll"); string anotherPdbFilePath = Path.Combine(searchDir, "symbols", "dll", "Documents.pdb"); Directory.CreateDirectory(tempDir); Directory.CreateDirectory(Path.GetDirectoryName(anotherPdbFilePath)); PortableShim.File.WriteAllBytes(peFilePath, TestResources.Documents.PortableDll); PortableShim.File.WriteAllBytes(anotherPdbFilePath, TestResources.Async.PortablePdb); string searchPath = searchDir; ISymUnmanagedReader symReader; Assert.Equal(HResult.E_PDB_NOT_FOUND, SymBinder.GetReaderForFile(importer, peFilePath, searchPath, out symReader)); Assert.Null(symReader); Directory.Delete(tempDir, recursive: true); }
private static SymReader CreateSymReaderFromResource(string name, out MetadataReader mdReader) { var importer = new SymMetadataImport(TestResources.ResourceHelper.GetResourceStream(name + ".dll")); mdReader = importer.MetadataReader; return new SymReader(new PortablePdbReader(TestResources.ResourceHelper.GetResourceStream(name + ".pdbx"), importer)); }
private static SymReader CreateSymReaderFromResource(KeyValuePair<byte[], byte[]> peAndPdb, out MetadataReader mdReader) { var importer = new SymMetadataImport(new MemoryStream(peAndPdb.Key)); mdReader = importer.MetadataReader; return new SymReader(new PortablePdbReader(peAndPdb.Value, peAndPdb.Value.Length, importer)); }