Class UniversalAssemblyResolver
- Namespace
- ICSharpCode.Decompiler.Metadata
- Assembly
- ICSharpCode.Decompiler.dll
Used to resolve assemblies referenced by an assembly.
public class UniversalAssemblyResolver : AssemblyReferenceClassifier, IAssemblyResolver
- Inheritance
-
UniversalAssemblyResolver
- Implements
- Inherited Members
Constructors
UniversalAssemblyResolver(string?, bool, string?, string?, PEStreamOptions, MetadataReaderOptions)
Creates a new instance of the UniversalAssemblyResolver.
public UniversalAssemblyResolver(string? mainAssemblyFileName, bool throwOnError, string? targetFramework, string? runtimePack = null, PEStreamOptions streamOptions = PEStreamOptions.Default, MetadataReaderOptions metadataOptions = MetadataReaderOptions.ApplyWindowsRuntimeProjections)
Parameters
mainAssemblyFileName
stringThe full path to the "main assembly" (i.e., the assembly being decompiled). This is used to resolve assemblies that are located next the main assembly. If no full path is used, the resolver falls back to using CurrentDirectory.
throwOnError
boolIf true an ResolutionException is thrown, in case the assembly reference cannot be resolved.
targetFramework
stringThe target framework name as used by TargetFrameworkAttribute. That is, "{framework},Version={version}": currently it supports ".NETCoreApp", ".NETStandard" and "Silverlight", if the string doesn't match any of these, the resolver falls back to ".NET Framework", which is "classic" .NET <= 4.8.
runtimePack
stringIdentifier of the runtime pack this assembly was compiled for. If omitted, falling back to "Microsoft.NETCore.App" and this is ignored in case of classic .NET
streamOptions
PEStreamOptionsOptions used for the PEReader.
metadataOptions
MetadataReaderOptionsOptions used for the MetadataReader.
Methods
AddSearchDirectory(string?)
public void AddSearchDirectory(string? directory)
Parameters
directory
string
EnumerateGac()
Gets the names of all assemblies in the GAC.
public static IEnumerable<AssemblyNameReference> EnumerateGac()
Returns
FindAssemblyFile(IAssemblyReference)
public string? FindAssemblyFile(IAssemblyReference name)
Parameters
name
IAssemblyReference
Returns
GetAssemblyInGac(IAssemblyReference)
public static string? GetAssemblyInGac(IAssemblyReference reference)
Parameters
reference
IAssemblyReference
Returns
GetGacPaths()
public static List<string> GetGacPaths()
Returns
GetSearchDirectories()
public string?[] GetSearchDirectories()
Returns
- string[]
IsSharedAssembly(IAssemblyReference, out string?)
For .NET Core framework references, the WholeProjectDecompiler will omit the assembly reference if the runtimePack is already included as an SDK.
public override bool IsSharedAssembly(IAssemblyReference reference, out string? runtimePack)
Parameters
reference
IAssemblyReferenceruntimePack
string
Returns
RemoveSearchDirectory(string?)
public void RemoveSearchDirectory(string? directory)
Parameters
directory
string
Resolve(IAssemblyReference)
public PEFile? Resolve(IAssemblyReference name)
Parameters
name
IAssemblyReference
Returns
ResolveAsync(IAssemblyReference)
public Task<PEFile?> ResolveAsync(IAssemblyReference name)
Parameters
name
IAssemblyReference
Returns
ResolveModule(PEFile, string)
public PEFile? ResolveModule(PEFile mainModule, string moduleName)
Parameters
Returns
ResolveModuleAsync(PEFile, string)
public Task<PEFile?> ResolveModuleAsync(PEFile mainModule, string moduleName)