Repository navigation
Description
Obsoleted APIs using new diagnostic ID (.NET 6.0 preview-to-preview breaking change)
During early .NET 6.0 previews, a few APIs were obsoleted without using custom diagnostic ids. In .NET 6.0 Preview 5, those APIs will now report as obsolete using new, custom diagnostic ids. If usage of those APIs had the diagnostics suppressed through CS0618, the suppressions will need to be modified to use the new diagnostic ids.
Version introduced
.NET 6.0 Preview 5
Old behavior
The following APIs were marked as [Obsolete] using the standard CS0618 diagnostic ID:
System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFileSystem.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtrSystem.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObjectSystem.Text.Json.JsonSerializerOptions.IgnoreNullValues
New behavior
Starting in .NET 6.0 Preview 5, usage of those APIs will now produce warnings with the following diagnostic ids.
System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFile:SYSLIB0019System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr:SYSLIB0019System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject:SYSLIB0019System.Text.Json.JsonSerializerOptions.IgnoreNullValues:SYSLIB0020
Reason for change
Starting in .NET 5.0, obsoletions are intended to use custom diagnostic id values allowing 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 marked as [Obsolete].
Recommended action
If the SYSLIB0019 or SYSLIB0020 diagnostic ids are produced from your build, review the usage of the above APIs. If possible, avoid using those APIs and refer to the messages and documentation for alternatives. If references to the obsolete APIs need to remain and diagnostic suppressions are desired, use the new diagnostic ids instead of CS0618.
Category
- ASP.NET Core
- C#
- Code analysis
- Core .NET libraries
- Cryptography
- Data
- Debugger
- Deployment
- Globalization
- Interop
- JIT
- LINQ
- Managed Extensibility Framework (MEF)
- MSBuild
- Networking
- Printing
- Security
- Serialization
- Visual Basic
- Windows Forms
- Windows Presentation Foundation (WPF)
- XML, XSLT
Affected APIs
System.Runtime.InteropServices.RuntimeEnvironment.SystemConfigurationFileSystem.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtrSystem.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObjectSystem.Text.Json.JsonSerializerOptions.IgnoreNullValues
Issue metadata
- Issue type: breaking-change
Activity