API obsoletions with non-default diagnostic IDs

Some APIs have been marked as obsolete, starting in .NET 5. 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 5 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
SYSLIB0001 The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead. Warning
SYSLIB0002 PrincipalPermissionAttribute is not honored by the runtime and must not be used. Error
SYSLIB0003 Code access security (CAS) is not supported or honored by the runtime. Warning
SYSLIB0004 The constrained execution region (CER) feature is not supported. Warning
SYSLIB0005 The global assembly cache (GAC) is not supported. Warning
SYSLIB0006 Thread.Abort() is not supported and throws PlatformNotSupportedException. Warning
SYSLIB0007 The default implementation of this cryptography algorithm is not supported. Warning
SYSLIB0008 The CreatePdbGenerator() API is not supported and throws PlatformNotSupportedException. Warning
SYSLIB0009 The AuthenticationManager.Authenticate and AuthenticationManager.PreAuthenticate methods are not supported and throw PlatformNotSupportedException. Warning
SYSLIB0010 Some remoting APIs are not supported and throw PlatformNotSupportedException. Warning
SYSLIB0011 BinaryFormatter serialization is obsolete and should not be used. Warning
SYSLIB0012 Assembly.CodeBase and Assembly.EscapedCodeBase are only included for .NET Framework compatibility. Use Assembly.Location instead. Warning

Version introduced

.NET 5.0

  • 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

SYSLIB0001

SYSLIB0002

SYSLIB0003

Classes in the System.Security.Permissions namespace:

Classes that derive from CodeAccessSecurityAttribute:

Interfaces:

Classes that implement IStackWalk:

Classes that implement IPermission:

Classes that derive from CodeAccessPermission:

Classes that derive from ResourcePermissionBase:

Enums in the System.Security.Permissions namespace:

Classes and members that depend on code access security types:

SYSLIB0004

SYSLIB0005

SYSLIB0006

SYSLIB0007

SYSLIB0008

SYSLIB0009

SYSLIB0010

SYSLIB0011

SYSLIB0012

See also