Table of Contents

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 string

The 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 bool

If true an ResolutionException is thrown, in case the assembly reference cannot be resolved.

targetFramework string

The 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 string

Identifier 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 PEStreamOptions

Options used for the PEReader.

metadataOptions MetadataReaderOptions

Options 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

IEnumerable<AssemblyNameReference>

FindAssemblyFile(IAssemblyReference)

public string? FindAssemblyFile(IAssemblyReference name)

Parameters

name IAssemblyReference

Returns

string

GetAssemblyInGac(IAssemblyReference)

public static string? GetAssemblyInGac(IAssemblyReference reference)

Parameters

reference IAssemblyReference

Returns

string

GetGacPaths()

public static List<string> GetGacPaths()

Returns

List<string>

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 IAssemblyReference
runtimePack string

Returns

bool

RemoveSearchDirectory(string?)

public void RemoveSearchDirectory(string? directory)

Parameters

directory string

Resolve(IAssemblyReference)

public PEFile? Resolve(IAssemblyReference name)

Parameters

name IAssemblyReference

Returns

PEFile

ResolveAsync(IAssemblyReference)

public Task<PEFile?> ResolveAsync(IAssemblyReference name)

Parameters

name IAssemblyReference

Returns

Task<PEFile>

ResolveModule(PEFile, string)

public PEFile? ResolveModule(PEFile mainModule, string moduleName)

Parameters

mainModule PEFile
moduleName string

Returns

PEFile

ResolveModuleAsync(PEFile, string)

public Task<PEFile?> ResolveModuleAsync(PEFile mainModule, string moduleName)

Parameters

mainModule PEFile
moduleName string

Returns

Task<PEFile>