Skip to content

[Proposal] [.NET 8] Use ExperimentalAttribute instead of ObsoleteAttribute to indicate alpha APIs. #1219

@philliphoff

Description

@philliphoff

Describe the proposal

Currently alpha APIs are decorated with the ObsoleteAttribute which causes the compiler to generate a warning/error when used. While the generated message is not entirely accurate, it does ensure users see and understand the risks of using a potentially unstable API.

.NET 6 introduced a new attribute, RequiresPreviewFeaturesAttribute, which serves a purpose similar to our use of ObsoleteAttribute. This generates a similar message (but from the Rosyln analyzer rather than the compiler itself), and requires a slightly different method to disable (via MSBuild property). The main disadvantage is disabling applies to all uses of such decorated APIs, rather than individual uses.

Still, RequiresPreviewFeaturesAttribute feels like a more appropriate way to indicate alpha APIs.

Another option is to create our own attribute and set of Roslyn analyzers that have our specific desired semantics; this could then be a start to additional work to help ensure best practices when using the SDK.

Update: .NET 8 introduces ExperimentalAttribute, which is even more closely aligned with our use case.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions