Skip to content

Commit b08181b

Browse files
authored
Mark the System.Formats.Nrbf assembly as [Experimental] with SYSLIB5005 (#107905)
1 parent 8ae3796 commit b08181b

File tree

11 files changed

+43
-8
lines changed

11 files changed

+43
-8
lines changed

docs/project/list-of-diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,4 @@ Diagnostic id values for experimental APIs must not be recycled, as that could s
310310
| __`SYSLIB5002`__ | .NET 9 | TBD | `SystemColors` alternate colors are experimental in .NET 9 |
311311
| __`SYSLIB5003`__ | .NET 9 | TBD | `System.Runtime.Intrinsics.Arm.Sve` is experimental in .NET 9 |
312312
| __`SYSLIB5004`__ | .NET 9 | TBD | `X86Base.DivRem` is experimental in .NET 9 since performance is not as optimized as `T.DivRem` |
313+
| __`SYSLIB5005`__ | .NET 9 | TBD | `System.Formats.Nrbf` is experimental in .NET 9 |

src/libraries/Common/src/System/Experimentals.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ internal static class Experimentals
2828
// X86Base.DivRem is experimental in .NET 9 since performance is not as optimized as T.DivRem
2929
internal const string X86BaseDivRemDiagId = "SYSLIB5004";
3030

31+
// System.Formats.Nrbf is experimental in .NET 9
32+
internal const string NrbfDecoderDiagId = "SYSLIB5005";
33+
3134
// When adding a new diagnostic ID, add it to the table in docs\project\list-of-diagnostics.md as well.
3235
// Keep new const identifiers above this comment.
3336
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
[assembly: System.Diagnostics.CodeAnalysis.ExperimentalAttribute("SYSLIB5005", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]

src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
<ProjectReference Include="$(LibrariesProjectRoot)System.Reflection.Metadata\ref\System.Reflection.Metadata.csproj" />
1313
</ItemGroup>
1414

15+
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
16+
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\ExperimentalAttribute.cs"
17+
Link="Common\ExperimentalAttribute.cs" />
18+
</ItemGroup>
19+
1520
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
1621
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\RequiresDynamicCodeAttribute.cs" />
1722
<PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
7+
[assembly: Experimental(Experimentals.NrbfDecoderDiagId, UrlFormat = Experimentals.SharedUrlFormat)]

src/libraries/System.Formats.Nrbf/src/PACKAGE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
You can think of [NrbfDecoder](https://learn.microsoft.com/en-us/dotnet/api/system.formats.nrbf.nrbfdecoder) as being the equivalent of using a JSON/XML reader without the deserializer.
88

9+
**Note:** The 9.0.0 release of the `System.Formats.Nrbf` package is marked `[Experimental]` as the API shape is subject to change in the next major release. Even with the experimental annotation, the package is officially supported. Using the APIs from this package will produce a build warning with diagnostic ID `SYSLIB5005`. The diagnostic can be suppressed with the acknowledgement that the API shape is subject to change in the next major release.
10+
911
## How to Use
1012

1113
The NRBF payload consists of serialization records that represent the serialized objects and their metadata. To read the whole payload and get the root record, you need to call one of the [NrbfDecoder.Decode](https://learn.microsoft.com/dotnet/api/system.formats.nrbf.nrbfdecoder.decode) methods.

src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
<EnableDefaultItems>true</EnableDefaultItems>
66
<CLSCompliant>false</CLSCompliant>
77
<IsPackable>true</IsPackable>
8-
<PackageDescription>Provides a safe reader for .NET Remoting Binary Format (NRBF) payloads.
9-
10-
Commonly Used Types:
11-
System.Formats.Nrbf.NrbfDecoder</PackageDescription>
128

139
<!-- Disabling baseline validation since this is a brand new package.
1410
Once this package has shipped a stable version, the following line
1511
should be removed in order to re-enable validation. -->
1612
<DisablePackageBaselineValidation>true</DisablePackageBaselineValidation>
17-
<!-- TODO: Add package README file: https://github.com/dotnet/runtime/issues/99358 -->
18-
<EnableDefaultPackageReadmeFile>false</EnableDefaultPackageReadmeFile>
13+
<EnableDefaultPackageReadmeFile>true</EnableDefaultPackageReadmeFile>
1914
</PropertyGroup>
15+
<ItemGroup>
16+
<Compile Include="$(CommonPath)System\Experimentals.cs"
17+
Link="Common\Experimentals.cs" />
18+
</ItemGroup>
19+
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
20+
<Compile Include="$(CoreLibSharedDir)System\Diagnostics\CodeAnalysis\ExperimentalAttribute.cs"
21+
Link="Common\ExperimentalAttribute.cs" />
22+
</ItemGroup>
2023
<ItemGroup Condition="'$(TargetFramework)' != '$(NetCoreAppCurrent)'">
2124
<ProjectReference Include="$(LibrariesProjectRoot)\System.Reflection.Metadata\src\System.Reflection.Metadata.csproj" />
2225
</ItemGroup>

src/libraries/System.Formats.Nrbf/tests/System.Formats.Nrbf.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<PropertyGroup>
44
<TargetFrameworks>$(NetCoreAppCurrent);$(NetFrameworkMinimum)</TargetFrameworks>
55
<EnableDefaultItems>true</EnableDefaultItems>
6+
<!-- SYSLIB5005: System.Formats.Nrbf is experimental -->
7+
<NoWarn>$(NoWarn);SYSLIB5005</NoWarn>
68
</PropertyGroup>
79

810
<ItemGroup>

src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ namespace System.Diagnostics.CodeAnalysis
2222
AttributeTargets.Event |
2323
AttributeTargets.Interface |
2424
AttributeTargets.Delegate, Inherited = false)]
25-
public sealed class ExperimentalAttribute : Attribute
25+
#if SYSTEM_PRIVATE_CORELIB
26+
public
27+
#else
28+
internal
29+
#endif
30+
sealed class ExperimentalAttribute : Attribute
2631
{
2732
/// <summary>
2833
/// Initializes a new instance of the <see cref="ExperimentalAttribute"/> class, specifying the ID that the compiler will use

src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ System.Resources.Extensions.DeserializingResourceReader
1717
System.Resources.Extensions.PreserializedResourceWriter</PackageDescription>
1818
<!-- TODO: Add package README file: https://github.com/dotnet/runtime/issues/99358 -->
1919
<EnableDefaultPackageReadmeFile>false</EnableDefaultPackageReadmeFile>
20+
<!-- SYSLIB5005: System.Formats.Nrbf is experimental -->
21+
<NoWarn>$(NoWarn);SYSLIB5005</NoWarn>
2022
</PropertyGroup>
2123

2224
<ItemGroup>

src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/System.Resources.Extensions.BinaryFormat.Tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
SYSLIB0011: BinaryFormatter obsolete
99
SYSLIB0050: Obsolete attribute
1010
SYSLIB0051: Formatters obsolete
11+
SYSLIB5005: System.Formats.Nrbf experimental
1112
-->
12-
<NoWarn>$(NoWarn);CS1574;CS1580;CA1036;CA1051;CA1066;SYSLIB0011;SYSLIB0050;SYSLIB0051;xUnit1013;CS0649</NoWarn>
13+
<NoWarn>$(NoWarn);CS1574;CS1580;CA1036;CA1051;CA1066;SYSLIB0011;SYSLIB0050;SYSLIB0051;SYSLIB5005;xUnit1013;CS0649</NoWarn>
1314
<StringResourcesPath>$(LibrariesProjectRoot)\System.Resources.Extensions\src\Resources\Strings.resx</StringResourcesPath>
1415
</PropertyGroup>
1516

0 commit comments

Comments
 (0)