Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking change]: ServicePointManager is fully marked as obsolete #43144

Open
1 of 3 tasks
MihaZupan opened this issue Oct 21, 2024 · 0 comments
Open
1 of 3 tasks

[Breaking change]: ServicePointManager is fully marked as obsolete #43144

MihaZupan opened this issue Oct 21, 2024 · 0 comments
Assignees
Labels
breaking-change Indicates a .NET Core breaking change doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 source incompatible Source code may encounter a breaking change in behavior when targeting the new version. ⌚ Not Triaged Not triaged

Comments

@MihaZupan
Copy link
Member

MihaZupan commented Oct 21, 2024

Description

Introduced with .NET 9 preview 6 - dotnet/runtime#103456.

Version

.NET 9 Preview 6

Previous behavior

The affected APIs had, and continue to have, no effect on types like SslStream or HttpClient.
This wasn't fully communicated to the user with existing obsoletions.

New behavior

Source code using any of the obsoleted static members will issue a warning.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

In .NET 6, we've obsoleted WebRequest, WebClient, and ServicePoint (SYSLIB0014).
See https://learn.microsoft.com/en-us/dotnet/core/compatibility/networking/6.0/webrequest-deprecated

To reduce the number of warnings, we didn't always obsolete the types themselves, instead obsoleting just the methods/constructors used to obtain their instances. For example, instead of marking ServicePoint as obsolete, we've obsoleted ServicePointManager.FindServicePoint instead.

This failed to properly communicate to the user that they shouldn't be using ServicePointManager at all, as seen in issues like dotnet/dotnet-api-docs#6867 (ServicePointManager.ReusePort).

In .NET 9, we've expanded the use of the SYSLIB0014 obsoletion diagnostic to apply to the whole ServicePointManager type instead, and updated the documentation to note that settings on ServicePointManager no longer have any effect on SslStream or HttpClient.
This is not a change in behavior in .NET 9, they had no effect in previous versions of .NET (Core) either.

Recommended action

Use HttpClient and related APIs like settings on SocketsHttpHandler instead.

We've written a new guide that offers more help around how to migrate to these types: https://learn.microsoft.com/dotnet/fundamentals/networking/http/httpclient-migrate-from-httpwebrequest

Feature area

Networking

Affected APIs

The ServicePointManager type.
Note that some methods on the type were already marked as obsolete previously, and in .NET 9 we've expanded the obsoletion to the whole type instead. For example this means that properties like ServicePointManager.ReusePort would now show up as obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Indicates a .NET Core breaking change doc-idea Indicates issues that are suggestions for new topics [org][type][category] Pri1 High priority, do before Pri2 and Pri3 source incompatible Source code may encounter a breaking change in behavior when targeting the new version. ⌚ Not Triaged Not triaged
Projects
Status: 🔖 Ready
Development

No branches or pull requests

2 participants