Skip to content

Commit

Permalink
Assembly resolution support for future .NET versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Oct 29, 2023
1 parent e5803be commit b93fe21
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions dnSpy/dnSpy/Documents/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,31 +440,28 @@ FrameworkKind GetFrameworkKind_AssemblyRefs(ModuleDef module, string? frameworkN
// 5.0: System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// 6.0: System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// 7.0: System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// ...
if (frameworkName != TFM_netstandard) {
if (module.IsClr40Exactly && systemRuntimeRef.Version >= minSystemRuntimeNetCoreVersion) {
var systemRuntimeVersion = systemRuntimeRef.Version;
if (module.IsClr40Exactly && systemRuntimeVersion >= minSystemRuntimeNetCoreVersion) {
version = aspNetCoreRef?.Version;
if (version is null) {
// .NET Core 1.0 or 1.1
if (systemRuntimeRef.Version == version_4_1_0_0)
if (systemRuntimeVersion == version_4_1_0_0)
version = version_1_0_0_0;
// .NET Core 2.0
else if (systemRuntimeRef.Version == version_4_2_0_0)
else if (systemRuntimeVersion== version_4_2_0_0)
version = version_2_0_0_0;
// .NET Core 2.1, 2.2 or 3.0
else if (systemRuntimeRef.Version == version_4_2_1_0)
else if (systemRuntimeVersion == version_4_2_1_0)
version = version_2_1_0_0;
// .NET Core 3.1
else if (systemRuntimeRef.Version == version_4_2_2_0)
else if (systemRuntimeVersion == version_4_2_2_0)
version = version_3_1_0_0;
// .NET 5
else if (systemRuntimeRef.Version == version_5_0_0_0)
version = version_5_0_0_0;
// .NET 6
else if (systemRuntimeRef.Version == version_6_0_0_0)
version = version_6_0_0_0;
// .NET 7
else if (systemRuntimeRef.Version == version_7_0_0_0)
version = version_7_0_0_0;
// .NET 5+
else if (systemRuntimeVersion.Major >= 5 && systemRuntimeVersion.Minor == 0 &&
systemRuntimeVersion.Build == 0 && systemRuntimeVersion.Revision == 0)
version = systemRuntimeRef.Version;
else
Debug.Fail("Unknown .NET Core version");
}
Expand Down Expand Up @@ -501,9 +498,6 @@ FrameworkKind GetFrameworkKind_AssemblyRefs(ModuleDef module, string? frameworkN
static readonly Version version_4_2_0_0 = new Version(4, 2, 0, 0);
static readonly Version version_4_2_1_0 = new Version(4, 2, 1, 0);
static readonly Version version_4_2_2_0 = new Version(4, 2, 2, 0);
static readonly Version version_5_0_0_0 = new Version(5, 0, 0, 0);
static readonly Version version_6_0_0_0 = new Version(6, 0, 0, 0);
static readonly Version version_7_0_0_0 = new Version(7, 0, 0, 0);

// Silverlight uses 5.0.5.0
static bool IsValidMscorlibVersion(Version? version) => version is not null && (uint)version.Major <= 5;
Expand Down

0 comments on commit b93fe21

Please sign in to comment.