Skip to content

Changes to Nullable Reference Type Annotations in .NET 6.0 #21202

Closed
@jeffhandley

Description

@jeffhandley

Changes to Nullable Reference Type Annotations in .NET 6.0

This issue represents a work-in-progress. All changes to nullability annotations in the .NET Libraries will be aggregated into this issue throughout the course of .NET 6.0.

Starting in .NET Core 3.0, we have been applying nullability annotations to the .NET Libraries; .NET 5.0 reached 94% coverage across the APIs. From the outset of this effort, we anticipated that mistakes would be made in these annotations and fixes would need to be made. In .NET 6.0, we are updating some annotations that have been previously applied.

Some of these changes are considered breaking changes because they could lead to new build-time warnings--code referencing these APIs will need to be updated when migrating to .NET 6.0. Other changes that are not considered breaking are also documented here as referencing code may benefit from removing operators or pragmas that become unnecessary.

Old behavior

The affected APIs had incorrect nullable reference type annotations and build warnings were either absent or incorrect.

New behavior

New build warnings will be produced and incorrect build warnings will no longer be produced for the affected APIs.

Reason for change

Through feedback and further testing, the nullable annotations for the affected APIs were determined to be inaccurate. The updated annotations now correctly represent the nullability contracts for the APIs.

Recommended action

Update code calling these APIs to reflect the revised nullability contracts.

Category

  • Core .NET libraries

Affected APIs

(Unchecked items in the list have not yet been documented)

Version introduced: .NET 6.0 Preview 1

dotnet/runtime#42918 [Breaking]

dotnet/runtime#43717 [Non-Breaking]

dotnet/runtime#44880 [Non-Breaking]

dotnet/runtime#44844 [Non-Breaking]

dotnet/runtime#44938 [Breaking]

Version introduced: .NET 6.0 Preview 2

dotnet/runtime#47402 [Non-Breaking]

dotnet/runtime#47598 [Breaking]


Issue metadata

  • Issue type: breaking-change

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions