diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json
index d6471277244259..9aa48ca41af5e3 100644
--- a/.config/dotnet-tools.json
+++ b/.config/dotnet-tools.json
@@ -15,7 +15,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
- "version": "1.0.0-prerelease.21154.2",
+ "version": "1.0.0-prerelease.21165.2",
"commands": [
"xharness"
]
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 3db4c219dfb241..3d1c02c54427d8 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -1,74 +1,74 @@
-
+
https://github.com/dotnet/icu
- 3dc14146be2c110eedc947afa62894f9b53b4f04
+ 9ffb5011f22ed30f09edba7b88309d83d1d99682
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 7f13798e5f567b72ffe63205bf49839245f0f8c1
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
-
+
https://github.com/dotnet/arcade
- 287fba3cbedce004fbd9823c268327960a69ca88
+ d88b466beb295e15b5e3bcb36b02b7900d4fd0ca
https://dev.azure.com/dnceng/internal/_git/dotnet-optimization
@@ -94,117 +94,117 @@
https://github.com/microsoft/vstest
140434f7109d357d0158ade9e5164a4861513965
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/runtime-assets
- c7c14818023404ed900360565f8289b8e14d9aa4
+ f01b1fca0c9157a16ade2629eb7d49a220b7e9ba
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
-
+
https://github.com/dotnet/llvm-project
- 121a29ab0b411db38efa6659307d86fe04aefcb8
+ 306703c30ca8509acf4abf85e96949edf6bb0472
https://github.com/dotnet/runtime
38017c3935de95d0335bac04f4901ddfc2718656
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/dotnet/runtime
- acbbb505492244b4c07a4a368257ba86a1fc02e1
+ 5ef6a0687ad58fdb726387897cde0d2584264fb6
-
+
https://github.com/mono/linker
- 0c4902a114192fce1e7570d998e70d24669e9cc3
+ c44302b73f744c24293c3092a011655f1a4fffe0
-
+
https://github.com/dotnet/xharness
- 645910141e0ef98efee3c5bf9128b8fefb1a3c01
+ 88f5732717457aff2c903fbdc66994d01fa1c8f1
-
+
https://github.com/dotnet/xharness
- 645910141e0ef98efee3c5bf9128b8fefb1a3c01
+ 88f5732717457aff2c903fbdc66994d01fa1c8f1
diff --git a/eng/Versions.props b/eng/Versions.props
index 261c39bba7ca4e..a4f48ac66299df 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -49,27 +49,27 @@
3.9.0-5.final
3.9.0-5.final
- 6.0.0-beta.21160.7
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 2.5.1-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
- 6.0.0-beta.21155.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 2.5.1-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
+ 6.0.0-beta.21165.1
5.9.0-preview.2
6.0.0-alpha.1.20612.4
- 6.0.0-preview.3.21157.6
- 6.0.0-preview.3.21157.6
+ 6.0.0-preview.3.21164.8
+ 6.0.0-preview.3.21164.8
3.1.0
- 6.0.0-preview.3.21157.6
+ 6.0.0-preview.3.21164.8
1.2.0-beta.304
4.5.1
@@ -97,24 +97,24 @@
4.7.0
4.7.0
4.7.0
- 6.0.0-preview.3.21157.6
- 6.0.0-preview.3.21157.6
+ 6.0.0-preview.3.21164.8
+ 6.0.0-preview.3.21164.8
4.3.0
4.5.4
4.5.0
1.1.1
4.3.0
- 6.0.0-preview.3.21157.6
+ 6.0.0-preview.3.21164.8
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
- 5.0.0-beta.21159.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
+ 6.0.0-beta.21162.1
99.99.99-master-20200806.6
99.99.99-master-20200806.6
@@ -144,8 +144,8 @@
1.0.1-prerelease-00006
16.9.0-preview-20201201-01
- 1.0.0-prerelease.21154.2
- 1.0.0-prerelease.21154.2
+ 1.0.0-prerelease.21165.2
+ 1.0.0-prerelease.21165.2
2.4.1
2.4.2
1.3.0
@@ -155,18 +155,18 @@
5.0.0-preview-20201009.2
- 6.0.100-preview.2.21126.1
+ 6.0.100-preview.2.21162.2
- 6.0.0-preview.3.21151.1
+ 6.0.0-preview.3.21165.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
- 9.0.1-alpha.1.21158.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
+ 9.0.1-alpha.1.21165.1
diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1
index b6e55f5e74a740..2427ca6b6aec74 100644
--- a/eng/common/post-build/publish-using-darc.ps1
+++ b/eng/common/post-build/publish-using-darc.ps1
@@ -55,15 +55,12 @@ try {
$optionalParams.Add($SigningValidationAdditionalParameters) | Out-Null
}
}
- # note the custom branch to work around https://github.com/dotnet/arcade/issues/6987 . Try to keep this rebased off master if publishing changes
-
- Write-Host "Using Arcade branch master-workaround-publishing-issue to work around disk space issues with alternate build pool. Will be lost on Arcade updates as this is in eng common. Contact dnceng for questions."
-
+
& $darc add-build-to-channel `
--id $buildId `
--publishing-infra-version $PublishingInfraVersion `
--default-channels `
- --source-branch master-workaround-publishing-issue `
+ --source-branch main `
--azdev-pat $AzdoToken `
--bar-uri $MaestroApiEndPoint `
--password $MaestroToken `
diff --git a/eng/common/templates/job/execute-sdl.yml b/eng/common/templates/job/execute-sdl.yml
index 53c100222b217c..4a32181fd8f932 100644
--- a/eng/common/templates/job/execute-sdl.yml
+++ b/eng/common/templates/job/execute-sdl.yml
@@ -45,6 +45,7 @@ jobs:
buildId: $(AzDOBuildId)
artifactName: ${{ artifactName }}
downloadPath: $(Build.ArtifactStagingDirectory)\artifacts
+ checkDownloadedFiles: true
- ${{ if eq(parameters.artifactNames, '') }}:
- task: DownloadBuildArtifacts@0
displayName: Download Build Artifacts
@@ -57,6 +58,7 @@ jobs:
downloadType: specific files
itemPattern: "**"
downloadPath: $(Build.ArtifactStagingDirectory)\artifacts
+ checkDownloadedFiles: true
- powershell: eng/common/sdl/extract-artifact-packages.ps1
-InputPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts
-ExtractPath $(Build.ArtifactStagingDirectory)\artifacts\BlobArtifacts
diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml
index 66ef736417f697..3b9e2524ff37ca 100644
--- a/eng/common/templates/job/publish-build-assets.yml
+++ b/eng/common/templates/job/publish-build-assets.yml
@@ -52,6 +52,7 @@ jobs:
inputs:
artifactName: AssetManifests
downloadPath: '$(Build.StagingDirectory)/Download'
+ checkDownloadedFiles: true
condition: ${{ parameters.condition }}
continueOnError: ${{ parameters.continueOnError }}
diff --git a/eng/common/templates/phases/publish-build-assets.yml b/eng/common/templates/phases/publish-build-assets.yml
index a0a8074282aa86..4e51e472e2bbab 100644
--- a/eng/common/templates/phases/publish-build-assets.yml
+++ b/eng/common/templates/phases/publish-build-assets.yml
@@ -20,6 +20,7 @@ phases:
inputs:
artifactName: AssetManifests
downloadPath: '$(Build.StagingDirectory)/Download'
+ checkDownloadedFiles: true
condition: ${{ parameters.condition }}
continueOnError: ${{ parameters.continueOnError }}
- task: AzureKeyVault@1
diff --git a/eng/common/templates/post-build/channels/generic-internal-channel.yml b/eng/common/templates/post-build/channels/generic-internal-channel.yml
index 7ae5255921aa8e..58fa9a35b8ca94 100644
--- a/eng/common/templates/post-build/channels/generic-internal-channel.yml
+++ b/eng/common/templates/post-build/channels/generic-internal-channel.yml
@@ -58,6 +58,7 @@ stages:
PdbArtifacts/**
BlobArtifacts/**
downloadPath: '$(Build.ArtifactStagingDirectory)'
+ checkDownloadedFiles: true
# This is necessary whenever we want to publish/restore to an AzDO private feed
# Since sdk-task.ps1 tries to restore packages we need to do this authentication here
@@ -124,6 +125,7 @@ stages:
BlobArtifacts/**
AssetManifests/**
downloadPath: '$(Build.ArtifactStagingDirectory)'
+ checkDownloadedFiles: true
- task: NuGetToolInstaller@1
displayName: 'Install NuGet.exe'
diff --git a/eng/common/templates/post-build/channels/generic-public-channel.yml b/eng/common/templates/post-build/channels/generic-public-channel.yml
index 6cf39dbb2907c4..b50c0b3bdb8e67 100644
--- a/eng/common/templates/post-build/channels/generic-public-channel.yml
+++ b/eng/common/templates/post-build/channels/generic-public-channel.yml
@@ -56,6 +56,7 @@ stages:
PdbArtifacts/**
BlobArtifacts/**
downloadPath: '$(Build.ArtifactStagingDirectory)'
+ checkDownloadedFiles: true
# This is necessary whenever we want to publish/restore to an AzDO private feed
# Since sdk-task.ps1 tries to restore packages we need to do this authentication here
@@ -123,6 +124,7 @@ stages:
BlobArtifacts/**
AssetManifests/**
downloadPath: '$(Build.ArtifactStagingDirectory)'
+ checkDownloadedFiles: true
- task: NuGetToolInstaller@1
displayName: 'Install NuGet.exe'
diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml
index c84ac55ebf8e42..4f79cf0f33703f 100644
--- a/eng/common/templates/post-build/post-build.yml
+++ b/eng/common/templates/post-build/post-build.yml
@@ -117,6 +117,7 @@ stages:
pipeline: $(AzDOPipelineId)
buildId: $(AzDOBuildId)
artifactName: PackageArtifacts
+ checkDownloadedFiles: true
- task: PowerShell@2
displayName: Validate
@@ -149,6 +150,7 @@ stages:
pipeline: $(AzDOPipelineId)
buildId: $(AzDOBuildId)
artifactName: PackageArtifacts
+ checkDownloadedFiles: true
itemPattern: |
**
!**/Microsoft.SourceBuild.Intermediate.*.nupkg
@@ -205,6 +207,7 @@ stages:
pipeline: $(AzDOPipelineId)
buildId: $(AzDOBuildId)
artifactName: BlobArtifacts
+ checkDownloadedFiles: true
- task: PowerShell@2
displayName: Validate
diff --git a/eng/common/templates/post-build/setup-maestro-vars.yml b/eng/common/templates/post-build/setup-maestro-vars.yml
index d0cbfb6c6ffddf..4a22b2e6f6de79 100644
--- a/eng/common/templates/post-build/setup-maestro-vars.yml
+++ b/eng/common/templates/post-build/setup-maestro-vars.yml
@@ -18,6 +18,7 @@ jobs:
inputs:
buildType: current
artifactName: ReleaseConfigs
+ checkDownloadedFiles: true
- task: PowerShell@2
name: setReleaseVars
diff --git a/eng/common/templates/steps/perf-send-to-helix.yml b/eng/common/templates/steps/perf-send-to-helix.yml
index 3427b311a72836..0fb786fabf7e35 100644
--- a/eng/common/templates/steps/perf-send-to-helix.yml
+++ b/eng/common/templates/steps/perf-send-to-helix.yml
@@ -29,7 +29,7 @@ steps:
sendParams: $(Build.SourcesDirectory)/eng/common/performance/${{ parameters.ProjectFile }} /restore /t:Test /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
displayName: ${{ parameters.DisplayNamePrefix }}
condition: ${{ parameters.condition }}
- continueOnError: ${{ parameters.continueOnError }}
+ shouldContinueOnError: ${{ parameters.continueOnError }}
environment:
BuildConfig: $(_BuildConfig)
HelixSource: ${{ parameters.HelixSource }}
diff --git a/global.json b/global.json
index 3e24a5950e6650..b3930c66623804 100644
--- a/global.json
+++ b/global.json
@@ -12,12 +12,12 @@
"python3": "3.7.1"
},
"msbuild-sdks": {
- "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.21155.1",
- "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21155.1",
- "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21155.1",
- "Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.21155.1",
+ "Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk": "6.0.0-beta.21165.1",
+ "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21165.1",
+ "Microsoft.DotNet.Helix.Sdk": "6.0.0-beta.21165.1",
+ "Microsoft.DotNet.SharedFramework.Sdk": "6.0.0-beta.21165.1",
"Microsoft.Build.NoTargets": "2.0.17",
"Microsoft.Build.Traversal": "2.1.1",
- "Microsoft.NET.Sdk.IL": "6.0.0-preview.3.21157.6"
+ "Microsoft.NET.Sdk.IL": "6.0.0-preview.3.21164.8"
}
}
diff --git a/src/libraries/System.Text.Json/src/System.Text.Json.csproj b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
index ed010eff3ce5aa..cb91cbdfdb4efb 100644
--- a/src/libraries/System.Text.Json/src/System.Text.Json.csproj
+++ b/src/libraries/System.Text.Json/src/System.Text.Json.csproj
@@ -227,6 +227,7 @@
+
@@ -254,6 +255,9 @@
+
+
+
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverterFactory.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverterFactory.cs
index cc67a34eb392e1..8e353bd5f3edca 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverterFactory.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverterFactory.cs
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Reflection;
+using System.Diagnostics.CodeAnalysis;
namespace System.Text.Json.Serialization.Converters
{
@@ -16,16 +16,27 @@ public override bool CanConvert(Type type)
return type.IsEnum;
}
- public override JsonConverter CreateConverter(Type type, JsonSerializerOptions options)
+ public override JsonConverter CreateConverter(Type type, JsonSerializerOptions options) =>
+ Create(type, EnumConverterOptions.AllowNumbers, options);
+
+ internal static JsonConverter Create(Type enumType, EnumConverterOptions converterOptions, JsonSerializerOptions serializerOptions)
{
- JsonConverter converter = (JsonConverter)Activator.CreateInstance(
- typeof(EnumConverter<>).MakeGenericType(type),
- BindingFlags.Instance | BindingFlags.Public,
- binder: null,
- new object[] { EnumConverterOptions.AllowNumbers, options },
- culture: null)!;
+ return (JsonConverter)Activator.CreateInstance(
+ GetEnumConverterType(enumType),
+ new object[] { converterOptions, serializerOptions })!;
+ }
- return converter;
+ internal static JsonConverter Create(Type enumType, EnumConverterOptions converterOptions, JsonNamingPolicy? namingPolicy, JsonSerializerOptions serializerOptions)
+ {
+ return (JsonConverter)Activator.CreateInstance(
+ GetEnumConverterType(enumType),
+ new object?[] { converterOptions, namingPolicy, serializerOptions })!;
}
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:MakeGenericType",
+ Justification = "'where T : struct' implies 'T : new()', so the trimmer is warning calling MakeGenericType here because enumType's constructors are not annotated. " +
+ "But EnumConverter doesn't call new T(), so this is safe.")]
+ [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
+ private static Type GetEnumConverterType(Type enumType) => typeof(EnumConverter<>).MakeGenericType(enumType);
}
}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverterFactory.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverterFactory.cs
index dfab566a636a8e..4754c7bebfaba8 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverterFactory.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/NullableConverterFactory.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Reflection;
namespace System.Text.Json.Serialization.Converters
@@ -34,11 +35,17 @@ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializer
public static JsonConverter CreateValueConverter(Type valueTypeToConvert, JsonConverter valueConverter)
{
return (JsonConverter)Activator.CreateInstance(
- typeof(NullableConverter<>).MakeGenericType(valueTypeToConvert),
+ GetNullableConverterType(valueTypeToConvert),
BindingFlags.Instance | BindingFlags.Public,
binder: null,
args: new object[] { valueConverter },
culture: null)!;
}
+
+ [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2055:MakeGenericType",
+ Justification = "'where T : struct' implies 'T : new()', so the trimmer is warning calling MakeGenericType here because valueTypeToConvert's constructors are not annotated. " +
+ "But NullableConverter doesn't call new T(), so this is safe.")]
+ [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
+ private static Type GetNullableConverterType(Type valueTypeToConvert) => typeof(NullableConverter<>).MakeGenericType(valueTypeToConvert);
}
}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
index cbe8e8f72d1899..e442176093ded0 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs
@@ -96,12 +96,7 @@ internal JsonConverter GetDictionaryKeyConverter(Type keyType)
// Use factory pattern to generate an EnumConverter with AllowStrings and AllowNumbers options for dictionary keys.
// There will be one converter created for each enum type.
JsonConverter GetEnumConverter()
- => (JsonConverter)Activator.CreateInstance(
- typeof(EnumConverter<>).MakeGenericType(keyType),
- BindingFlags.Instance | BindingFlags.Public,
- binder: null,
- new object[] { EnumConverterOptions.AllowStrings | EnumConverterOptions.AllowNumbers, this },
- culture: null)!;
+ => EnumConverterFactory.Create(keyType, EnumConverterOptions.AllowStrings | EnumConverterOptions.AllowNumbers, this);
}
private ConcurrentDictionary? _dictionaryKeyConverters;
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumConverter.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumConverter.cs
index 65ac02718fb536..ac6fe18b9dbda9 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumConverter.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonStringEnumConverter.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Reflection;
using System.Text.Json.Serialization.Converters;
namespace System.Text.Json.Serialization
@@ -52,16 +51,7 @@ public override bool CanConvert(Type typeToConvert)
}
///
- public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
- {
- JsonConverter converter = (JsonConverter)Activator.CreateInstance(
- typeof(EnumConverter<>).MakeGenericType(typeToConvert),
- BindingFlags.Instance | BindingFlags.Public,
- binder: null,
- new object?[] { _converterOptions, _namingPolicy, options },
- culture: null)!;
-
- return converter;
- }
+ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
+ EnumConverterFactory.Create(typeToConvert, _converterOptions, _namingPolicy, options);
}
}