Skip to content

Commit

Permalink
Update to net9.0 (#75465)
Browse files Browse the repository at this point in the history
* Update to net9.0

* Fixup code

* Remove unused references

* Fix MSBuild.UnitTests

* Update checklist
  • Loading branch information
jjonescz authored Oct 14, 2024
1 parent b1567b7 commit daf100b
Show file tree
Hide file tree
Showing 34 changed files with 59 additions and 51 deletions.
12 changes: 6 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/net7.0/BuildValidator.dll",
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/net9.0/BuildValidator.dll",
"args": [
"--assembliesPath", "./artifacts/obj/csc/Debug/net6.0",
"--assembliesPath", "./artifacts/obj/csc/Debug/net9.0",
"--referencesPath", "./artifacts/bin",
"--referencesPath", "C:/Program Files/dotnet/packs/Microsoft.AspNetCore.App.Ref",
"--referencesPath", "C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref",
Expand All @@ -29,7 +29,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/RunTests/Debug/net7.0/RunTests.dll",
"program": "${workspaceFolder}/artifacts/bin/RunTests/Debug/net9.0/RunTests.dll",
"args": ["--runtime", "both", "--artifactspath", "${workspaceFolder}/artifacts/testPayload/artifacts"],
"cwd": "${workspaceFolder}/artifacts/bin/RunTests",
"stopAtEntry": false,
Expand All @@ -41,7 +41,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/PrepareTests/Debug/net7.0/PrepareTests.dll",
"program": "${workspaceFolder}/artifacts/bin/PrepareTests/Debug/net9.0/PrepareTests.dll",
"args": [
"--source", "${workspaceFolder}",
"--destination", "${workspaceFolder}/artifacts/testPayload"
Expand All @@ -56,7 +56,7 @@
"request": "launch",
"preLaunchTask": "build current project",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/Replay/Debug/net8.0/Replay.dll",
"program": "${workspaceFolder}/artifacts/bin/Replay/Debug/net9.0/Replay.dll",
"args": [],
"cwd": "${workspaceFolder}/artifacts/bin/Replay",
"stopAtEntry": false,
Expand All @@ -68,7 +68,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/csc/Debug/net6.0/csc.dll",
"program": "${workspaceFolder}/artifacts/bin/csc/Debug/net9.0/csc.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Compilers/CSharp/csc",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
Expand Down
9 changes: 9 additions & 0 deletions docs/contributing/Target Framework Strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,12 @@ When the .NET SDK RTMs and Roslyn adopts it all occurrences of `$(NetRoslynNext)

**DO NOT** include both `$(NetRoslyn)` and `$(NetRoslynNext)` in the same project unless there is a very specific reason that both tests are adding value. The most common case is that the runtime has changed behavior and we simply need to update our baselines to match it. Adding extra TFMs for this just increases test time for very little gain.

## Checklist for updating TFMs (once a year)

- Update `TargetFrameworks.props`.
- Ensure we have the correct TFM for VS / VSCode (usually not the latest TFM).
- Might need updating `MicrosoftNetCompilersToolsetVersion` in `eng\Versions.props` to consume latest compiler features.
- Change `$(NetRoslynNext)` references to `$(NetRoslyn)` in project files.
- Update TFMs in code/scripts/pipelines (search for the old `netX.0` and replace with the new `netY.0`).
- Check that the same number of tests still run in CI (they are not unintentionally filtered out by TFM).
- Try an official build, a VS insertion.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<MicrosoftExtensionsOptionsConfigurationExtensionVersion>8.0.0</MicrosoftExtensionsOptionsConfigurationExtensionVersion>
<MicrosoftExtensionsOptionsVersion>8.0.0</MicrosoftExtensionsOptionsVersion>
<MicrosoftExtensionsPrimitivesVersion>8.0.0</MicrosoftExtensionsPrimitivesVersion>
<MicrosoftNetCompilersToolsetVersion>4.11.0-2.24270.4</MicrosoftNetCompilersToolsetVersion>
<MicrosoftNetCompilersToolsetVersion>4.12.0-3.24473.3</MicrosoftNetCompilersToolsetVersion>
<MicrosoftVSSDKBuildToolsVersion>17.9.3137-preview3</MicrosoftVSSDKBuildToolsVersion>
<vswhereVersion>2.4.1</vswhereVersion>
<!--
Expand Down
4 changes: 2 additions & 2 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ function TestUsingRunTests() {
$env:ROSLYN_TEST_USEDASSEMBLIES = "true"
}

$runTests = GetProjectOutputBinary "RunTests.dll" -tfm "net8.0"
$runTests = GetProjectOutputBinary "RunTests.dll" -tfm "net9.0"

if (!(Test-Path $runTests)) {
Write-Host "Test runner not found: '$runTests'. Run Build.cmd first." -ForegroundColor Red
Expand Down Expand Up @@ -546,7 +546,7 @@ function EnablePreviewSdks() {
# deploying at build time.
function Deploy-VsixViaTool() {

$vsixExe = Join-Path $ArtifactsDir "bin\RunTests\$configuration\net8.0\VSIXExpInstaller\VSIXExpInstaller.exe"
$vsixExe = Join-Path $ArtifactsDir "bin\RunTests\$configuration\net9.0\VSIXExpInstaller\VSIXExpInstaller.exe"
Write-Host "VSIX EXE path: " $vsixExe
if (-not (Test-Path $vsixExe)) {
Write-Host "VSIX EXE not found: '$vsixExe'." -ForegroundColor Red
Expand Down
2 changes: 1 addition & 1 deletion eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,6 @@ if [[ "$test_core_clr" == true ]]; then
if [[ "$ci" != true ]]; then
runtests_args="$runtests_args --html"
fi
dotnet exec "$scriptroot/../artifacts/bin/RunTests/${configuration}/net8.0/RunTests.dll" --runtime core --configuration ${configuration} --logs ${log_dir} --dotnet ${_InitializeDotNetCli}/dotnet $runtests_args
dotnet exec "$scriptroot/../artifacts/bin/RunTests/${configuration}/net9.0/RunTests.dll" --runtime core --configuration ${configuration} --logs ${log_dir} --dotnet ${_InitializeDotNetCli}/dotnet $runtests_args
fi
ExitWithExitCode 0
6 changes: 3 additions & 3 deletions eng/generate-compiler-code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Run-LanguageCore($language, $languageSuffix, $languageDir, $syntaxProje
$errorFileName = if ($language -eq "CSharp") { "ErrorCode.cs" } else { "Errors.vb" }
$errorFilePath = Join-Path $languageDir "Errors\$errorFileName"
$errorGeneratedFilePath = Join-Path $generatedDir "ErrorFacts.Generated.$($languageSuffix)"
$targetFramework = "net8.0"
$targetFramework = "net9.0"

Create-Directory $generatedDir
Create-Directory $generatedTestDir
Expand Down Expand Up @@ -75,7 +75,7 @@ function Run-IOperation($coreDir, $ioperationProject) {
$operationsDir = Join-Path $coreDir "Operations"
$operationsXml = Join-Path $operationsDir "OperationInterfaces.xml"
$generationDir = Join-Path $coreDir "Generated"
$targetFramework = "net8.0"
$targetFramework = "net9.0"

if (-not $test) {
Run-Tool $ioperationProject "`"$operationsXml`" `"$generationDir`"" $targetFramework
Expand All @@ -92,7 +92,7 @@ function Run-GetTextCore($generatedDir) {
$syntaxTextFilePath = Join-Path $generatedDir "Syntax.xml.GetText.Generated.vb"

Create-Directory $generatedDir
Run-Tool $basicSyntaxProject "`"$syntaxFilePath`" `"$syntaxTextFilePath`" /gettext" "net8.0"
Run-Tool $basicSyntaxProject "`"$syntaxFilePath`" `"$syntaxTextFilePath`" /gettext" "net9.0"
}

function Run-GetText() {
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/test-integration-helix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ stages:
- task: BatchScript@1
displayName: Rehydrate RunTests
inputs:
filename: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net8.0/rehydrate.cmd
filename: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net9.0/rehydrate.cmd
env:
HELIX_CORRELATION_PAYLOAD: '$(Build.SourcesDirectory)\.duplicate'

Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/test-unix-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- task: ShellScript@2
displayName: Rehydrate RunTests
inputs:
scriptPath: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net8.0/rehydrate.sh
scriptPath: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net9.0/rehydrate.sh
env:
HELIX_CORRELATION_PAYLOAD: '$(Build.SourcesDirectory)/.duplicate'

Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/test-windows-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- task: BatchScript@1
displayName: Rehydrate RunTests
inputs:
filename: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net8.0/rehydrate.cmd
filename: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net9.0/rehydrate.cmd
env:
HELIX_CORRELATION_PAYLOAD: '$(Build.SourcesDirectory)\.duplicate'

Expand Down
2 changes: 1 addition & 1 deletion eng/prepare-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ try {
# permissions issues make this a pain to do in PrepareTests itself.
Remove-Item -Recurse -Force "$RepoRoot\artifacts\testPayload" -ErrorAction SilentlyContinue
$dotnet = Ensure-DotNetSdk
Exec-Command $dotnet "exec $RepoRoot\artifacts\bin\PrepareTests\$configuration\net8.0\PrepareTests.dll --source $RepoRoot --destination $RepoRoot\artifacts\testPayload --dotnetPath `"$dotnet`""
Exec-Command $dotnet "exec $RepoRoot\artifacts\bin\PrepareTests\$configuration\net9.0\PrepareTests.dll --source $RepoRoot --destination $RepoRoot\artifacts\testPayload --dotnetPath `"$dotnet`""
exit 0
}
catch {
Expand Down
2 changes: 1 addition & 1 deletion eng/prepare-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ InitializeDotNetCli true
# permissions issues make this a pain to do in PrepareTests itself.
rm -rf "$repo_root/artifacts/testPayload"

dotnet "$repo_root/artifacts/bin/PrepareTests/Debug/net8.0/PrepareTests.dll" --source "$repo_root" --destination "$repo_root/artifacts/testPayload" --unix --dotnetPath ${_InitializeDotNetCli}/dotnet
dotnet "$repo_root/artifacts/bin/PrepareTests/Debug/net9.0/PrepareTests.dll" --source "$repo_root" --destination "$repo_root/artifacts/testPayload" --unix --dotnetPath ${_InitializeDotNetCli}/dotnet
11 changes: 5 additions & 6 deletions eng/targets/TargetFrameworks.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<!--
This props file manages the target framework properties for Roslyn. The strategy for these properties
is convered in "docs/contributing/Target Framework Strategy.md". Please see that for documentation
is covered in "docs/contributing/Target Framework Strategy.md". Please see that for documentation
on what these values mean.
Requirements:
Expand All @@ -12,11 +12,11 @@
- NetRoslynAll must include all .NET Core TFMS in any property below
-->
<PropertyGroup>
<NetRoslyn>net8.0</NetRoslyn>
<NetRoslynAll>net7.0;net8.0</NetRoslynAll>
<NetRoslyn>net9.0</NetRoslyn>
<NetRoslynAll>net8.0;net9.0</NetRoslynAll>
<NetVS>net8.0</NetVS>
<NetVSCode>net8.0</NetVSCode>
<NetVSShared>net7.0;net8.0</NetVSShared>
<NetVSShared>net8.0</NetVSShared>
<NetRoslynBuildHostNetCoreVersion>net6.0</NetRoslynBuildHostNetCoreVersion>
<NetRoslynNext>net9.0</NetRoslynNext>
</PropertyGroup>
Expand Down Expand Up @@ -67,8 +67,7 @@
-->
<Otherwise>
<PropertyGroup>
<NetRoslyn>net8.0</NetRoslyn>
<NetRoslynSourceBuild>net7.0;net8.0</NetRoslynSourceBuild>
<NetRoslynSourceBuild>$(NetRoslynAll)</NetRoslynSourceBuild>
</PropertyGroup>
</Otherwise>
</Choose>
Expand Down
4 changes: 2 additions & 2 deletions eng/test-rebuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ try {
# Rebuilds with missing references
# Rebuilds with other issues
" --exclude net472\Microsoft.CodeAnalysis.EditorFeatures2.UnitTests.dll" +
" --exclude net8.0\Microsoft.CodeAnalysis.Collections.Package.dll" +
" --exclude net9.0\Microsoft.CodeAnalysis.Collections.Package.dll" +
" --exclude netcoreapp3.1\Microsoft.CodeAnalysis.Collections.Package.dll" +
" --exclude netstandard2.0\Microsoft.CodeAnalysis.Collections.Package.dll" +
" --exclude netstandard2.0\Microsoft.CodeAnalysis.Debugging.Package.dll" +
Expand All @@ -67,7 +67,7 @@ try {

# Semantic Search reference assemblies can't be reconstructed from source.
# The assemblies are not marked with ReferenceAssemblyAttribute attribute.
" --exclude net8.0\GeneratedRefAssemblies\Microsoft.CodeAnalysis.dll" +
" --exclude net9.0\GeneratedRefAssemblies\Microsoft.CodeAnalysis.dll" +

" --debugPath `"$ArtifactsDir/BuildValidator`"" +
" --sourcePath `"$RepoRoot/`"" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Label="Project References">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Label="Project References">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Label="Project References">
Expand Down
1 change: 0 additions & 1 deletion src/Compilers/CSharp/csc/CscCommandLine.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Portable\Microsoft.CodeAnalysis.CSharp.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\Tools\ExternalAccess\RazorCompiler\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.csproj" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'net6.0'" />
</ItemGroup>
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.UnitTests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup Label="Linked Files">
<Compile Include="..\..\Shared\GlobalAssemblyCacheHelpers\FusionAssemblyIdentity.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\Tools\ExternalAccess\RazorCompiler\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.csproj" Condition="'$(TargetFramework)' == 'net472'" />

<Reference Include="System.Configuration" Condition="'$(TargetFramework)' == 'net472'" />

<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'net6.0'" />
</ItemGroup>
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
Expand Down
4 changes: 0 additions & 4 deletions src/Compilers/Test/Core/Compilation/RuntimeUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ internal static bool IsCoreClr8OrHigherRuntime
internal static bool IsCoreClr9OrHigherRuntime
=> CoreClrRuntimeVersion is { } v && v >= 9;

#if NET9_0_OR_GREATER
#error Make the above check be an #if NET9_OR_GREATER when we add net8 support to build
#endif

internal static BuildPaths CreateBuildPaths(string workingDirectory, string sdkDirectory = null, string tempDirectory = null)
{
tempDirectory ??= Path.GetTempPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<RootNamespace></RootNamespace>

<!-- Disabling on assumption -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<RootNamespace></RootNamespace>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<RootNamespace></RootNamespace>

<!-- A zillion test failures + crash. See https://github.com/mono/mono/issues/10756. -->
Expand Down
1 change: 0 additions & 1 deletion src/Compilers/VisualBasic/vbc/VbcCommandLine.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\Core\Portable\Microsoft.CodeAnalysis.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\Portable\Microsoft.CodeAnalysis.VisualBasic.vbproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)..\..\..\Tools\ExternalAccess\RazorCompiler\Microsoft.CodeAnalysis.ExternalAccess.RazorCompiler.csproj" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="$(SystemIOPipesAccessControlVersion)" Condition="'$(TargetFramework)' == 'net6.0'" />
</ItemGroup>
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>$(NetRoslynNext);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslyn);net472</TargetFrameworks>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ static Test()
// reasonable TLS protocol version for outgoing connections.
#pragma warning disable CA5364 // Do Not Use Deprecated Security Protocols
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete
if (ServicePointManager.SecurityProtocol == (SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls))
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CA5364 // Do Not Use Deprecated Security Protocols
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}
#pragma warning restore SYSLIB0014 // 'ServicePointManager' is obsolete
}

public Test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ static Test()
// reasonable TLS protocol version for outgoing connections.
#pragma warning disable CA5364 // Do Not Use Deprecated Security Protocols
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete
if (ServicePointManager.SecurityProtocol == (SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls))
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CA5364 // Do Not Use Deprecated Security Protocols
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}
#pragma warning restore SYSLIB0014 // 'ServicePointManager' is obsolete
}

public Test()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ static Test()
// reasonable TLS protocol version for outgoing connections.
#pragma warning disable CA5364 // Do Not Use Deprecated Security Protocols
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable SYSLIB0014 // 'ServicePointManager' is obsolete
if (ServicePointManager.SecurityProtocol == (SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls))
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CA5364 // Do Not Use Deprecated Security Protocols
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
}
#pragma warning restore SYSLIB0014 // 'ServicePointManager' is obsolete
}

public Test()
Expand Down
Loading

0 comments on commit daf100b

Please sign in to comment.