From c556782e8ab33849953a4085ae82da6eeac9983d Mon Sep 17 00:00:00 2001 From: Jeff Handley Date: Mon, 16 Sep 2024 22:54:02 -0700 Subject: [PATCH] Mark the System.Formats.Nrbf assembly as [Experimental] with SYSLIB5005 --- docs/project/list-of-diagnostics.md | 1 + src/libraries/Common/src/System/Experimentals.cs | 3 +++ .../ref/System.Formats.Nrbf.Experimental.cs | 4 ++++ .../ref/System.Formats.Nrbf.csproj | 5 +++++ .../System.Formats.Nrbf/src/AssemblyInfo.cs | 7 +++++++ src/libraries/System.Formats.Nrbf/src/PACKAGE.md | 2 ++ .../src/System.Formats.Nrbf.csproj | 15 +++++++++------ .../tests/System.Formats.Nrbf.Tests.csproj | 2 ++ .../CodeAnalysis/ExperimentalAttribute.cs | 7 ++++++- .../src/System.Resources.Extensions.csproj | 2 ++ ...Resources.Extensions.BinaryFormat.Tests.csproj | 3 ++- 11 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.Experimental.cs create mode 100644 src/libraries/System.Formats.Nrbf/src/AssemblyInfo.cs diff --git a/docs/project/list-of-diagnostics.md b/docs/project/list-of-diagnostics.md index c0cfc970267829..a9dee40efdc8f3 100644 --- a/docs/project/list-of-diagnostics.md +++ b/docs/project/list-of-diagnostics.md @@ -310,3 +310,4 @@ Diagnostic id values for experimental APIs must not be recycled, as that could s | __`SYSLIB5002`__ | .NET 9 | TBD | `SystemColors` alternate colors are experimental in .NET 9 | | __`SYSLIB5003`__ | .NET 9 | TBD | `System.Runtime.Intrinsics.Arm.Sve` is experimental in .NET 9 | | __`SYSLIB5004`__ | .NET 9 | TBD | `X86Base.DivRem` is experimental in .NET 9 since performance is not as optimized as `T.DivRem` | +| __`SYSLIB5005`__ | .NET 9 | TBD | `System.Formats.Nrbf` is experimental in .NET 9 | diff --git a/src/libraries/Common/src/System/Experimentals.cs b/src/libraries/Common/src/System/Experimentals.cs index ddcfaf951f3738..fa9d92a403ee11 100644 --- a/src/libraries/Common/src/System/Experimentals.cs +++ b/src/libraries/Common/src/System/Experimentals.cs @@ -28,6 +28,9 @@ internal static class Experimentals // X86Base.DivRem is experimental in .NET 9 since performance is not as optimized as T.DivRem internal const string X86BaseDivRemDiagId = "SYSLIB5004"; + // System.Formats.Nrbf is experimental in .NET 9 + internal const string NrbfDecoderDiagId = "SYSLIB5005"; + // When adding a new diagnostic ID, add it to the table in docs\project\list-of-diagnostics.md as well. // Keep new const identifiers above this comment. } diff --git a/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.Experimental.cs b/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.Experimental.cs new file mode 100644 index 00000000000000..7c8b580a721ae0 --- /dev/null +++ b/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.Experimental.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +[assembly: System.Diagnostics.CodeAnalysis.ExperimentalAttribute("SYSLIB5005", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")] diff --git a/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj b/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj index 0d64bbf0a72d7d..092064146e4fcf 100644 --- a/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj +++ b/src/libraries/System.Formats.Nrbf/ref/System.Formats.Nrbf.csproj @@ -12,6 +12,11 @@ + + + + diff --git a/src/libraries/System.Formats.Nrbf/src/AssemblyInfo.cs b/src/libraries/System.Formats.Nrbf/src/AssemblyInfo.cs new file mode 100644 index 00000000000000..d976cf786d901a --- /dev/null +++ b/src/libraries/System.Formats.Nrbf/src/AssemblyInfo.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Diagnostics.CodeAnalysis; + +[assembly: Experimental(Experimentals.NrbfDecoderDiagId, UrlFormat = Experimentals.SharedUrlFormat)] diff --git a/src/libraries/System.Formats.Nrbf/src/PACKAGE.md b/src/libraries/System.Formats.Nrbf/src/PACKAGE.md index 5f5bfd09975ee4..c301459358838b 100644 --- a/src/libraries/System.Formats.Nrbf/src/PACKAGE.md +++ b/src/libraries/System.Formats.Nrbf/src/PACKAGE.md @@ -6,6 +6,8 @@ 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. +**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. + ## How to Use 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. diff --git a/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj b/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj index 3eced597c2e085..b75e1fb6408333 100644 --- a/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj +++ b/src/libraries/System.Formats.Nrbf/src/System.Formats.Nrbf.csproj @@ -5,18 +5,21 @@ true false true - Provides a safe reader for .NET Remoting Binary Format (NRBF) payloads. - -Commonly Used Types: -System.Formats.Nrbf.NrbfDecoder true - - false + true + + + + + + diff --git a/src/libraries/System.Formats.Nrbf/tests/System.Formats.Nrbf.Tests.csproj b/src/libraries/System.Formats.Nrbf/tests/System.Formats.Nrbf.Tests.csproj index c31537bb983ef1..9bf2f51fcce6cd 100644 --- a/src/libraries/System.Formats.Nrbf/tests/System.Formats.Nrbf.Tests.csproj +++ b/src/libraries/System.Formats.Nrbf/tests/System.Formats.Nrbf.Tests.csproj @@ -3,6 +3,8 @@ $(NetCoreAppCurrent);$(NetFrameworkMinimum) true + + $(NoWarn);SYSLIB5005 diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs index 55004a73d8b682..198341e3f78a6a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/ExperimentalAttribute.cs @@ -22,7 +22,12 @@ namespace System.Diagnostics.CodeAnalysis AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] - public sealed class ExperimentalAttribute : Attribute +#if SYSTEM_PRIVATE_CORELIB + public +#else + internal +#endif + sealed class ExperimentalAttribute : Attribute { /// /// Initializes a new instance of the class, specifying the ID that the compiler will use diff --git a/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj b/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj index 506df9b54bf577..2bb3dab6a1b41e 100644 --- a/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj +++ b/src/libraries/System.Resources.Extensions/src/System.Resources.Extensions.csproj @@ -17,6 +17,8 @@ System.Resources.Extensions.DeserializingResourceReader System.Resources.Extensions.PreserializedResourceWriter false + + $(NoWarn);SYSLIB5005 diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/System.Resources.Extensions.BinaryFormat.Tests.csproj b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/System.Resources.Extensions.BinaryFormat.Tests.csproj index b3d238081a2ecf..3e4dc3aae71e69 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/System.Resources.Extensions.BinaryFormat.Tests.csproj +++ b/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/System.Resources.Extensions.BinaryFormat.Tests.csproj @@ -8,8 +8,9 @@ SYSLIB0011: BinaryFormatter obsolete SYSLIB0050: Obsolete attribute SYSLIB0051: Formatters obsolete + SYSLIB5005: System.Formats.Nrbf experimental --> - $(NoWarn);CS1574;CS1580;CA1036;CA1051;CA1066;SYSLIB0011;SYSLIB0050;SYSLIB0051;xUnit1013;CS0649 + $(NoWarn);CS1574;CS1580;CA1036;CA1051;CA1066;SYSLIB0011;SYSLIB0050;SYSLIB0051;SYSLIB5005;xUnit1013;CS0649 $(LibrariesProjectRoot)\System.Resources.Extensions\src\Resources\Strings.resx