From 4bc82251ae4b23c66faeb9bd82525ba418680afb Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 17 Sep 2020 10:35:07 +0200 Subject: [PATCH] Update to target .NET5 framework (dotnet/linker#1471) Co-authored-by: vitek-karas Co-authored-by: Viktor Hofer Commit migrated from https://github.com/dotnet/linker/commit/cc5c0f934dd37330a6e7484aced73d93771fc324 --- src/tools/illink/Directory.Build.props | 2 ++ src/tools/illink/eng/Version.Details.xml | 2 +- src/tools/illink/eng/Versions.props | 3 +- src/tools/illink/eng/ilasm.ilproj | 2 +- src/tools/illink/global.json | 6 ++-- .../src/ILLink.Tasks/ILLink.Tasks.csproj | 4 +-- src/tools/illink/src/ILLink.Tasks/LinkTask.cs | 2 +- .../illink/src/ILLink.Tasks/Sdk/Sdk.props | 2 +- src/tools/illink/src/analyzer/analyzer.csproj | 2 +- .../analyzer/common/Mono.Options/Options.cs | 2 +- .../illink/src/linker/Directory.Build.props | 1 - .../illink/src/linker/Mono.Linker.csproj | 2 ++ .../illink/src/linker/ref/Mono.Linker.csproj | 1 + .../ILLink.Tasks.Tests.csproj | 2 +- ...ono.Linker.Tests.Cases.Expectations.csproj | 6 +++- .../DataFlow/XmlAnnotations.xml | 16 ++++----- .../DynamicDependencyFromAttributeXml.cs | 10 +++++- ...ndencyFromAttributeXml.mono.Attributes.xml | 12 +++++++ ...cyFromAttributeXml.netcore.Attributes.xml} | 2 +- .../OverrideAttributeRemoval.xml | 3 ++ .../Mono.Linker.Tests.Cases.csproj | 4 +-- .../Reflection/ActivatorCreateInstance.cs | 4 +++ .../SuppressWarningsUsingTargetViaXml.cs | 10 +++++- ...uppressWarningsUsingTargetViaXml.mono.xml} | 0 ...pressWarningsUsingTargetViaXml.netcore.xml | 35 +++++++++++++++++++ .../Mono.Linker.Tests.csproj | 15 ++------ .../TestCasesRunner/PathUtilities.cs | 6 ++-- .../TestCasesRunner/ResultChecker.cs | 4 +-- .../TestCasesRunner/TestCaseSandbox.cs | 2 +- 29 files changed, 116 insertions(+), 46 deletions(-) create mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyFromAttributeXml.mono.Attributes.xml rename src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/{DynamicDependencyFromAttributeXml.Attributes.xml => DynamicDependencyFromAttributeXml.netcore.Attributes.xml} (84%) rename src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/{SuppressWarningsUsingTargetViaXml.xml => SuppressWarningsUsingTargetViaXml.mono.xml} (100%) create mode 100644 src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXml.netcore.xml diff --git a/src/tools/illink/Directory.Build.props b/src/tools/illink/Directory.Build.props index 655264983262..e1fcd8960bcc 100644 --- a/src/tools/illink/Directory.Build.props +++ b/src/tools/illink/Directory.Build.props @@ -7,6 +7,8 @@ true + + false true $(MSBuildProjectName)/ref diff --git a/src/tools/illink/eng/Version.Details.xml b/src/tools/illink/eng/Version.Details.xml index 1742468cde1e..0577df92122c 100644 --- a/src/tools/illink/eng/Version.Details.xml +++ b/src/tools/illink/eng/Version.Details.xml @@ -3,7 +3,7 @@ - + https://github.com/dotnet/arcade bd918c64b786bdba42e895e4cb93603e5a2ca608 diff --git a/src/tools/illink/eng/Versions.props b/src/tools/illink/eng/Versions.props index e5ddd7166c09..b73c26a7ae0a 100644 --- a/src/tools/illink/eng/Versions.props +++ b/src/tools/illink/eng/Versions.props @@ -17,11 +17,12 @@ $(MicrosoftNETSdkILPackageVersion) - 1.5.0 + 1.8.0 15.4.8 15.4.8 5.0.0-beta.20464.13 0.11.2 + true diff --git a/src/tools/illink/eng/ilasm.ilproj b/src/tools/illink/eng/ilasm.ilproj index b8be3b2b2255..3a11b2bfe499 100644 --- a/src/tools/illink/eng/ilasm.ilproj +++ b/src/tools/illink/eng/ilasm.ilproj @@ -4,7 +4,7 @@ project. --> - netcoreapp3.0 + net5.0 diff --git a/src/tools/illink/global.json b/src/tools/illink/global.json index 1ff2cfb51af6..1c9fe93790bd 100644 --- a/src/tools/illink/global.json +++ b/src/tools/illink/global.json @@ -1,14 +1,14 @@ { "tools": { - "dotnet": "5.0.100-preview.6.20310.4", + "dotnet": "5.0.100-rc.1.20454.5", "runtimes": { "dotnet": [ - "3.0.0" + "5.0.0-rc.1.20451.14" ] } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.20464.13", + "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.20466.13", "Microsoft.FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0", "Microsoft.NET.Sdk.IL": "6.0.0-alpha.1.20463.3" } diff --git a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj index ef94924561d2..36a49f01677b 100644 --- a/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj +++ b/src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj @@ -2,7 +2,7 @@ - netcoreapp3.0;net472 + net5.0;net472 false MSBuild tasks for running the IL Linker latest @@ -36,7 +36,7 @@ - + diff --git a/src/tools/illink/src/ILLink.Tasks/LinkTask.cs b/src/tools/illink/src/ILLink.Tasks/LinkTask.cs index 11da51673d5b..a2960f1c4fd7 100644 --- a/src/tools/illink/src/ILLink.Tasks/LinkTask.cs +++ b/src/tools/illink/src/ILLink.Tasks/LinkTask.cs @@ -235,7 +235,7 @@ public class ILLink : ToolTask var taskDirectory = Path.GetDirectoryName (Assembly.GetExecutingAssembly ().Location); // The linker always runs on .NET Core, even when using desktop MSBuild to host ILLink.Tasks. - _illinkPath = Path.Combine (Path.GetDirectoryName (taskDirectory), "netcoreapp3.0", "illink.dll"); + _illinkPath = Path.Combine (Path.GetDirectoryName (taskDirectory), "net5.0", "illink.dll"); return _illinkPath; } set => _illinkPath = value; diff --git a/src/tools/illink/src/ILLink.Tasks/Sdk/Sdk.props b/src/tools/illink/src/ILLink.Tasks/Sdk/Sdk.props index 89633629c59b..fc938c6b8fcc 100644 --- a/src/tools/illink/src/ILLink.Tasks/Sdk/Sdk.props +++ b/src/tools/illink/src/ILLink.Tasks/Sdk/Sdk.props @@ -13,7 +13,7 @@ Copyright (c) .NET Foundation. All rights reserved. <_ILLinkTasksDirectoryRoot Condition=" '$(_ILLinkTasksDirectoryRoot)' == '' ">$(MSBuildThisFileDirectory)../tools/ - <_ILLinkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">netcoreapp3.0 + <_ILLinkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">net5.0 <_ILLinkTasksTFM Condition=" '$(_ILLinkTasksTFM)' == '' ">net472 <_ILLinkTasksDirectory>$(_ILLinkTasksDirectoryRoot)$(_ILLinkTasksTFM)/ $(_ILLinkTasksDirectory)ILLink.Tasks.dll diff --git a/src/tools/illink/src/analyzer/analyzer.csproj b/src/tools/illink/src/analyzer/analyzer.csproj index c9b38b487f19..3166183ecc5c 100644 --- a/src/tools/illink/src/analyzer/analyzer.csproj +++ b/src/tools/illink/src/analyzer/analyzer.csproj @@ -9,7 +9,7 @@ $(DefineConstants);FEATURE_ILLINK - netcoreapp3.0 + net5.0 diff --git a/src/tools/illink/src/analyzer/common/Mono.Options/Options.cs b/src/tools/illink/src/analyzer/common/Mono.Options/Options.cs index a68c1608b7c5..a289e6281283 100644 --- a/src/tools/illink/src/analyzer/common/Mono.Options/Options.cs +++ b/src/tools/illink/src/analyzer/common/Mono.Options/Options.cs @@ -748,7 +748,7 @@ protected OptionException (SerializationInfo info, StreamingContext context) get {return this.option;} } -#if !PCL +#if !PCL && !NETCOREAPP #pragma warning disable 618 // SecurityPermissionAttribute is obsolete [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] #pragma warning restore 618 diff --git a/src/tools/illink/src/linker/Directory.Build.props b/src/tools/illink/src/linker/Directory.Build.props index bc3e9d940b3d..1fad0962ee10 100644 --- a/src/tools/illink/src/linker/Directory.Build.props +++ b/src/tools/illink/src/linker/Directory.Build.props @@ -10,7 +10,6 @@ illink IL Linker - netcoreapp3.0 Microsoft.NET.ILLink diff --git a/src/tools/illink/src/linker/Mono.Linker.csproj b/src/tools/illink/src/linker/Mono.Linker.csproj index dd9a28c0459c..471e6d0b3984 100644 --- a/src/tools/illink/src/linker/Mono.Linker.csproj +++ b/src/tools/illink/src/linker/Mono.Linker.csproj @@ -6,6 +6,7 @@ + net5.0 $(DefineConstants);FEATURE_ILLINK true - $(DefineConstants);NETCOREAPP @@ -72,12 +69,4 @@ - - - - - - - - diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs index c9fbea7cc018..b1b7913c76df 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/PathUtilities.cs @@ -15,12 +15,14 @@ public static class PathUtilities public const string ConfigDirectoryName = "Release"; #endif -#if NETCOREAPP3_0 +#if NET5_0 + public const string TFMDirectoryName = "net5.0"; +#elif NETCOREAPP3_0 public const string TFMDirectoryName = "netcoreapp3.0"; #elif NET471 public const string TFMDirectoryName = "net471"; #else - public const string TFMDirectoryName = ""; +#error "Unknown TFM" #endif public static string GetTestsSourceRootDirectory ([CallerFilePath] string thisFile = null) diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index 89af9873ee78..8389b9ad575c 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -880,9 +880,9 @@ void VerifyRecordedReflectionPatterns (AssemblyDefinition original, TestReflecti // By now all verified recorded patterns were removed from the test recorder lists, so validate // that there are no remaining patterns for this type. var recognizedPatternsForType = reflectionPatternRecorder.RecognizedPatterns - .Where (pattern => pattern.Source.DeclaringType.FullName == typeToVerify.FullName); + .Where (pattern => pattern.Source.DeclaringType?.FullName == typeToVerify.FullName); var unrecognizedPatternsForType = reflectionPatternRecorder.UnrecognizedPatterns - .Where (pattern => pattern.Source.DeclaringType.FullName == typeToVerify.FullName); + .Where (pattern => pattern.Source.DeclaringType?.FullName == typeToVerify.FullName); if (recognizedPatternsForType.Any () || unrecognizedPatternsForType.Any ()) { string recognizedPatterns = string.Join (Environment.NewLine, recognizedPatternsForType diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs index 24869feef834..5c8b2900f67f 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestCaseSandbox.cs @@ -127,7 +127,7 @@ public virtual void Populate (TestCaseMetadaProvider metadataProvider) private static NPath GetExpectationsAssemblyPath () { - return new Uri (typeof (KeptAttribute).Assembly.CodeBase).LocalPath.ToNPath (); + return new Uri (typeof (KeptAttribute).Assembly.Location).LocalPath.ToNPath (); } protected void CopyToInputAndExpectations (NPath source)