Skip to content

Commit f02580b

Browse files
committed
Support detecting .NET Core 1.0 and 1.1
1 parent b50f4e1 commit f02580b

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

ICSharpCode.Decompiler/Metadata/DotNetCorePathFinderExtensions.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,24 @@ public static string DetectTargetFrameworkId(this MetadataReader metadata, strin
9797
return $".NETStandard,Version=v{version}";
9898
case "System.Runtime":
9999
// System.Runtime.dll uses the following scheme:
100+
// 4.1.0 => .NET Core 1.0
101+
// 4.1.1 => .NET Core 1.1
100102
// 4.2.0 => .NET Core 2.0
101103
// 4.2.1 => .NET Core 2.1 / 3.0
102104
// 4.2.2 => .NET Core 3.1
103105
// 5.0.0+ => .NET 5+
104-
if (r.Version >= new Version(4, 2, 0))
106+
version = (r.Version.Major, r.Version.Minor, r.Version.Build) switch
107+
{
108+
(4, 1, 0) => "1.0",
109+
(4, 1, 1) => "1.1",
110+
(4, 2, 0) => "2.0",
111+
(4, 2, 1) => "3.0",
112+
(4, 2, 2) => "3.1",
113+
(>= 5, _, _) => r.Version.ToString(2),
114+
_ => null
115+
};
116+
if (version != null)
105117
{
106-
if (r.Version.Major >= 5)
107-
{
108-
version = r.Version.ToString(2);
109-
}
110-
else if (r.Version.Major == 4 && r.Version.Minor == 2)
111-
{
112-
version = r.Version.Build switch {
113-
<= 0 => "2.0",
114-
1 => "3.0",
115-
_ => "3.1"
116-
};
117-
}
118-
else
119-
{
120-
version = "2.0";
121-
}
122118
return $".NETCoreApp,Version=v{version}";
123119
}
124120
else

0 commit comments

Comments
 (0)