Skip to content

Commit e0a0955

Browse files
authored
Add an Experimental APIs overview page (#43119)
1 parent 3becc8a commit e0a0955

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

docs/core/whats-new/dotnet-9/libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ The following codes shows some of the APIs included with the new `Tensor<T>` typ
742742
:::code language="csharp" source="../snippets/dotnet-9/csharp/Tensors.cs" id="Tensor":::
743743

744744
> [!NOTE]
745-
> This API is marked as [experimental](../../../fundamentals/apicompat/preview-apis.md#experimentalattribute) for .NET 9.
745+
> This API is marked as [experimental](../../../fundamentals/syslib-diagnostics/experimental-overview.md) for .NET 9.
746746
747747
### TensorPrimitives
748748

docs/fundamentals/apicompat/preview-apis.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ When building against an experimental API, the compiler will produce an error. E
5454

5555
Since each experimental feature has a separate ID, consenting to using one experimental feature doesn't consent to using another.
5656

57+
For more information, see [Experimental features][experimental-overview].
58+
5759
## Choose between the options
5860

5961
Library developers should only use prerelease NuGet packages or mark APIs with `[Experimental]`:
@@ -67,3 +69,4 @@ The `[RequiresPreviewFeatures]` attribute is only meant for components of the .N
6769
The exception to this rule is if you're building a stable library and want to expose certain features that in turn depend on runtime or language preview behaviors. In that case you should use `[RequiresPreviewFeatures]` for the entry points of that feature. However, you need to consider that users of such APIs have to turn on preview features too, which exposes them to all runtime, library, and language preview behaviors.
6870

6971
[choosing-diagnostic-ids]: ../../csharp/roslyn-sdk/choosing-diagnostic-ids.md
72+
[experimental-overview]: ../syslib-diagnostics/experimental-overview.md
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Experimental features in .NET 9+
3+
titleSuffix: ""
4+
description: Learn about APIs that are marked as experimental in .NET 9 and later versions that produce SYSLIB compiler warnings.
5+
ms.date: 10/21/2024
6+
---
7+
8+
# Experimental features in .NET 9+
9+
10+
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.
11+
12+
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).
13+
14+
Since each experimental feature has a separate ID, consenting to using one experimental feature doesn't consent to using another.
15+
16+
## Reference
17+
18+
The following table provides an index to the `SYSLIB5XXX` experimental APIs in .NET 9+.
19+
20+
| Diagnostic ID | Experimental version | Description |
21+
| - | - | - |
22+
| SYSLIB5001 | .NET 9 | <xref:System.Numerics.Tensors.Tensor%601> and related APIs in <xref:System.Numerics.Tensors> are experimental |
23+
| SYSLIB5002 | .NET 9 | <xref:System.Drawing.SystemColors> alternate colors are experimental |
24+
| SYSLIB5003 | .NET 9 | <xref:System.Runtime.Intrinsics.Arm.Sve> is experimental |
25+
| 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` |
26+
| SYSLIB5005 | .NET 9 | <xref:System.Formats.Nrbf> is experimental |
27+
28+
## Suppress warnings
29+
30+
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.
31+
32+
To suppress the warnings in a project file:
33+
34+
```xml
35+
<Project Sdk="Microsoft.NET.Sdk">
36+
<PropertyGroup>
37+
<TargetFramework>net9.0</TargetFramework>
38+
<!-- NoWarn below suppresses SYSLIB5001 project-wide -->
39+
<NoWarn>$(NoWarn);SYSLIB5001</NoWarn>
40+
<!-- To suppress multiple warnings, you can use multiple NoWarn elements -->
41+
<NoWarn>$(NoWarn);SYSLIB5002</NoWarn>
42+
<NoWarn>$(NoWarn);SYSLIB5003</NoWarn>
43+
<!-- Alternatively, you can suppress multiple warnings by using a semicolon-delimited list -->
44+
<NoWarn>$(NoWarn);SYSLIB5001;SYSLIB5002;SYSLIB5003</NoWarn>
45+
</PropertyGroup>
46+
</Project>
47+
```
48+
49+
To suppress the warnings in code:
50+
51+
```csharp
52+
// Disable the warning.
53+
#pragma warning disable SYSLIB5001
54+
55+
// Code that uses an experimental API that produces the diagnostic SYSLIB5001
56+
//...
57+
58+
// Re-enable the warning.
59+
#pragma warning restore SYSLIB5001
60+
```
61+
62+
## See also
63+
64+
- [Preview APIs](../apicompat/preview-apis.md)

docs/navigate/tools-diagnostics/toc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,6 +1800,11 @@ items:
18001800
href: ../../fundamentals/syslib-diagnostics/syslib0056.md
18011801
- name: SYSLIB0057
18021802
href: ../../fundamentals/syslib-diagnostics/syslib0057.md
1803+
- name: Experimental features
1804+
items:
1805+
- name: Overview
1806+
displayName: syslib, experimental
1807+
href: ../../fundamentals/syslib-diagnostics/experimental-overview.md
18031808
- name: Source-generated code
18041809
items:
18051810
- name: Overview

0 commit comments

Comments
 (0)