|
|
@ -29,9 +29,11 @@ namespace ICSharpCode.Decompiler.Metadata |
|
|
|
public static class DotNetCorePathFinderExtensions |
|
|
|
public static class DotNetCorePathFinderExtensions |
|
|
|
{ |
|
|
|
{ |
|
|
|
static readonly string RefPathPattern = |
|
|
|
static readonly string RefPathPattern = |
|
|
|
@"(Reference Assemblies[/\\]Microsoft[/\\]Framework[/\\](?<1>.NETFramework)[/\\]v(?<2>[^/\\]+)[/\\])" + |
|
|
|
@"(Reference Assemblies[/\\]Microsoft[/\\]Framework[/\\](?<type>.NETFramework)[/\\]v(?<version>[^/\\]+)[/\\])" + |
|
|
|
@"|(NuGetFallbackFolder[/\\](?<1>[^/\\]+)\\(?<2>[^/\\]+)([/\\].*)?[/\\]ref[/\\])" + |
|
|
|
@"|((?<type>Microsoft\.NET)[/\\]assembly[/\\]GAC_(MSIL|32|64)[/\\])" + |
|
|
|
@"|(shared[/\\](?<1>[^/\\]+)\\(?<2>[^/\\]+)([/\\].*)?[/\\])"; |
|
|
|
@"|((?<type>Microsoft\.NET)[/\\]Framework(64)?[/\\](?<version>[^/\\]+)[/\\])" + |
|
|
|
|
|
|
|
@"|(NuGetFallbackFolder[/\\](?<type>[^/\\]+)\\(?<version>[^/\\]+)([/\\].*)?[/\\]ref[/\\])" + |
|
|
|
|
|
|
|
@"|(shared[/\\](?<type>[^/\\]+)\\(?<version>[^/\\]+)([/\\].*)?[/\\])"; |
|
|
|
|
|
|
|
|
|
|
|
public static string DetectTargetFrameworkId(this PEFile assembly) |
|
|
|
public static string DetectTargetFrameworkId(this PEFile assembly) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -68,16 +70,20 @@ namespace ICSharpCode.Decompiler.Metadata |
|
|
|
var pathMatch = Regex.Match(assemblyPath, RefPathPattern, |
|
|
|
var pathMatch = Regex.Match(assemblyPath, RefPathPattern, |
|
|
|
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture); |
|
|
|
RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture); |
|
|
|
if (pathMatch.Success) { |
|
|
|
if (pathMatch.Success) { |
|
|
|
var type = pathMatch.Groups[1].Value; |
|
|
|
var type = pathMatch.Groups["type"].Value; |
|
|
|
var version = pathMatch.Groups[2].Value; |
|
|
|
var version = pathMatch.Groups["version"].Value; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(version)) |
|
|
|
|
|
|
|
version = reader.MetadataVersion; |
|
|
|
|
|
|
|
|
|
|
|
if (type == ".NETFramework") { |
|
|
|
if (type == "Microsoft.NET" || type == ".NETFramework") { |
|
|
|
return $".NETFramework,Version=v{version}"; |
|
|
|
return $".NETFramework,Version=v{version.TrimStart('v').Substring(0, 3)}"; |
|
|
|
} else if (type.IndexOf("netcore", StringComparison.OrdinalIgnoreCase) >= 0) { |
|
|
|
} else if (type.IndexOf("netcore", StringComparison.OrdinalIgnoreCase) >= 0) { |
|
|
|
return $".NETCoreApp,Version=v{version}"; |
|
|
|
return $".NETCoreApp,Version=v{version}"; |
|
|
|
} else if (type.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0) { |
|
|
|
} else if (type.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) >= 0) { |
|
|
|
return $".NETStandard,Version=v{version}"; |
|
|
|
return $".NETStandard,Version=v{version}"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return $".NETFramework,Version={reader.MetadataVersion.Substring(0, 4)}"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|