New diagnostic IDs for obsoleted APIs

Previously, a few APIs were obsoleted without using custom diagnostic IDs. Starting in .NET 6, those APIs report as obsolete using different, custom diagnostic IDs. If you suppressed warnings for usage of those APIs through CS0618, modify the suppressions to use the new diagnostic IDs, which are SYSLIB0003, SYSLIB0019, and SYSLIB0020.

Change description

The following table shows the old and new diagnostic IDs for the listed obsolete API.

API Previous diagnostic ID New diagnostic ID
Thread.GetCompressedStack() CS0618 SYSLIB0003
Thread.SetCompressedStack(CompressedStack) CS0618 SYSLIB0003
RuntimeEnvironment.SystemConfigurationFile CS0618 SYSLIB0019
RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr(Guid, Guid) CS0618 SYSLIB0019
RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid, Guid) CS0618 SYSLIB0019
JsonSerializerOptions.IgnoreNullValues CS0618 SYSLIB0020

Version introduced

.NET 6

Reason for change

Starting in .NET 5, obsoletions are intended to use custom diagnostic ID values to allow fine-grained suppression of the warnings. This yields a better experience when the obsolete APIs need to remain referenced. The obsoletions affected here should have had custom diagnostic ID values applied when the APIs were originally marked as [Obsolete].

If the SYSLIB0003, SYSLIB0019, or SYSLIB0020 diagnostic IDs are produced from your build, review the usage of the affected APIs. If possible, avoid using those APIs and refer to the messages and documentation for alternatives. If you need to retain the references to the obsolete APIs and suppress the diagnostics, suppress the warnings using the new diagnostic IDs instead of CS0618.

Affected APIs

See also