Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitek Karas <vitek.karas@microsoft.com>2021-08-23 21:05:35 +0300
committerGitHub <noreply@github.com>2021-08-23 21:05:35 +0300
commitf48949f13430ad17bef203d7f9d0bad19c399a8e (patch)
tree122b3f728ff74cb54cd8eae0699eaa60af3647f7
parent8a5f3b2398253774bc0cccf28da6e3557336cd5a (diff)
Make linker forward compatible with regards to framework versioning (#2226)
Runtime is trying to update to .NET 7 versioning, but this breaks linker since it hardcodes knowledge of all versions. This change makes it forward compatible by recognizing "higher than what I know". No test as there's not a really good way to test this without going through a lot of trouble. Tested locally with runtime targetting 7.0 versioning.
-rw-r--r--src/linker/Linker/LinkContext.cs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/linker/Linker/LinkContext.cs b/src/linker/Linker/LinkContext.cs
index ef78bc064..4c0f6b822 100644
--- a/src/linker/Linker/LinkContext.cs
+++ b/src/linker/Linker/LinkContext.cs
@@ -45,9 +45,13 @@ namespace Mono.Linker
public enum TargetRuntimeVersion
{
+ // These have to be ordered the same way the versions are
+ // since the code uses > or < on these values.
Unknown = 0,
+ Lower = 1, // Anything below 5
NET5 = 5,
NET6 = 6,
+ Higher = 9999 // Anything above the highest explicitly supported version (future proofing)
}
public class LinkContext : IMetadataResolver, IDisposable
@@ -699,10 +703,13 @@ namespace Mono.Linker
return _targetRuntime.Value;
TypeDefinition objectType = BCL.FindPredefinedType ("System", "Object", this);
- _targetRuntime = objectType?.Module.Assembly.Name.Version.Major switch {
+ int? majorVersion = objectType?.Module.Assembly.Name.Version.Major;
+ _targetRuntime = majorVersion switch {
+ > 6 => TargetRuntimeVersion.Higher,
6 => TargetRuntimeVersion.NET6,
5 => TargetRuntimeVersion.NET5,
- _ => TargetRuntimeVersion.Unknown,
+ < 5 => TargetRuntimeVersion.Lower,
+ _ => TargetRuntimeVersion.Unknown
};
return _targetRuntime.Value;