API obsoletions with non-default diagnostic IDs (.NET 8)

Some APIs have been marked as obsolete, starting in .NET 8. This breaking change is specific to APIs that have been marked as obsolete with a custom diagnostic ID. Suppressing the default obsoletion diagnostic ID, which is CS0618 for the C# compiler, does not suppress the warnings that the compiler generates when these APIs are used.

Change description

In previous .NET versions, these APIs can be used without any build warning. In .NET 8 and later versions, use of these APIs produces a compile-time warning or error with a custom diagnostic ID. The use of custom diagnostic IDs allows you to suppress the obsoletion warnings individually instead of blanket-suppressing all obsoletion warnings.

The following table lists the custom diagnostic IDs and their corresponding warning messages for obsoleted APIs.

Diagnostic ID Description Severity
SYSLIB0011 BinaryFormatter serialization is obsolete Warning/error
SYSLIB0048 RSA.EncryptValue(Byte[]) and RSA.DecryptValue(Byte[]) are obsolete. Use RSA.Encrypt and RSA.Decrypt instead. Warning
SYSLIB0049 JsonSerializerOptions.AddContext is obsolete. To register a JsonSerializerContext, use either the TypeInfoResolver or TypeInfoResolverChain property. Warning
SYSLIB0050 Formatter-based serialization is obsolete and should not be used. Warning
SYSLIB0051 APIs that support obsolete formatter-based serialization are obsolete. They should not be called or extended by application code. Warning
SYSLIB0052 APIs that support obsolete mechanisms for Regex extensibility are obsolete. Warning
SYSLIB0053 AesGcm should indicate the required tag size for encryption and decryption. Use a constructor that accepts the tag size. Warning

Version introduced

.NET 8

Type of breaking change

These obsoletions can affect source compatibility.

  • Follow the specific guidance provided for the each diagnostic ID using the URL link provided on the warning.

  • Warnings or errors for these obsoletions can't be suppressed using the standard diagnostic ID for obsolete types or members; use the custom SYSLIBxxxx diagnostic ID value instead.

Affected APIs

SYSLIB0011

SYSLIB0048

SYSLIB0049

SYSLIB0050

SYSLIB0051

The SYSLIB0051 API obsoletions are organized here by namespace.

Microsoft.CSharp.RuntimeBinder namespace

Microsoft.VisualBasic.FileIO namespace

System namespace

System.Collections namespace

System.Collections.Generic namespace

System.Collections.Specialized namespace

System.ComponentModel namespace

System.ComponentModel.Composition namespace

System.ComponentModel.Composition.Primitives namespace

System.ComponentModel.DataAnnotations namespace

System.ComponentModel.Design namespace

System.Configuration namespace

System.Data namespace

System.Data.Common namespace

System.Data.Odbc namespace

System.Data.OleDb namespace

System.Data.SqlTypes namespace

System.Diagnostics.Eventing.Reader namespace

System.Diagnostics.Tracing namespace

System.DirectoryServices namespace

System.DirectoryServices.AccountManagement namespace

System.DirectoryServices.ActiveDirectory namespace

System.DirectoryServices.Protocols namespace

System.Formats.Asn1 namespace

System.Formats.Cbor namespace

System.Globalization namespace

System.IO namespace

System.Management namespace

System.Media namespace

System.Net namespace

System.Net.Mail namespace

System.Net.NetworkInformation namespace

System.Net.Sockets namespace

System.Reflection namespace

System.Reflection.Metadata namespace

System.Resources namespace

System.Runtime.CompilerServices namespace

System.Runtime.InteropServices namespace

System.Runtime.Serialization namespace

System.Security namespace

System.Security.AccessControl namespace

System.Security.Authentication namespace

System.Security.Claims namespace

System.Security.Cryptography namespace

System.Security.Policy namespace

System.Security.Principal namespace

System.Text.Json namespace

System.Text.RegularExpressions namespace

System.Threading namespace

System.Threading.Channels namespace

System.Threading.Tasks namespace

System.Transactions namespace

System.Xml namespace

System.Xml.Schema namespace

System.Xml.XPath namespace

System.Xml.Xsl namespace

SYSLIB0052

SYSLIB0053

See also