[Breaking Change] MinimumOSPlatformAttribute and RemovedInOSPlatformAttribute renamed, ObsoletedInOSPlatformAttribute removed #20635
Labels
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 5
Work items for the .NET 5 release
MinimumOSPlatformAttribute and RemovedInOSPlatformAttribute renamed, ObsoletedInOSPlatformAttribute removed
MinimumOSPlatformAttribute
was renamed toSupportedOSPlatformAttribute
;RemovedInOSPlatformAttribute
was renamed toUnsupportedOSPlatformAttribute
; andObsoletedInOSPlatformAttribute
was removed.These changes can introduce build-time or runtime errors for projects when retargeting from .NET 5.0 Preview 8 to .NET 5.0 RC1. The rename of
MinimumOSPlatformAttribute
is most likely to produce build-time or runtime errors in projects because the attribute is applied to platform-specific assemblies at build-time and old build artifacts will still reference the old API name.Example build-time errors:
Example runtime error:
These errors are likely to be introduced for projects targeting OS specific flavors of .NET 5 through target framework monikers such as
net5.0-windows
. To resolve either error, the project must be rebuilt (clean + build) after retargeting to .NET 5.0 RC1.Version introduced
.NET 5.0 RC1
Old behavior
In .NET 5.0 Preview 8, the following attributes existed within
System.Runtime.Versioning
:MinimumOSPlatformAttribute
RemovedInOSPlatformAttribute
ObsoletedInOSPlatformAttribute
In .NET 5.0 Preview 8, when a project was targeting an OS specific flavor of .NET 5 through a target framework moniker such as
net5.0-windows
, the build would produce an assembly-level attribute usingSystem.Runtime.Versioning.MinimumOSPlatformAttribute
.New behavior
In .NET 5.0 RC1, the following changes were made to the attributes:
MinimumOSPlatformAttribute
was renamed toSupportedOSPlatformAttribute
RemovedInOSPlatformAttribute
was renamed toUnsupportedOSPlatformAttribute
ObsoletedInOSPlatformAttribute
was removedIn .NET 5.0 RC1, when a project was targeting an OS specific flavor of .NET 5 through a target framework moniker such as
net5.0-windows
, the build will produce an assembly-level attribute usingSystem.Runtime.Versioning.SupportedOSPlatformAttribute
.Reason for change
.NET 5.0 Preview 8 introduced attributes in
System.Runtime.Versioning
with the purpose of performing platform checks for APIs that only work on specified platforms. The attributes are consumed by the Platform Compatibility Analyzer to produce build warnings when consuming platform-specific APIs on platforms those APIs don't support.During .NET 5.0 RC1, an additional feature was added to the Platform Compatibility Analyzer for platform exclusion, allowing APIs to be marked as entirely unsupported on OS platforms. That feature prompted changes to the attributes, using API names more suitable for scenarios.
The following API changes were made in
System.Runtime.Versioning
to support this new feature:MinimumOSPlatformAttribute
renamed toSupportedOSPlatformAttribute
, to support platform-specific API annotationsRemovedInOSPlatformAttribute
renamed toUnsupportedOSPlatformAttribute
, to support platform exclusion annotationsObsoletedInOSPlatformAttribute
was removed, as this annotation is not needed at this timeRecommended action
MinimumOSPlatformAttribute
toSupportedOSPlatformAttribute
RemovedInOSPlatformAttribute
toUnsupportedOSPlatformAttribute
ObsoletedInOSPlatformAttribute
Category
Affected APIs
MinimumOSPlatformAttribute
RemovedInOSPlatformAttribute
ObsoletedInOSPlatformAttribute
Issue metadata
The text was updated successfully, but these errors were encountered: