From ae5b1135f5f232d95b1fb115e1e74ffa9f68ce4a Mon Sep 17 00:00:00 2001
From: Doug Bunting <dougbu@microsoft.com>
Date: Mon, 29 Apr 2019 21:21:00 -0700
Subject: [PATCH] Move from Microsoft.Bcl.Json.Sources to System.Text.Json
 (#9836)

- fix downgrade of CoreFx packages in core-sdk
- change eng/SharedFramework.Externsl.props
- remove System.Buffers and System.Runtime.CompilerServices.Unsafe references
  - System.Text.Json brings them in transitively
  - suppress baseline warning about System.Buffers
- remove more references from Microsoft.AspNetCore.SignalR.Protocols.Json project
  - Microsoft.AspNetCore.SignalR.Common brings necessary .NET Standard 2.0 packages in transitively
- regenerate ref project files

details:
- CoreFx no longer produces the Microsoft.Bcl.Json.Sources package
- System.Text.Json is now .NET Standard 2.0-compatible
- see also dotnet/corefx#37129 and aspnet/Extensions#1610
---
 eng/Dependencies.props                                    | 2 +-
 eng/SharedFramework.External.props                        | 1 +
 eng/Version.Details.xml                                   | 8 ++++----
 eng/Versions.props                                        | 2 +-
 .../Microsoft.AspNetCore.Http.Connections.Common.csproj   | 4 +---
 .../Microsoft.AspNetCore.Http.Connections.Common.csproj   | 7 ++++---
 .../Microsoft.AspNetCore.SignalR.Protocols.Json.csproj    | 3 ---
 .../Microsoft.AspNetCore.SignalR.Protocols.Json.csproj    | 6 ------
 .../ref/Microsoft.AspNetCore.SignalR.Common.csproj        | 4 +---
 .../src/Microsoft.AspNetCore.SignalR.Common.csproj        | 7 ++++---
 10 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/eng/Dependencies.props b/eng/Dependencies.props
index 8cfcf96d7fd..d58eedbfa15 100644
--- a/eng/Dependencies.props
+++ b/eng/Dependencies.props
@@ -42,7 +42,6 @@ and are generated based on the last package release.
     <LatestPackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
     <LatestPackageReference Include="Microsoft.Azure.KeyVault" Version="$(MicrosoftAzureKeyVaultPackageVersion)" />
     <LatestPackageReference Include="Microsoft.Azure.Storage.Blob" Version="$(MicrosoftAzureStorageBlobPackageVersion)" />
-    <LatestPackageReference Include="Microsoft.Bcl.Json.Sources" Version="$(MicrosoftBclJsonSourcesPackageVersion)" />
     <LatestPackageReference Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkPackageVersion)" />
     <LatestPackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCorePackageVersion)" />
     <LatestPackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisCommonPackageVersion)" />
@@ -157,6 +156,7 @@ and are generated based on the last package release.
     <LatestPackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsPackageVersion)" />
     <LatestPackageReference Include="System.ServiceProcess.ServiceController" Version="$(SystemServiceProcessServiceControllerPackageVersion)" />
     <LatestPackageReference Include="System.Text.Encodings.Web" Version="$(SystemTextEncodingsWebPackageVersion)" />
+    <LatestPackageReference Include="System.Text.Json" Version="$(SystemTextJsonPackageVersion)" />
     <LatestPackageReference Include="System.Threading.Channels" Version="$(SystemThreadingChannelsPackageVersion)" />
     <LatestPackageReference Include="System.Threading.Tasks.Extensions" Version="$(SystemThreadingTasksExtensionsPackageVersion)" />
     <LatestPackageReference Include="Utf8Json" Version="$(Utf8JsonPackageVersion)" />
diff --git a/eng/SharedFramework.External.props b/eng/SharedFramework.External.props
index 71db8f8a2a3..f09417b2aa3 100644
--- a/eng/SharedFramework.External.props
+++ b/eng/SharedFramework.External.props
@@ -89,6 +89,7 @@
     <_CompilationOnlyReference Include="System.Buffers" />
     <_CompilationOnlyReference Include="System.ComponentModel.Annotations" />
     <_CompilationOnlyReference Include="System.Runtime.CompilerServices.Unsafe" />
+    <_CompilationOnlyReference Include="System.Text.Json" />
   </ItemGroup>
 
   <!--
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 457ff427347..cceefcea21e 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -285,10 +285,6 @@
       <Uri>https://github.com/aspnet/Extensions</Uri>
       <Sha>b38492576f2ad4025dda6ad49a83324804f9ff9c</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.Bcl.Json.Sources" Version="4.6.0-preview6.19222.12" CoherentParentDependency="Microsoft.NETCore.App">
-      <Uri>https://github.com/dotnet/corefx</Uri>
-      <Sha>a78bd0c13887e26372aafdffb8f06be26563c4a8</Sha>
-    </Dependency>
     <Dependency Name="Microsoft.CSharp" Version="4.6.0-preview6.19229.2" CoherentParentDependency="Microsoft.NETCore.App">
       <Uri>https://github.com/dotnet/corefx</Uri>
       <Sha>7066a0cac2cadd21ca144cc78d1b1fab9b1f9cd7</Sha>
@@ -357,6 +353,10 @@
       <Uri>https://github.com/dotnet/corefx</Uri>
       <Sha>7066a0cac2cadd21ca144cc78d1b1fab9b1f9cd7</Sha>
     </Dependency>
+    <Dependency Name="System.Text.Json" Version="4.6.0-preview6.19229.2" CoherentParentDependency="Microsoft.NETCore.App">
+      <Uri>https://github.com/dotnet/corefx</Uri>
+      <Sha>7066a0cac2cadd21ca144cc78d1b1fab9b1f9cd7</Sha>
+    </Dependency>
     <Dependency Name="System.Threading.Channels" Version="4.6.0-preview6.19229.2" CoherentParentDependency="Microsoft.NETCore.App">
       <Uri>https://github.com/dotnet/corefx</Uri>
       <Sha>7066a0cac2cadd21ca144cc78d1b1fab9b1f9cd7</Sha>
diff --git a/eng/Versions.props b/eng/Versions.props
index 30b5613d1a8..9dd6e109a24 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -22,7 +22,6 @@
     <MicrosoftExtensionsDependencyModelPackageVersion>3.0.0-preview6-27629-07</MicrosoftExtensionsDependencyModelPackageVersion>
     <MicrosoftNETCoreAppPackageVersion>3.0.0-preview6-27629-07</MicrosoftNETCoreAppPackageVersion>
     <!-- Packages from dotnet/corefx -->
-    <MicrosoftBclJsonSourcesPackageVersion>4.6.0-preview6.19222.12</MicrosoftBclJsonSourcesPackageVersion>
     <MicrosoftCSharpPackageVersion>4.6.0-preview6.19229.2</MicrosoftCSharpPackageVersion>
     <MicrosoftWin32RegistryPackageVersion>4.6.0-preview6.19229.2</MicrosoftWin32RegistryPackageVersion>
     <SystemComponentModelAnnotationsPackageVersion>4.6.0-preview6.19229.2</SystemComponentModelAnnotationsPackageVersion>
@@ -40,6 +39,7 @@
     <SystemSecurityPrincipalWindowsPackageVersion>4.6.0-preview6.19229.2</SystemSecurityPrincipalWindowsPackageVersion>
     <SystemServiceProcessServiceControllerPackageVersion>4.6.0-preview6.19229.2</SystemServiceProcessServiceControllerPackageVersion>
     <SystemTextEncodingsWebPackageVersion>4.6.0-preview6.19229.2</SystemTextEncodingsWebPackageVersion>
+    <SystemTextJsonPackageVersion>4.6.0-preview6.19229.2</SystemTextJsonPackageVersion>
     <SystemThreadingChannelsPackageVersion>4.6.0-preview6.19229.2</SystemThreadingChannelsPackageVersion>
     <!-- Only listed explicitly to workaround https://github.com/dotnet/cli/issues/10528 -->
     <MicrosoftNETCorePlatformsPackageVersion>3.0.0-preview6.19229.2</MicrosoftNETCorePlatformsPackageVersion>
diff --git a/src/SignalR/common/Http.Connections.Common/ref/Microsoft.AspNetCore.Http.Connections.Common.csproj b/src/SignalR/common/Http.Connections.Common/ref/Microsoft.AspNetCore.Http.Connections.Common.csproj
index c564d1974e8..e7de246e935 100644
--- a/src/SignalR/common/Http.Connections.Common/ref/Microsoft.AspNetCore.Http.Connections.Common.csproj
+++ b/src/SignalR/common/Http.Connections.Common/ref/Microsoft.AspNetCore.Http.Connections.Common.csproj
@@ -6,9 +6,7 @@
   <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
     <Compile Include="Microsoft.AspNetCore.Http.Connections.Common.netstandard2.0.cs" />
     <Reference Include="Microsoft.AspNetCore.Connections.Abstractions"  />
-    <Reference Include="Microsoft.Bcl.Json.Sources"  />
-    <Reference Include="System.Buffers"  />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe"  />
+    <Reference Include="System.Text.Json"  />
   </ItemGroup>
 <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
     <Compile Include="Microsoft.AspNetCore.Http.Connections.Common.netcoreapp3.0.cs" />
diff --git a/src/SignalR/common/Http.Connections.Common/src/Microsoft.AspNetCore.Http.Connections.Common.csproj b/src/SignalR/common/Http.Connections.Common/src/Microsoft.AspNetCore.Http.Connections.Common.csproj
index 533add06e18..29d4251866d 100644
--- a/src/SignalR/common/Http.Connections.Common/src/Microsoft.AspNetCore.Http.Connections.Common.csproj
+++ b/src/SignalR/common/Http.Connections.Common/src/Microsoft.AspNetCore.Http.Connections.Common.csproj
@@ -20,14 +20,15 @@
   </ItemGroup>
 
   <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'" >
-    <Reference Include="Microsoft.Bcl.Json.Sources" />
-    <Reference Include="System.Buffers" />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe" />
+    <Reference Include="System.Text.Json" />
   </ItemGroup>
 
   <ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
     <!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
     <SuppressBaselineReference Include="Newtonsoft.Json" />
+
+    <!-- System.Text.Json (for .NET Standard 2.0) and ShardFx bring System.Buffers in (transitively). No need for both here. -->
+    <SuppressBaselineReference Include="System.Buffers" />
   </ItemGroup>
 
 </Project>
diff --git a/src/SignalR/common/Protocols.Json/ref/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj b/src/SignalR/common/Protocols.Json/ref/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj
index 28a3dc0426d..7e0ddcd3dad 100644
--- a/src/SignalR/common/Protocols.Json/ref/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj
+++ b/src/SignalR/common/Protocols.Json/ref/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj
@@ -6,9 +6,6 @@
   <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
     <Compile Include="Microsoft.AspNetCore.SignalR.Protocols.Json.netstandard2.0.cs" />
     <Reference Include="Microsoft.AspNetCore.SignalR.Common"  />
-    <Reference Include="Microsoft.Bcl.Json.Sources"  />
-    <Reference Include="System.Buffers"  />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe"  />
   </ItemGroup>
 <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
     <Compile Include="Microsoft.AspNetCore.SignalR.Protocols.Json.netcoreapp3.0.cs" />
diff --git a/src/SignalR/common/Protocols.Json/src/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj b/src/SignalR/common/Protocols.Json/src/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj
index 763b8853d65..a252ecf33e5 100644
--- a/src/SignalR/common/Protocols.Json/src/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj
+++ b/src/SignalR/common/Protocols.Json/src/Microsoft.AspNetCore.SignalR.Protocols.Json.csproj
@@ -22,12 +22,6 @@
     <Reference Include="Microsoft.AspNetCore.SignalR.Common" />
   </ItemGroup>
 
-  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
-    <Reference Include="Microsoft.Bcl.Json.Sources" />
-    <Reference Include="System.Buffers" />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe" />
-  </ItemGroup>
-
   <ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
     <!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
     <SuppressBaselineReference Include="Newtonsoft.Json" />
diff --git a/src/SignalR/common/SignalR.Common/ref/Microsoft.AspNetCore.SignalR.Common.csproj b/src/SignalR/common/SignalR.Common/ref/Microsoft.AspNetCore.SignalR.Common.csproj
index aa6ace09f82..e1fb26d63eb 100644
--- a/src/SignalR/common/SignalR.Common/ref/Microsoft.AspNetCore.SignalR.Common.csproj
+++ b/src/SignalR/common/SignalR.Common/ref/Microsoft.AspNetCore.SignalR.Common.csproj
@@ -7,9 +7,7 @@
     <Compile Include="Microsoft.AspNetCore.SignalR.Common.netstandard2.0.cs" />
     <Reference Include="Microsoft.AspNetCore.Connections.Abstractions"  />
     <Reference Include="Microsoft.Extensions.Options"  />
-    <Reference Include="Microsoft.Bcl.Json.Sources"  />
-    <Reference Include="System.Buffers"  />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe"  />
+    <Reference Include="System.Text.Json"  />
   </ItemGroup>
 <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
     <Compile Include="Microsoft.AspNetCore.SignalR.Common.netcoreapp3.0.cs" />
diff --git a/src/SignalR/common/SignalR.Common/src/Microsoft.AspNetCore.SignalR.Common.csproj b/src/SignalR/common/SignalR.Common/src/Microsoft.AspNetCore.SignalR.Common.csproj
index 4370a504b1d..d1ba59a3eb8 100644
--- a/src/SignalR/common/SignalR.Common/src/Microsoft.AspNetCore.SignalR.Common.csproj
+++ b/src/SignalR/common/SignalR.Common/src/Microsoft.AspNetCore.SignalR.Common.csproj
@@ -25,14 +25,15 @@
   </ItemGroup>
 
   <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
-    <Reference Include="Microsoft.Bcl.Json.Sources" />
-    <Reference Include="System.Buffers" />
-    <Reference Include="System.Runtime.CompilerServices.Unsafe" />
+    <Reference Include="System.Text.Json" />
   </ItemGroup>
 
   <ItemGroup Condition="'$(AspNetCoreMajorMinorVersion)' == '3.0'">
     <!-- This dependency was replaced by System.Text.Json between 3.0 and 2.2. This suppression can be removed after 3.0 is complete. -->
     <SuppressBaselineReference Include="Newtonsoft.Json" />
+
+    <!-- System.Text.Json (for .NET Standard 2.0) and ShardFx bring System.Buffers in (transitively). No need for both here. -->
+    <SuppressBaselineReference Include="System.Buffers" />
   </ItemGroup>
 
 </Project>
-- 
GitLab