本文整理汇总了C#中ReaderParameters类的典型用法代码示例。如果您正苦于以下问题:C# ReaderParameters类的具体用法?C# ReaderParameters怎么用?C# ReaderParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReaderParameters类属于命名空间,在下文中一共展示了ReaderParameters类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetAssemblyDef
public static AssemblyDefinition GetAssemblyDef(string assemblyPath)
{
if (assemblies.ContainsKey(assemblyPath))
return assemblies[assemblyPath];
var assemblyResolver = new DefaultAssemblyResolver();
var assemblyLocation = Path.GetDirectoryName(assemblyPath);
assemblyResolver.AddSearchDirectory(assemblyLocation);
var readerParameters = new ReaderParameters { AssemblyResolver = assemblyResolver };
var pdbName = Path.ChangeExtension(assemblyPath, "pdb");
if (File.Exists(pdbName))
{
var symbolReaderProvider = new PdbReaderProvider();
readerParameters.SymbolReaderProvider = symbolReaderProvider;
readerParameters.ReadSymbols = true;
}
var assemblyDef = AssemblyDefinition.ReadAssembly(assemblyPath, readerParameters);
assemblies.Add(assemblyPath,assemblyDef);
return assemblyDef;
}
开发者ID:chartly,项目名称:flood,代码行数:25,代码来源:CecilUtils.cs
示例2: LoadAssemblyAndGetMethods
public void LoadAssemblyAndGetMethods()
{
var readerParameters = new ReaderParameters { ReadSymbols = true };
assembly = AssemblyDefinition.ReadAssembly(assemblyPath, readerParameters);
methods = assembly.MainModule.Types.
SelectMany(type => type.Methods);
}
开发者ID:AlbertoMonteiro,项目名称:ThrowHelper,代码行数:7,代码来源:ThrowHelperIilInjector.cs
示例3: ReadModule
public void ReadModule()
{
if (pdbFound)
{
using (var symbolStream = File.OpenRead(pdbPath))
{
var readerParameters = new ReaderParameters
{
AssemblyResolver = this,
ReadSymbols = pdbFound || mdbFound,
SymbolReaderProvider = debugReaderProvider,
SymbolStream = symbolStream
};
ModuleDefinition = ModuleDefinition.ReadModule(AssemblyFilePath, readerParameters);
}
}
else
{
var readerParameters = new ReaderParameters
{
AssemblyResolver = this,
ReadSymbols = pdbFound || mdbFound,
SymbolReaderProvider = debugReaderProvider,
};
ModuleDefinition = ModuleDefinition.ReadModule(AssemblyFilePath, readerParameters);
}
}
开发者ID:CloudMetal,项目名称:Fody,代码行数:28,代码来源:ModuleReader.cs
示例4: ReadModule
public virtual void ReadModule()
{
string symbolsPath;
if (pdbFound)
{
symbolsPath = pdbPath;
}
else
{
symbolsPath = mdbPath;
}
var tempAssembly = $"{AssemblyFilePath}.tmp";
var tempSymbols = $"{symbolsPath}.tmp";
File.Copy(AssemblyFilePath, tempAssembly,true);
File.Copy(symbolsPath, tempSymbols, true);
SymbolStream = File.OpenRead(tempSymbols);
var readerParameters = new ReaderParameters
{
AssemblyResolver = this,
ReadSymbols = true,
SymbolReaderProvider = debugReaderProvider,
SymbolStream = SymbolStream,
};
ModuleDefinition = ModuleDefinition.ReadModule(tempAssembly, readerParameters);
}
开发者ID:Fody,项目名称:Fody,代码行数:26,代码来源:ModuleReader.cs
示例5: Resolve
public AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters)
{
lock (resolutionCache)
{
string key = name.FullName;
AssemblyDefinition result;
if (resolutionCache.TryGetValue(key, out result))
return result;
}
if (!name.Name.StartsWith("System", StringComparison.OrdinalIgnoreCase)
&& !name.Name.StartsWith("mscorlib", StringComparison.OrdinalIgnoreCase))
return null;
var asm = Assembly.Load(name.ToString());
var asmDef = AssemblyDefinition.ReadAssembly(
asm.Location,
parameters ??
new ReaderParameters(ReadingMode.Deferred) { AssemblyResolver = this });
lock (resolutionCache)
{
string key = name.FullName;
AssemblyDefinition result;
if (resolutionCache.TryGetValue(key, out result))
return result;
resolutionCache[key] = asmDef;
}
return asmDef;
}
开发者ID:BGCX261,项目名称:zoom-decompiler-hg-to-git,代码行数:34,代码来源:AssemblyResolver.cs
示例6: Patch
/// <summary>
/// Patches the specified input PDB file.
/// </summary>
/// <param name="inputExeFile">The input PDB file.</param>
/// <param name="outputPdbFile">The output PDB file.</param>
/// <param name="sourcePathRewriter">The source path modifier.</param>
/// <exception cref="System.ArgumentNullException">inputExeFile</exception>
public static void Patch(string inputExeFile, string outputPdbFile, SourcePathRewriterDelegate sourcePathRewriter)
{
if (inputExeFile == null) throw new ArgumentNullException("inputExeFile");
if (outputPdbFile == null) throw new ArgumentNullException("outputPdbFile");
if (sourcePathRewriter == null) throw new ArgumentNullException("sourcePathRewriter");
// Copy PDB from input assembly to output assembly if any
var inputPdbFile = Path.ChangeExtension(inputExeFile, "pdb");
if (!File.Exists(inputPdbFile))
{
ShowMessage(string.Format("Warning file [{0}] does not exist", inputPdbFile), ConsoleColor.Yellow);
return;
}
var symbolReaderProvider = new PdbReaderProvider();
var readerParameters = new ReaderParameters
{
SymbolReaderProvider = symbolReaderProvider,
ReadSymbols = true
};
// Read Assembly
var assembly = AssemblyDefinition.ReadAssembly(inputExeFile, readerParameters);
// Write back the assembly and pdb
assembly.Write(inputExeFile, new WriterParameters {WriteSymbols = true, SourcePathRewriter = sourcePathRewriter});
}
开发者ID:modulexcite,项目名称:SharpPdbPatcher,代码行数:34,代码来源:PdbPatcher.cs
示例7: GetMemberReference
public MemberReference GetMemberReference(IAssemblyResolver resolver)
{
if (resolver == null)
throw new ArgumentNullException("resolver");
if (memberReference != null)
return memberReference;
// reload from filename
ReaderParameters readerParameters = new ReaderParameters();
// Use new assembly resolver instance so that the AssemblyDefinitions can be garbage-collected
// once the code is decompiled.
readerParameters.AssemblyResolver = resolver;
string typeName;
if (GetAssemblyAndType(FileName.ToString(), out assemblyFile, out typeName)) {
ModuleDefinition module = ModuleDefinition.ReadModule(assemblyFile, readerParameters);
TypeDefinition typeDefinition = module.GetType(typeName);
if (typeDefinition == null)
throw new InvalidOperationException("Could not find type");
memberReference = typeDefinition;
}
return memberReference;
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:25,代码来源:DecompiledBreakpointBookmark.cs
示例8: Resolve
public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
{
if (string.IsNullOrEmpty(fullName))
throw new ArgumentException("fullName is null or empty");
return Resolve(AssemblyNameReference.Parse(fullName), parameters);
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:7,代码来源:ILSpyAssemblyResolver.cs
示例9: Load
public static AssemblyDefinition Load(string fileName)
{
var resolver = new DefaultAssemblyResolver();
resolver.AddSearchDirectory(new FileInfo(fileName).DirectoryName);
var parameters = new ReaderParameters
{
SymbolReaderProvider = new PdbReaderProvider(),
ReadingMode = ReadingMode.Immediate,
AssemblyResolver = resolver
};
AssemblyDefinition assemblyDef;
try
{
assemblyDef = AssemblyDefinition.ReadAssembly(fileName, parameters);
}
catch (FileNotFoundException)
{
// Perhaps we have an MDB file (Mono), or there is no symbol file to load.
// Try MDB first!
parameters.SymbolReaderProvider = new MdbReaderProvider();
try
{
assemblyDef = AssemblyDefinition.ReadAssembly(fileName, parameters);
}
catch (FileNotFoundException)
{
parameters.SymbolReaderProvider = null;
assemblyDef = AssemblyDefinition.ReadAssembly(fileName, parameters);
}
}
return assemblyDef;
}
开发者ID:provegard,项目名称:testness,代码行数:32,代码来源:AssemblyLoader.cs
示例10: Main
static void Main(string[] args)
{
try
{
var path = args.Length >= 1 ? args[0] : "Ibasa.dll";
var symbolReader = new Mono.Cecil.Pdb.PdbReaderProvider();
var readerParameters = new ReaderParameters()
{
SymbolReaderProvider = symbolReader,
ReadSymbols = true,
};
var writerParameters = new WriterParameters()
{
WriteSymbols = true,
};
AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(path, readerParameters);
Console.WriteLine("Loaded {0}.", path);
GenerateMemoryType(assembly.MainModule);
Console.WriteLine("Saving new dll.");
assembly.Write(path, writerParameters);
}
catch (Exception e)
{
Console.WriteLine("InteropBuilder failed with: {0}", e);
}
}
开发者ID:Frassle,项目名称:Ibasa,代码行数:32,代码来源:Program.cs
示例11: Resolve
public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters)
{
if (name == null)
throw new ArgumentNullException("name");
return Cache.GetOrCreate(name.FullName, () => base.Resolve(name, parameters));
}
开发者ID:Caspeco,项目名称:JSIL,代码行数:7,代码来源:CILSupport.cs
示例12: DiscoverSpecs
public IEnumerable<MSpecTestCase> DiscoverSpecs(string assemblyFilePath)
{
if (!this.AssemblyContainsMSpecReference(assemblyFilePath) || !this.SourceDirectoryContainsMSpec(assemblyFilePath))
return new List<MSpecTestCase>();
assemblyFilePath = Path.GetFullPath(assemblyFilePath);
if (!File.Exists(assemblyFilePath))
{
throw new ArgumentException("Could not find file: " + assemblyFilePath);
}
this.AssemblyFilename = assemblyFilePath;
// make sure that cecil looks in the assembly path for mspec (+ related assemblies) first
this.AssemblyResolver = new ScopedAssemblyResolver(Path.GetDirectoryName(assemblyFilePath));
this.ReaderParameters = new ReaderParameters()
{
ReadSymbols = true,
AssemblyResolver = AssemblyResolver
};
List<MSpecTestCase> list = new List<MSpecTestCase>();
List<IDelegateFieldScanner> fieldScanners = new List<IDelegateFieldScanner>();
fieldScanners.Add(new ItDelegateFieldScanner());
fieldScanners.Add(new CustomDelegateFieldScanner());
// statically inspect the types in the assembly using mono.cecil
var assembly = AssemblyDefinition.ReadAssembly(this.AssemblyFilename, this.ReaderParameters);
foreach (TypeDefinition type in GetNestedTypes(assembly.MainModule.Types))
{
// if a type is an It delegate generate some test case info for it
foreach (FieldDefinition fieldDefinition in type.Fields.Where(x => !x.Name.Contains("__Cached")))
{
foreach (IDelegateFieldScanner scanner in fieldScanners)
{
if (scanner.ProcessFieldDefinition(fieldDefinition))
{
string typeName = NormalizeCecilTypeName(type.Name);
string typeFullName = NormalizeCecilTypeName(type.FullName);
MSpecTestCase testCase = new MSpecTestCase()
{
ClassName = typeName,
ContextFullType = typeFullName,
SpecificationName = fieldDefinition.Name,
ContextDisplayName = GetContextDisplayName(type),
SpecificationDisplayName = fieldDefinition.Name.Replace("_", " "),
};
// get the source code location for the It delegate from the PDB file using mono.cecil.pdb
this.UpdateTestCaseWithLocation(type, testCase);
list.Add(testCase);
break;
}
}
}
}
return list.Select(x => x);
}
开发者ID:machine-visualstudio,项目名称:machine.vstestadapter,代码行数:60,代码来源:CecilSpecificationDiscoverer.cs
示例13: Weave
public static string Weave(string assemblyPath)
{
var newAssembly = assemblyPath.Replace(".dll", "2.dll");
var oldPdb = assemblyPath.Replace(".dll", ".pdb");
var newPdb = assemblyPath.Replace(".dll", "2.pdb");
File.Copy(assemblyPath, newAssembly, true);
File.Copy(oldPdb, newPdb, true);
var assemblyResolver = new MockAssemblyResolver
{
Directory = Path.GetDirectoryName(assemblyPath)
};
using (var symbolStream = File.OpenRead(newPdb))
{
var readerParameters = new ReaderParameters
{
ReadSymbols = true,
SymbolStream = symbolStream,
SymbolReaderProvider = new PdbReaderProvider()
};
var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver
};
weavingTask.Execute();
moduleDefinition.Write(newAssembly);
return newAssembly;
}
}
开发者ID:AndreGleichner,项目名称:Anotar,代码行数:35,代码来源:WeaverHelper.cs
示例14: ReadAssembly
public static AssemblyNode ReadAssembly (string filename)
{
var readerParameters = new ReaderParameters ();
AssemblyDefinition definition = AssemblyDefinition.ReadAssembly (filename, readerParameters);
return new AssemblyNode (definition);
}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:AssemblyNode.cs
示例15: WeaverHelper
public WeaverHelper(string projectPath)
{
this.projectPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\TestAssemblies", projectPath));
GetAssemblyPath();
AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);
var assemblyResolver = new TestAssemblyResolver(BeforeAssemblyPath, this.projectPath);
var readerParameters = new ReaderParameters
{
AssemblyResolver = assemblyResolver
};
var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, readerParameters);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver
};
weavingTask.Execute();
moduleDefinition.Write(AfterAssemblyPath);
Assembly = Assembly.LoadFile(AfterAssemblyPath);
}
开发者ID:Fody,项目名称:PropertyChanged,代码行数:27,代码来源:WeaverHelper.cs
示例16: Resolve
public AssemblyDefinition Resolve(string fullName, ReaderParameters parameters)
{
var dllName = fullName.Split(',')[0] + ".dll";
var fullPath = _targetAssemblyDirs.Select(x => Path.Combine(x, dllName)).FirstOrDefault(x => File.Exists(x));
if (fullPath == null)
{
dllName = fullName.Split(',')[0] + ".winmd";
fullPath = _targetAssemblyDirs.Select(x => Path.Combine(x, dllName)).FirstOrDefault(x => File.Exists(x));
}
// NB: This hacks WinRT's weird mscorlib to just use the regular one
// We forget why this was needed, maybe it's not needed anymore?
if (fullName.Contains("mscorlib") && fullName.Contains("255"))
{
fullPath =
Environment.ExpandEnvironmentVariables(
@"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll");
}
if (fullPath == null)
{
var errorMessage = $"Failed to resolve!!! {fullName}";
Log.Error(errorMessage);
throw new Exception(errorMessage);
}
return AssemblyDefinition.ReadAssembly(fullPath, parameters);
}
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:29,代码来源:PathSearchAssemblyResolver.cs
示例17: AssemblyWeaver
public AssemblyWeaver(string assemblyPath, List<string> referenceAssemblyPaths = null)
{
if (referenceAssemblyPaths == null)
{
referenceAssemblyPaths = new List<string>();
}
assemblyPath = FixAssemblyPath(assemblyPath);
var newAssembly = assemblyPath.Replace(".dll", "2.dll");
File.Copy(assemblyPath, newAssembly, true);
var assemblyResolver = new MockAssemblyResolver();
foreach (var referenceAssemblyPath in referenceAssemblyPaths)
{
var directoryName = Path.GetDirectoryName(referenceAssemblyPath);
assemblyResolver.AddSearchDirectory(directoryName);
}
var readerParameters = new ReaderParameters
{
AssemblyResolver = assemblyResolver
};
var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
LogError = LogError,
ReferenceCopyLocalPaths = referenceAssemblyPaths
};
weavingTask.Execute();
moduleDefinition.Write(newAssembly);
Assembly = Assembly.LoadFrom(newAssembly);
}
开发者ID:GavinOsborn,项目名称:MethodTimer,代码行数:35,代码来源:AssemblyWeaver.cs
示例18: AssemblyLoader
public AssemblyLoader(IEnumerable<NPath> searchDirectories, [Optional, DefaultParameterValue(false)] bool readSymbols, [Optional, DefaultParameterValue(false)] bool applyWindowsRuntimeProjections)
{
this._resolver = new AssemblyResolver(this);
foreach (NPath path in searchDirectories)
{
if (path != null)
{
this._resolver.AddSearchDirectory(path);
}
}
ReaderParameters parameters = new ReaderParameters {
AssemblyResolver = this._resolver,
MetadataResolver = new WindowsRuntimeAwareMetadataResolver(this._resolver),
ReadSymbols = readSymbols,
SymbolReaderProvider = !readSymbols ? null : new MdbReaderProvider(),
ApplyWindowsRuntimeProjections = applyWindowsRuntimeProjections
};
this._readerParameters = parameters;
parameters = new ReaderParameters {
ApplyWindowsRuntimeProjections = this._readerParameters.ApplyWindowsRuntimeProjections,
AssemblyResolver = this._readerParameters.AssemblyResolver,
MetadataImporterProvider = this._readerParameters.MetadataImporterProvider,
MetadataResolver = this._readerParameters.MetadataResolver,
ReadingMode = this._readerParameters.ReadingMode,
ReadSymbols = false,
SymbolReaderProvider = null,
ReflectionImporterProvider = this._readerParameters.ReflectionImporterProvider,
SymbolStream = this._readerParameters.SymbolStream
};
this._readerWithoutSymbolsParameters = parameters;
}
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:31,代码来源:AssemblyLoader.cs
示例19: CreateTracker
public IAssemblyTracker CreateTracker()
{
if (_whiteList == null || _whiteList.Count == 0)
throw new InvalidOperationException
("Initialize options first. (AssemblyTracker: target files have to be set!)");
var readPDB = new ReaderParameters { ReadSymbols = true };
var ignorePDB = new ReaderParameters { ReadSymbols = false };
var allFiles = BuildTargetFilesList();
List<AssemblyDefinition> assemblies = new List<AssemblyDefinition> ();
foreach (var doc in allFiles)
{
try
{
if (_fileSystem.FileExists (doc.Substring (0, doc.Length-3) + "pdb"))
assemblies.Add (_fileSystem.ReadAssembly (doc, readPDB));
else
assemblies.Add (_fileSystem.ReadAssembly (doc, ignorePDB));
}
catch (BadImageFormatException e)
{
Console.WriteLine (" WARNING :: '" + doc + "' is not a valid .NET assembly! [is ignored]");
}
}
((BaseAssemblyResolver) GlobalAssemblyResolver.Instance).AddSearchDirectory (_workingDirectory);
return new AssemblyTracker (assemblies, new TypeDefinitionCache());
}
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:29,代码来源:DirectoryBasedAssemblyTrackerFactory.cs
示例20: Resolve
public virtual AssemblyDefinition Resolve (string fullName, ReaderParameters parameters)
{
if (fullName == null)
throw new ArgumentNullException ("fullName");
return Resolve (AssemblyNameReference.Parse (fullName), parameters);
}
开发者ID:telurmasin,项目名称:mono,代码行数:7,代码来源:BaseAssemblyResolver.cs
注:本文中的ReaderParameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论