dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

[dotnet-sdk-9.0.100-rc.2.24470.13] DiscordChatExporter build with warning:‘ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. #43621

Closed Junjun-zhao closed 3 weeks ago

Junjun-zhao commented 1 month ago

Application Name: DiscordChatExporter OS: Windows 10 21H2 CPU: X64 .NET Build Number: dotnet-sdk-9.0.100-rc.2.24470.13 App & Source Checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2260224 Github Link: https://github.com/Tyrrrz/DiscordChatExporter

Verify Scenarios: 1). Windows 10 21H2 AMD64 + dotnet-sdk-8.0.300(default target net8.0): Pass 2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.6.24317.13(retarget net9.0): Pass 3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.6.24324.9(retarget net9.0): Fail 4). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-rc.2.24470.13(retarget net9.0): Fail

Description : When retarget the 3rd party application to net9.0 and build with the latest .NET 9 sdk, it failed with "warning as error": 'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)

Findings: We retarget the app to net9.0 and build with dotnet-sdk-9.0.100-preview.6.24324.9 and earlier versions, there is no warning. We found this warning is caused by ServicePointManager.DefaultConnectionLimit, but ServicePointManager.DefaultConnectionLimit is not defined as observer in this document. SYSLIB0014 warning - .NET | Microsoft Learn

Minimal Repro steps (Demo attached: ConsoleDemo.zip):

  1. Create a default8.0 console project.
  2. Add the following codes in Programs.cs.
    
    using System.Net;
    ServicePointManager.DefaultConnectionLimit = 20;
4. Retarget to net9.0.
5. Build with dotnet-sdk-9.0.100-rc.2.24470.13.

**Expected Result:**
Build successfully without warnings.

**Actual Result:**
There is a warning in error list: ```'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.'```

**Dotnet Info:**

.NET SDK: Version: 9.0.100-rc.2.24470.13 Commit: 3229e54b07 Workload version: 9.0.100-manifests.8fbc914b MSBuild version: 17.12.0-preview-24469-05+fea15fbd1

Runtime Environment: OS Name: Windows OS Version: 10.0.19045 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\9.0.100-rc.2.24470.13\

Host: Version: 9.0.0-rc.2.24463.7 Architecture: x64 Commit: static

.NET SDKs installed: 9.0.100-rc.2.24470.13 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 9.0.0-rc.2.24466.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 9.0.0-rc.2.24463.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 9.0.0-rc.2.24464.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]


@dotnet-actwx-bot @dotnet/compat
Junjun-zhao commented 1 month ago

@marcpopMSFT Could you please take look at this issue and triage this issue? Meanwhile, could you help confirm if this is a RC2 blocker. Thanks.

marcpopMSFT commented 1 month ago

@Junjun-zhao this is not an SDK issue nor is it likely a blocker since it's just a warning. @jaredpar @arkalyanms may know where to route this.

KalleOlaviNiemitalo commented 1 month ago

ServicePointManager was obsoleted in issue https://github.com/dotnet/runtime/issues/71836, PR https://github.com/dotnet/runtime/pull/103456 before v9.0.0-preview.6.24327.7; that still has the "new-api-needs-documentation" label. I suppose this should be added to the net9.0 breaking changes list and to the SYSLIB0014 documentation, and then the label should be removed.

Junjun-zhao commented 1 month ago

Thanks @KalleOlaviNiemitalo. I didn't find the breaking change doc about this issue. Could you please share the doc once it is filed?

FYI. This is the template for create a breaking change issue :https://github.com/dotnet/docs/issues/new?assignees=gewarren&labels=breaking-change%2CPri1%2Cdoc-idea&projects=&template=02-breaking-change.yml&title=%5BBreaking+change%5D%3A+

Junjun-zhao commented 1 month ago

@KalleOlaviNiemitalo Any update for the document for this issue?

MihaZupan commented 3 weeks ago

These types were already effectively obsolete since .NET 6. The change in .NET 9 moves the obsoletion to the whole type to make that more obvious for the couple of remaining static members that wouldn't have triggered warnings before.

I've tweaked the docs a bit (https://github.com/dotnet/docs/pull/43143) and filed a breaking change issue (https://github.com/dotnet/docs/issues/43144) to communicate that better.

Junjun-zhao commented 3 weeks ago

Thank you @MihaZupan. Closing this issue as "Update ServicePointManager obsoletion docs" PR and breaking change issue have been filed.