[wasm] Port additional fixes in #52078 main (#52125)
authorLarry Ewing <lewing@microsoft.com>
Sat, 1 May 2021 00:28:54 +0000 (19:28 -0500)
committerGitHub <noreply@github.com>
Sat, 1 May 2021 00:28:54 +0000 (19:28 -0500)
* Port additional fixes in #52078 main

* Update src/tasks/AotCompilerTask/MonoAOTCompiler.csproj

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Update src/tasks/WasmAppBuilder/WasmAppBuilder.csproj

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Update src/tasks/WasmAppBuilder/WasmAppBuilder.csproj

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Apply suggestions from code review

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Use a property for net472

* Use consistent separator character

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
src/tasks/AotCompilerTask/MonoAOTCompiler.csproj
src/tasks/Common/IsExternalInit.cs [new file with mode: 0644]
src/tasks/Common/NotNullAttribute.cs [deleted file]
src/tasks/Directory.Build.props [new file with mode: 0644]
src/tasks/WasmAppBuilder/WasmAppBuilder.cs
src/tasks/WasmAppBuilder/WasmAppBuilder.csproj

index e4e889fb8c2e890acd7eb732d2ced25dccded38b..1538b0669b95481a1d77d407e884095afdcec334 100644 (file)
@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFrameworks>$(NetCoreAppToolCurrent);net472</TargetFrameworks>
+    <TargetFrameworks>$(NetCoreAppToolCurrent);$(TargetFrameworkForNETFramework)</TargetFrameworks>
     <OutputType>Library</OutputType>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
@@ -19,7 +19,7 @@
   <ItemGroup>
     <Compile Include="MonoAOTCompiler.cs" />
     <Compile Include="..\Common\Utils.cs" />
-    <Compile Include="..\Common\NotNullAttribute.cs" Condition="$(TargetFramework.StartsWith('net4'))" />
+    <Compile Include="$(RepoRoot)src\libraries\System.Private.CoreLib\src\System\Diagnostics\CodeAnalysis\NullableAttributes.cs" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="MonoAOTCompiler.props">
diff --git a/src/tasks/Common/IsExternalInit.cs b/src/tasks/Common/IsExternalInit.cs
new file mode 100644 (file)
index 0000000..d7be691
--- /dev/null
@@ -0,0 +1,7 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace System.Runtime.CompilerServices
+{
+    internal sealed class IsExternalInit { }
+}
diff --git a/src/tasks/Common/NotNullAttribute.cs b/src/tasks/Common/NotNullAttribute.cs
deleted file mode 100644 (file)
index 3d9af52..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-[System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property | System.AttributeTargets.ReturnValue, Inherited=false)]
-public sealed class NotNullAttribute : System.Attribute
-{
-}
diff --git a/src/tasks/Directory.Build.props b/src/tasks/Directory.Build.props
new file mode 100644 (file)
index 0000000..7ed8a45
--- /dev/null
@@ -0,0 +1,7 @@
+<Project>
+  <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props, '$(MSBuildThisFileDirectory)..'))" />
+
+  <PropertyGroup>
+    <TargetFrameworkForNETFramework>net472</TargetFrameworkForNETFramework>
+  </PropertyGroup>
+</Project>
index a8a8b1ebee3c8230e9f27a1ae2708a65d82a8bb9..9ef7679c292b6683244986f9d0c960e9af895de5 100644 (file)
@@ -86,9 +86,9 @@ public class WasmAppBuilder : Task
             Behavior = behavior;
         }
         [JsonPropertyName("behavior")]
-        public string Behavior { get; set; }
+        public string Behavior { get; init; }
         [JsonPropertyName("name")]
-        public string Name { get; set; }
+        public string Name { get; init; }
     }
 
     private class AssemblyEntry : AssetEntry
index aa5f258b45ae47c2ff23894372d9d44f2935d880..e7641b3ab1aad70170b3aa61d23e932c35ae02f5 100644 (file)
@@ -1,15 +1,19 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFrameworks>$(NetCoreAppToolCurrent);net472</TargetFrameworks>
+    <TargetFrameworks>$(NetCoreAppToolCurrent);$(TargetFrameworkForNETFramework)</TargetFrameworks>
     <Nullable>enable</Nullable>
     <NoWarn>$(NoWarn),CA1050</NoWarn>
 
     <!-- Ignore nullable warnings on net4* -->
-    <NoWarn Condition="$(TargetFramework.StartsWith('net4'))">$(NoWarn),CS8604,CS8602</NoWarn>
+    <NoWarn Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">$(NoWarn),CS8604,CS8602</NoWarn>
   </PropertyGroup>
-  <ItemGroup>
-    <Compile Include="..\Common\NotNullAttribute.cs" Condition="$(TargetFramework.StartsWith('net4'))" />
 
+  <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
+    <Compile Include="..\Common\IsExternalInit.cs" />
+    <Compile Include="$(RepoRoot)src\libraries\System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs" />
+  </ItemGroup>
+
+  <ItemGroup>
     <PackageReference Include="Microsoft.Build" Version="$(RefOnlyMicrosoftBuildVersion)" />
     <PackageReference Include="Microsoft.Build.Framework" Version="$(RefOnlyMicrosoftBuildFrameworkVersion)" />
     <PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(RefOnlyMicrosoftBuildTasksCoreVersion)" />
       <_PublishFramework Include="$(TargetFrameworks)" />
 
       <!-- non-net4* -->
-      <FilesToPackage Include="$(OutputPath)%(_PublishFramework.Identity)\$(MSBuildProjectName)*"
-                      Condition="!$([System.String]::Copy('%(_PublishFramework.Identity)').StartsWith('net4'))"
-                      TargetPath="tasks\%(_PublishFramework.Identity)" />
-      <FilesToPackage Include="$(OutputPath)%(_PublishFramework.Identity)\publish\System.Reflection.MetadataLoadContext.dll"
-                      Condition="!$([System.String]::Copy('%(_PublishFramework.Identity)').StartsWith('net4'))"
-                      TargetPath="tasks\%(_PublishFramework.Identity)" />
+      <FilesToPackage Include="$(OutputPath)$(NetCoreAppToolCurrent)\$(MSBuildProjectName)*"
+                      TargetPath="tasks\$(NetCoreAppToolCurrent)" />
+      <FilesToPackage Include="$(OutputPath)$(NetCoreAppToolCurrent)\publish\System.Reflection.MetadataLoadContext.dll"
+                      TargetPath="tasks\$(NetCoreAppToolCurrent)" />
 
       <!-- for net472 we need all the dependent assemblies too, so copy from the publish folder -->
-      <FilesToPackage Include="$(OutputPath)%(_PublishFramework.Identity)\publish\*"
-                      Condition="$([System.String]::Copy('%(_PublishFramework.Identity)').StartsWith('net4'))"
-                      TargetPath="tasks\%(_PublishFramework.Identity)" />
+      <FilesToPackage Include="$(OutputPath)$(TargetFrameworkForNETFramework)\publish\*"
+                      TargetPath="tasks\$(TargetFrameworkForNETFramework)" />
     </ItemGroup>
   </Target>