mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Resolve assembly references against the host runtime directory as a last resort
Hosts without a .NET Framework installation (e.g. Linux and macOS) have no GAC; the only system-wide assembly store there is the shared-framework directory of the runtime executing the decompiler, and UniversalAssemblyResolver only consulted it through the version <= 4.0 legacy fallback. This made e.g. the type-forwards of a netstandard facade (pointing to a versioned System.Runtime) unresolvable, which left well-known types like Nullable<T> without a definition and among other things misaligned nullability decoding (Nullable<T> occupies no slot in the nullable metadata, so it must be recognized). On Windows nothing the GAC answered changes; the new fallback only adds resolutions that previously failed outright. Assisted-by: Claude:claude-fable-5:Claude Code
This commit is contained in:
committed by
Siegfried Pammer
parent
fcedb8980b
commit
701edf3a8c
@@ -71,6 +71,8 @@ namespace ICSharpCode.Decompiler.Metadata
|
||||
decompilerRuntime = DecompilerRuntime.NETCoreApp;
|
||||
else if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
decompilerRuntime = DecompilerRuntime.Mono;
|
||||
else
|
||||
decompilerRuntime = DecompilerRuntime.NETFramework;
|
||||
}
|
||||
|
||||
readonly Lazy<DotNetCorePathFinder> dotNetCorePathFinder;
|
||||
@@ -464,6 +466,20 @@ namespace ICSharpCode.Decompiler.Metadata
|
||||
return assembly;
|
||||
}
|
||||
|
||||
if (decompilerRuntime == DecompilerRuntime.NETCoreApp)
|
||||
{
|
||||
// Hosts without a .NET Framework installation (e.g. Linux, macOS) have no GAC;
|
||||
// the only system-wide assembly store there is the shared-framework directory
|
||||
// of the runtime executing the decompiler. Search it as the last resort,
|
||||
// regardless of the requested version (the runtime itself rolls forward in the
|
||||
// same way). Without this, e.g. the type-forwards of a netstandard facade
|
||||
// (pointing to a versioned System.Runtime) are unresolvable on such hosts.
|
||||
string runtimeDir = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)!;
|
||||
assembly = SearchDirectory(name, runtimeDir);
|
||||
if (assembly != null)
|
||||
return assembly;
|
||||
}
|
||||
|
||||
if (throwOnError)
|
||||
throw new ResolutionException(name, null, null);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user