本文整理汇总了C#中ISymUnmanagedReader类的典型用法代码示例。如果您正苦于以下问题:C# ISymUnmanagedReader类的具体用法?C# ISymUnmanagedReader怎么用?C# ISymUnmanagedReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISymUnmanagedReader类属于命名空间,在下文中一共展示了ISymUnmanagedReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PDBReader
public PDBReader(string assemblyPath)
{
object metaDataImport = null;
IMetaDataDispenser dispenser = null;
try
{
Guid metaDataImportIID = new Guid(IMetaDataImportGuid);
dispenser = (IMetaDataDispenser)(new MetaDataDispenser());
dispenser.OpenScope(assemblyPath, 0, ref metaDataImportIID, out metaDataImport);
this.symReader = (ISymUnmanagedReader)(new CorSymReader_SxS());
this.symReader.Initialize(metaDataImport, assemblyPath, null, null);
}
finally
{
// Release COM objects so that files don't remain locked.
if (metaDataImport != null)
Marshal.ReleaseComObject(metaDataImport);
if (dispenser != null)
Marshal.ReleaseComObject(dispenser);
}
}
示例2: PdbToXmlConverter
private PdbToXmlConverter(XmlWriter writer, ISymUnmanagedReader symReader, MetadataReader metadataReader, PdbToXmlOptions options)
{
_symReader = symReader;
_metadataReader = metadataReader;
_writer = writer;
_options = options;
}
示例3: GetMethodTokensForEachLine
private int[][] GetMethodTokensForEachLine(ISymUnmanagedReader symReader, ISymUnmanagedDocument symDocument, int minZeroBasedLine, int maxZeroBasedLine)
{
var result = new List<int[]>();
for (int line = minZeroBasedLine; line <= maxZeroBasedLine; line++)
{
int[] allMethodTokens = GetMethodTokensFromDocumentPosition(symReader, symDocument, line, 0);
ISymUnmanagedMethod method;
int hr = symReader.GetMethodFromDocumentPosition(symDocument, line, 1, out method);
if (hr != HResult.S_OK)
{
Assert.Equal(HResult.E_FAIL, hr);
Assert.Equal(0, allMethodTokens.Length);
}
else
{
int primaryToken;
Assert.Equal(HResult.S_OK, method.GetToken(out primaryToken));
Assert.Equal(primaryToken, allMethodTokens.First());
}
result.Add(allMethodTokens);
}
return result.ToArray();
}
示例4: Create
public unsafe static ModuleInstance Create(
PEMemoryBlock metadata,
Guid moduleVersionId,
ISymUnmanagedReader symReader = null)
{
return Create((IntPtr)metadata.Pointer, metadata.Length, moduleVersionId, symReader);
}
示例5: SymbolWriterClass
public SymbolWriterClass(EnCManager manager,ITokenTranslator transl)
{
// Create the writer from the COM catalog
Type writerType = Type.GetTypeFromCLSID(typeof(CorSymWriter_SxSClass).GUID);
object comWriterObj = Activator.CreateInstance(writerType);
Type readerType = Type.GetTypeFromCLSID(typeof(CorSymReader_SxSClass).GUID);
object comReaderObj = Activator.CreateInstance(readerType);
mWriter = (ISymUnmanagedWriter2)comWriterObj;
mReader = (ISymUnmanagedReader)comReaderObj;
this.manager = manager;
this.stream = new CorMemStream();
this.translator = transl;
State = WriterState.NotIninitialized;
}
示例6: TestGetMethodFromDocumentPosition
private void TestGetMethodFromDocumentPosition(
ISymUnmanagedReader symReader,
ISymUnmanagedDocument symDocument,
int zeroBasedLine,
int zeroBasedColumn,
int expectedToken)
{
ISymUnmanagedMethod method;
Assert.Equal(HResult.S_OK, symReader.GetMethodFromDocumentPosition(symDocument, zeroBasedLine, zeroBasedColumn, out method));
int token;
Assert.Equal(HResult.S_OK, method.GetToken(out token));
Assert.Equal(expectedToken, token);
}
示例7: TestGetDocument
private void TestGetDocument(ISymUnmanagedReader 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);
}
}
示例8: CreateRuntimeInstance
internal RuntimeInstance CreateRuntimeInstance(
string assemblyName,
ImmutableArray<MetadataReference> references,
byte[] exeBytes,
ISymUnmanagedReader symReader,
bool includeLocalSignatures = true)
{
var exeReference = AssemblyMetadata.CreateFromImage(exeBytes).GetReference(display: assemblyName);
var modulesBuilder = ArrayBuilder<ModuleInstance>.GetInstance();
// Create modules for the references
modulesBuilder.AddRange(references.Select(r => r.ToModuleInstance(fullImage: null, symReader: null, includeLocalSignatures: includeLocalSignatures)));
// Create a module for the exe.
modulesBuilder.Add(exeReference.ToModuleInstance(exeBytes, symReader, includeLocalSignatures: includeLocalSignatures));
var modules = modulesBuilder.ToImmutableAndFree();
modules.VerifyAllModules();
var instance = new RuntimeInstance(modules);
_runtimeInstances.Add(instance);
return instance;
}
示例9: GetMethodTokensFromDocumentPosition
private int[] GetMethodTokensFromDocumentPosition(
ISymUnmanagedReader symReader,
ISymUnmanagedDocument symDocument,
int zeroBasedLine,
int zeroBasedColumn)
{
int count;
Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, zeroBasedLine, zeroBasedColumn, 0, out count, null));
var methods = new ISymUnmanagedMethod[count];
int count2;
Assert.Equal(HResult.S_OK, symReader.GetMethodsFromDocumentPosition(symDocument, zeroBasedLine, zeroBasedColumn, count, out count2, methods));
Assert.Equal(count, count2);
return methods.Select(m =>
{
int token;
Assert.Equal(HResult.S_OK, m.GetToken(out token));
return token;
}).ToArray();
}
示例10: GetContextState
internal static void GetContextState(
RuntimeInstance runtime,
string methodOrTypeName,
out ImmutableArray<MetadataBlock> blocks,
out Guid moduleVersionId,
out ISymUnmanagedReader symReader,
out int methodOrTypeToken,
out int localSignatureToken)
{
var moduleInstances = runtime.Modules;
blocks = moduleInstances.SelectAsArray(m => m.MetadataBlock);
var compilation = blocks.ToCompilation();
var methodOrType = GetMethodOrTypeBySignature(compilation, methodOrTypeName);
var module = (PEModuleSymbol)methodOrType.ContainingModule;
var id = module.Module.GetModuleVersionIdOrThrow();
var moduleInstance = moduleInstances.First(m => m.ModuleVersionId == id);
moduleVersionId = id;
symReader = (ISymUnmanagedReader)moduleInstance.SymReader;
EntityHandle methodOrTypeHandle;
if (methodOrType.Kind == SymbolKind.Method)
{
methodOrTypeHandle = ((PEMethodSymbol)methodOrType).Handle;
localSignatureToken = moduleInstance.GetLocalSignatureToken((MethodDefinitionHandle)methodOrTypeHandle);
}
else
{
methodOrTypeHandle = ((PENamedTypeSymbol)methodOrType).Handle;
localSignatureToken = -1;
}
MetadataReader reader = null; // null should be ok
methodOrTypeToken = reader.GetToken(methodOrTypeHandle);
}
示例11: PDBReader
public PDBReader(string assemblyPath)
{
object unknown = null;
System.Workflow.ComponentModel.Compiler.IMetaDataDispenser o = null;
try
{
Guid riid = new Guid("7DAC8207-D3AE-4c75-9B67-92801A497D44");
o = (System.Workflow.ComponentModel.Compiler.IMetaDataDispenser) new System.Workflow.ComponentModel.Compiler.MetaDataDispenser();
o.OpenScope(assemblyPath, 0, ref riid, out unknown);
this.symReader = (ISymUnmanagedReader) new CorSymReader_SxS();
this.symReader.Initialize(unknown, assemblyPath, null, null);
}
finally
{
if (unknown != null)
{
Marshal.ReleaseComObject(unknown);
}
if (o != null)
{
Marshal.ReleaseComObject(o);
}
}
}
示例12: LoadSymbolsDynamic
/// <summary>
/// Load symbols for dynamic module
/// (as of .NET 4.0)
/// </summary>
public void LoadSymbolsDynamic()
{
if (this.CorModule is ICorDebugModule3 && this.IsDynamic) {
Guid guid = new Guid(0, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 70);
try {
symReader = (ISymUnmanagedReader)((ICorDebugModule3)this.CorModule).CreateReaderForInMemorySymbols(guid);
} catch (COMException e) {
// 0x80131C3B The application did not supply symbols when it loaded or created this module, or they are not yet available.
if ((uint)e.ErrorCode == 0x80131C3B) {
process.TraceMessage("Failed to load dynamic symbols for " + this.Name);
return;
}
throw;
}
TrackedComObjects.Track(symReader);
process.TraceMessage("Loaded dynamic symbols for " + this.Name);
OnSymbolsUpdated();
}
}
示例13: Dispose
public void Dispose()
{
// If the underlying symbol reader supports an explicit dispose interface to release
// it's resources, then call it.
(rawReader as ISymUnmanagedDispose)?.Destroy();
this.rawReader = null;
}
示例14: SymReader
internal SymReader(byte[] pdbBytes, ImmutableDictionary<string, byte[]> constantSignaturesOpt = null)
{
_reader = SymUnmanagedReaderExtensions.CreateReader(
new MemoryStream(pdbBytes),
PDB::Roslyn.Test.PdbUtilities.DummyMetadataImport.Instance);
_constantSignaturesOpt = constantSignaturesOpt;
}
示例15: Dispose
private void Dispose()
{
if (this.symReader != null)
{
Marshal.ReleaseComObject(this.symReader);
this.symReader = null;
}
}