Skip to content

[Breaking change]: Nullable annotation corrected for System.Net.HttpListenerRequest.UserAgent #37900

Closed
@ManickaP

Description

@ManickaP

Description

ystem.Net.HttpListenerRequest has 1 property that were previously annotated as being non-nullable, but they were indeed nullable in practice. The nullable annotations for these properties have been updated to indicate that they are nullable. This can result in new build warnings related to use of nullable members.

.NET 9.0 alpha
It's in the main branch of current https://github.com/dotnet/runtime, not yet released.

Version

Other (please put exact version in description textbox)

Previous behavior

The properties were previously annotated as not being nullable. Consuming their values and assuming they could not be null would not produce any warnings during build.

New behavior

The properties are now annotated as being nullable. Consuming the values without null checks will result in build warnings.

Type of breaking change

  • Binary incompatible: Existing binaries may 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 may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

As was reported and fixed in dotnet/runtime#78287, the annotations of these properties were incorrect. This change applies the appropriate behavior for the properties and ensures callers understand the values can be null.

Recommended action

Update calling code to guard against null for these properties.

Feature area

Core .NET libraries

Affected APIs


Associated WorkItem - 196552

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 9Work items for the .NET 9 release📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking changesource incompatibleSource code may encounter a breaking change in behavior when targeting the new version.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions