Skip to content

Commit

Permalink
Update to target .NET5 framework (dotnet/linker#1471)
Browse files Browse the repository at this point in the history
Co-authored-by: vitek-karas <vitek.karas@microsoft.com>
Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>

Commit migrated from dotnet/linker@cc5c0f9
  • Loading branch information
marek-safar committed Sep 17, 2020
1 parent 0c2e1df commit 4bc8225
Show file tree
Hide file tree
Showing 29 changed files with 116 additions and 46 deletions.
2 changes: 2 additions & 0 deletions src/tools/illink/Directory.Build.props
Expand Up @@ -7,6 +7,8 @@
<IsReferenceAssembly Condition="'$(IsReferenceAssembly)' == '' and '$([System.IO.Path]::GetFileName($(MSBuildProjectDirectory)))' == 'ref'">true</IsReferenceAssembly>
</PropertyGroup>
<PropertyGroup Condition=" '$(IsReferenceAssembly)' == 'true' ">
<!-- Since .NET 5 reference assemblies are always produced -->
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<ProduceOnlyReferenceAssembly>true</ProduceOnlyReferenceAssembly>
<!-- Used by Arcade to compute OutputPath, IntermediateOutputPath, etc. early in the import chain. -->
<OutDirName>$(MSBuildProjectName)/ref</OutDirName>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/illink/eng/Version.Details.xml
Expand Up @@ -3,7 +3,7 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.20464.13">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.20466.13">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>bd918c64b786bdba42e895e4cb93603e5a2ca608</Sha>
</Dependency>
Expand Down
3 changes: 2 additions & 1 deletion src/tools/illink/eng/Versions.props
Expand Up @@ -17,11 +17,12 @@
<!-- see https://github.com/dotnet/runtime/issues/1338 -->
<MicrosoftNETCoreILAsmVersion>$(MicrosoftNETSdkILPackageVersion)</MicrosoftNETCoreILAsmVersion>
<!-- These should match the SDK version at https://github.com/dotnet/sdk/blob/master/eng/Versions.props -->
<SystemReflectionMetadataVersion>1.5.0</SystemReflectionMetadataVersion>
<SystemReflectionMetadataVersion>1.8.0</SystemReflectionMetadataVersion>
<MicrosoftBuildFrameworkVersion>15.4.8</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildUtilitiesCoreVersion>15.4.8</MicrosoftBuildUtilitiesCoreVersion>
<MicrosoftDotNetApiCompatVersion>5.0.0-beta.20464.13</MicrosoftDotNetApiCompatVersion>
<!-- We depend on (and redistribute) the official Mono.Cecil NuGet package built from https://github.com/jbevain/cecil -->
<MonoCecilVersion>0.11.2</MonoCecilVersion>
<UseVSTestRunner>true</UseVSTestRunner>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/tools/illink/eng/ilasm.ilproj
Expand Up @@ -4,7 +4,7 @@
project. -->

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<Target Name="CopyILAsmTool" DependsOnTargets="ResolveIlasmToolPaths" Condition="'$(MonoBuild)' == ''">
Expand Down
6 changes: 3 additions & 3 deletions 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"
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/illink/src/ILLink.Tasks/ILLink.Tasks.csproj
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Keep these in sync with _ILLinkTasksTFM in Sdk.props. -->
<!-- Keep the netcoreapp TFM in sync with the Mono.Linker.csproj condition below. -->
<TargetFrameworks>netcoreapp3.0;net472</TargetFrameworks>
<TargetFrameworks>net5.0;net472</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<Description>MSBuild tasks for running the IL Linker</Description>
<LangVersion>latest</LangVersion>
Expand Down Expand Up @@ -36,7 +36,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../linker/Mono.Linker.csproj" PrivateAssets="All" Condition=" '$(TargetFramework)' == 'netcoreapp3.0' " />
<ProjectReference Include="../linker/Mono.Linker.csproj" PrivateAssets="All" Condition=" '$(TargetFramework)' == 'net5.0' " />
<PackageReference Condition="'$(UseCecilPackage)' == 'true'" Include="Mono.Cecil" Version="$(MonoCecilVersion)" PrivateAssets="All" Publish="True" />
<ProjectReference Condition="'$(UseCecilPackage)' != 'true'" Include="../../external/cecil/Mono.Cecil.csproj" PrivateAssets="All" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/illink/src/ILLink.Tasks/LinkTask.cs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/illink/src/ILLink.Tasks/Sdk/Sdk.props
Expand Up @@ -13,7 +13,7 @@ Copyright (c) .NET Foundation. All rights reserved.

<PropertyGroup>
<_ILLinkTasksDirectoryRoot Condition=" '$(_ILLinkTasksDirectoryRoot)' == '' ">$(MSBuildThisFileDirectory)../tools/</_ILLinkTasksDirectoryRoot>
<_ILLinkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">netcoreapp3.0</_ILLinkTasksTFM>
<_ILLinkTasksTFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">net5.0</_ILLinkTasksTFM>
<_ILLinkTasksTFM Condition=" '$(_ILLinkTasksTFM)' == '' ">net472</_ILLinkTasksTFM>
<_ILLinkTasksDirectory>$(_ILLinkTasksDirectoryRoot)$(_ILLinkTasksTFM)/</_ILLinkTasksDirectory>
<ILLinkTasksAssembly Condition=" '$(ILLinkTasksAssembly)' == '' ">$(_ILLinkTasksDirectory)ILLink.Tasks.dll</ILLinkTasksAssembly>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/illink/src/analyzer/analyzer.csproj
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup Condition="'$(MonoBuild)' == ''">
<DefineConstants>$(DefineConstants);FEATURE_ILLINK</DefineConstants>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(MonoBuild)' != ''">
Expand Down
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/tools/illink/src/linker/Directory.Build.props
Expand Up @@ -10,7 +10,6 @@
<PropertyGroup Condition="'$(MonoBuild)' == ''">
<AssemblyName>illink</AssemblyName>
<Description>IL Linker</Description>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PackageId>Microsoft.NET.ILLink</PackageId>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions src/tools/illink/src/linker/Mono.Linker.csproj
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(MonoBuild)' == ''">
<TargetFramework>net5.0</TargetFramework>
<DefineConstants>$(DefineConstants);FEATURE_ILLINK</DefineConstants>
<IsPackable>true</IsPackable>
<!-- Nuget issues a warning about missing <reference> items in the generated nuspec,
Expand Down Expand Up @@ -33,6 +34,7 @@
<Compile Remove="Linker.Steps\PreserveCalendarsStep.cs" />
<Compile Remove="Linker.Steps\RemoveFeaturesStep.cs" />
<Compile Remove="Linker.Steps\ResolveFromXApiStep.cs" />
<Compile Remove="System.Diagnostics.CodeAnalysis\*.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/tools/illink/src/linker/ref/Mono.Linker.csproj
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<BuildOutputTargetFolder>ref</BuildOutputTargetFolder>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Expand Up @@ -5,10 +5,14 @@
</PropertyGroup>

<PropertyGroup Condition="'$(MonoBuild)' == ''">
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(MonoBuild)' != ''">
<TargetFramework>net471</TargetFramework>
</PropertyGroup>

<ItemGroup Condition="'$(MonoBuild)' == ''">
<Compile Remove="System.Diagnostics.CodeAnalysis\*.cs" />
</ItemGroup>

</Project>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="Test">
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2067</argument>
<property name="Scope">member</property>
Expand All @@ -18,45 +18,45 @@
</field>
<method signature="System.Void TwoAnnotatedParameters(System.Type,System.Type)">
<parameter name="type">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>PublicParameterlessConstructor</argument>
</attribute>
</parameter>
<parameter name="type2">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>PublicConstructors</argument>
</attribute>
</parameter>
</method>
<method signature="SpacesBetweenParametersWrongArgument (System.Type, System.Boolean)">
<parameter name="type">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>NonValidArgument</argument>
</attribute>
</parameter>
</method>
<method signature="GenericMethod&lt;T&gt;(T,System.Type)">
<parameter name="type">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>PublicParameterlessConstructor</argument>
</attribute>
</parameter>
</method>
<method name="ReturnConstructorsFailure">
<return>
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>PublicParameterlessConstructor</argument>
</attribute>
</return>
</method>
<property name="PropertyWithPublicParameterlessConstructor">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>PublicParameterlessConstructor</argument>
</attribute>
</property>
<type name="NestedType">
<field name="_typeWithPublicParameterlessConstructor">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute">
<argument>PublicParameterlessConstructor</argument>
</attribute>
</field>
Expand Down
Expand Up @@ -6,7 +6,15 @@

namespace Mono.Linker.Tests.Cases.DynamicDependencies
{
[SetupLinkAttributesFile ("DynamicDependencyFromAttributeXml.Attributes.xml")]
// For netcoreapp we don't have to specify the assembly for the attribute, since the attribute comes from corelib
// and will be found always.
// For mono though, we have to specify the assembly (Mono.Linker.Tests.Cases.Expectations) because at the time of processing
// that assembly is not yet loaded into the closure in the linker, so it won't find the attribute type.
#if NETCOREAPP
[SetupLinkAttributesFile ("DynamicDependencyFromAttributeXml.netcore.Attributes.xml")]
#else
[SetupLinkAttributesFile ("DynamicDependencyFromAttributeXml.mono.Attributes.xml")]
#endif
[IgnoreLinkAttributes (false)]
class DynamicDependencyFromAttributeXml
{
Expand Down
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="Mono.Linker.Tests.Cases.DynamicDependencies.DynamicDependencyFromAttributeXml">
<method name="DependencyToUnusedMethod">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<argument>UnusedMethod</argument>
</attribute>
</method>
</type>
</assembly>
</linker>
Expand Up @@ -3,7 +3,7 @@
<assembly fullname="test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="Mono.Linker.Tests.Cases.DynamicDependencies.DynamicDependencyFromAttributeXml">
<method name="DependencyToUnusedMethod">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute" assembly="Mono.Linker.Tests.Cases.Expectations">
<attribute fullname="System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute">
<argument>UnusedMethod</argument>
</attribute>
</method>
Expand Down
Expand Up @@ -3,4 +3,7 @@
<assembly fullname="Mono.Linker.Tests.Cases.Expectations">
<type fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"/>
</assembly>
<assembly fullname="System.Runtime">
<type fullname="System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute"/>
</assembly>
</linker>
Expand Up @@ -5,11 +5,11 @@
<WarningLevel>0</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<LangVersion>8.0</LangVersion>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(MonoBuild)' == ''">
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<DefineConstants>$(DefineConstants);ILLINK</DefineConstants>
</PropertyGroup>

Expand Down
Expand Up @@ -424,6 +424,10 @@ public TestCreateInstanceOfTWithNoConstraintType (int i)

[Kept]
[UnrecognizedReflectionAccessPattern (typeof (Activator), nameof (Activator.CreateInstance) + "<T>", new Type[0], messageCode: "IL2091")]
#if NETCOREAPP
// Warnings are currently duplicated in NETCORE (annotation and intrinsics) - but they're not identical in this case, so we have to list both cases
[UnrecognizedReflectionAccessPattern (typeof (Activator), nameof (Activator.CreateInstance) + "<T>()::T", messageCode: "IL2091")]
#endif
private static void TestCreateInstanceOfTWithNoConstraint<T> ()
{
Activator.CreateInstance<T> ();
Expand Down
Expand Up @@ -8,7 +8,15 @@

namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
{
[SetupLinkAttributesFile ("SuppressWarningsUsingTargetViaXml.xml")]
// For netcoreapp we don't have to specify the assembly for the attribute, since the attribute comes from corelib
// and will be found always.
// For mono though, we have to specify the assembly (Mono.Linker.Tests.Cases.Expectations) because at the time of processing
// that assembly is not yet loaded into the closure in the linker, so it won't find the attribute type.
#if NETCOREAPP
[SetupLinkAttributesFile ("SuppressWarningsUsingTargetViaXml.netcore.xml")]
#else
[SetupLinkAttributesFile ("SuppressWarningsUsingTargetViaXml.mono.xml")]
#endif
[SetupCompileBefore ("library.dll", new[] { "Dependencies/TriggerWarnings_Lib.cs" })]
[KeptAssembly ("library.dll")]
[SetupLinkerAction ("link", "library.dll")]
Expand Down
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<linker>
<assembly fullname="library, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:Mono.Linker.Tests.Cases.Warnings.WarningSuppression.Dependencies.TriggerWarnings_Lib.Main</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:Mono.Linker.Tests.Cases.Warnings.WarningSuppression.Dependencies.TriggerWarnings_Lib.NestedType.Warning3</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:Mono.Linker.Tests.Cases.Warnings.WarningSuppression.Dependencies.TriggerWarnings_Lib.NestedType.Warning4``1(System.Collections.Generic.List{``0}@)</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:Mono.Linker.Tests.Cases.Warnings.WarningSuppression.Dependencies.TriggerWarnings_Lib.Warning1</property>
</attribute>
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
<argument>ILLink</argument>
<argument>IL2072</argument>
<property name="Scope">member</property>
<property name="Target">M:Mono.Linker.Tests.Cases.Warnings.WarningSuppression.Dependencies.TriggerWarnings_Lib.get_Warning2</property>
</attribute>
</assembly>
</linker>
15 changes: 2 additions & 13 deletions src/tools/illink/test/Mono.Linker.Tests/Mono.Linker.Tests.csproj
@@ -1,17 +1,14 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup Condition="'$(MonoBuild)' == ''">
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<DefineConstants>$(DefineConstants);ILLINK</DefineConstants>
<DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);DEBUG</DefineConstants>
<!-- Simulate https://github.com/dotnet/sdk/pull/2073 until it ships. -->
<DefineConstants Condition="'$(TargetFramework)' == 'netcoreapp3.0'">$(DefineConstants);NETCOREAPP</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(MonoBuild)' != ''">
Expand Down Expand Up @@ -72,12 +69,4 @@
<Exec Command="mono $(PkgNUnit_ConsoleRunner)/tools/nunit3-console.exe --result=TestResults.xml $(OutputPath)Mono.Linker.Tests.dll" />
</Target>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

<!-- Arcade's custom test imports assume that we are using xunit. -->
<!-- Map the Arcade "Test" target to the "VSTest" target used by "dotnet test" -->
<Target Name="Test" Condition="'$(MonoBuild)' == ''">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="VSTest" />
</Target>

</Project>

0 comments on commit 4bc8225

Please sign in to comment.