Skip to content

Commit

Permalink
Fix #2891 Populate framework_dirs with the correct values depending o…
Browse files Browse the repository at this point in the history
…n the current host runtime.
  • Loading branch information
siegfriedpammer committed Aug 1, 2023
1 parent d1ac27e commit 3de29c8
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions ICSharpCode.Decompiler/Metadata/UniversalAssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,37 @@ string FindClosestVersionDirectory(string basePath, Version? version)
if (assembly != null)
return assembly;

var framework_dir = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)!;
var framework_dirs = decompilerRuntime == DecompilerRuntime.Mono
? new[] { framework_dir, Path.Combine(framework_dir, "Facades") }
: new[] { framework_dir };
string[] framework_dirs;
string framework_dir;

switch (decompilerRuntime)
{
case DecompilerRuntime.Mono:
framework_dir = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)!;
framework_dirs = new[] { framework_dir, Path.Combine(framework_dir, "Facades") };
break;
case DecompilerRuntime.NETCoreApp:
string windir;
try
{
windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
if (string.IsNullOrEmpty(windir))
{
goto default;
}
}
catch (PlatformNotSupportedException)
{
goto default;
}
framework_dir = Path.Combine(windir, "Microsoft.NET", "Framework64", "v4.0.30319");
framework_dirs = new[] { framework_dir };
break;
default:
framework_dir = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName)!;
framework_dirs = new[] { framework_dir };
break;
}

if (IsSpecialVersionOrRetargetable(name))
{
Expand Down

0 comments on commit 3de29c8

Please sign in to comment.