-
Notifications
You must be signed in to change notification settings - Fork 6k
Add an Experimental APIs overview page #43119
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
Merged
gewarren
merged 8 commits into
dotnet:main
from
jeffhandley:jeffhandley/experimental-apis
Oct 25, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e8d1da
Add an Experimental APIs overview page
jeffhandley a86d503
Update link for Tensor APIs to point to the new experimental APIs ove…
jeffhandley 71eb18d
Update DivRem xref
jeffhandley baa0e3e
Fix lint error and invalid links
jeffhandley 14f48f2
Apply feedback from review
jeffhandley 832d7df
Swap suppression sections
gewarren 0e0581e
Update docs/fundamentals/syslib-diagnostics/experimental-overview.md
gewarren e7f73d5
Add a link to Experimental features from Preview APIs
jeffhandley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
docs/fundamentals/syslib-diagnostics/experimental-overview.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: Experimental features in .NET 9+ | ||
titleSuffix: "" | ||
description: Learn about APIs that are marked as experimental in .NET 9 and later versions that produce SYSLIB compiler warnings. | ||
ms.date: 10/21/2024 | ||
--- | ||
|
||
# Experimental features in .NET 9+ | ||
|
||
Starting in .NET 9, some features make use of the <xref:System.Diagnostics.CodeAnalysis.ExperimentalAttribute> to indicate that the API shape or functionality is included in the release but not yet officially supported. Experimental features let the .NET team collect feedback on an API's shape and functionality with the intent of refining the API and removing the `[Experimental]` attribute in the next major release. | ||
|
||
When your code references an experimental API, the compiler produces an error with an ID like `SYSLIB5XXX`. Each feature that's marked as experimental has a unique diagnostic ID. To express consent to using an experimental feature, you suppress the specific diagnostic. You can do that via any of the means for suppressing diagnostics, but the recommended way is to add the diagnostic to the project's `<NoWarn>` property. For more information, see [Suppress warnings](#suppress-warnings). | ||
|
||
Since each experimental feature has a separate ID, consenting to using one experimental feature doesn't consent to using another. | ||
|
||
## Reference | ||
|
||
The following table provides an index to the `SYSLIB5XXX` experimental APIs in .NET 9+. | ||
|
||
| Diagnostic ID | Experimental version | Description | | ||
| - | - | - | | ||
| SYSLIB5001 | .NET 9 | <xref:System.Numerics.Tensors.Tensor%601> and related APIs in <xref:System.Numerics.Tensors> are experimental | | ||
| SYSLIB5002 | .NET 9 | <xref:System.Drawing.SystemColors> alternate colors are experimental | | ||
| SYSLIB5003 | .NET 9 | <xref:System.Runtime.Intrinsics.Arm.Sve> is experimental | | ||
| SYSLIB5004 | .NET 9 | <xref:System.Runtime.Intrinsics.X86.X86Base.DivRem(System.UInt32,System.Int32,System.Int32)> is experimental since performance is not as optimized as `T.DivRem` | | ||
| SYSLIB5005 | .NET 9 | <xref:System.Formats.Nrbf> is experimental | | ||
|
||
## Suppress warnings | ||
|
||
Using an experimental feature gives you the opportunity to submit feedback on the API shape and functionality before the feature is marked as stable and fully supported. But using the feature produces a warning from the compiler. When you suppress the warning, you acknowledge that the API shape or functionality might change in the next major release. The API might even be removed. You can suppress the warning through a `<NoWarn>` project setting (recommended) or a `#pragma` directive in code. | ||
|
||
To suppress the warnings in a project file: | ||
|
||
```xml | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<!-- NoWarn below suppresses SYSLIB5001 project-wide --> | ||
<NoWarn>$(NoWarn);SYSLIB5001</NoWarn> | ||
<!-- To suppress multiple warnings, you can use multiple NoWarn elements --> | ||
<NoWarn>$(NoWarn);SYSLIB5002</NoWarn> | ||
<NoWarn>$(NoWarn);SYSLIB5003</NoWarn> | ||
<!-- Alternatively, you can suppress multiple warnings by using a semicolon-delimited list --> | ||
<NoWarn>$(NoWarn);SYSLIB5001;SYSLIB5002;SYSLIB5003</NoWarn> | ||
</PropertyGroup> | ||
</Project> | ||
``` | ||
|
||
To suppress the warnings in code: | ||
|
||
```csharp | ||
// Disable the warning. | ||
#pragma warning disable SYSLIB5001 | ||
|
||
// Code that uses an experimental API that produces the diagnostic SYSLIB5001 | ||
//... | ||
|
||
// Re-enable the warning. | ||
#pragma warning restore SYSLIB5001 | ||
``` | ||
|
||
## See also | ||
|
||
- [Preview APIs](../apicompat/preview-apis.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.