Skip to content

Obsoleted APIs using new diagnostic ID (.NET 6.0 preview-to-preview breaking change) #23891

Closed

Description

@jeffhandley

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.SystemConfigurationFile
  • System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr
  • System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject
  • System.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 : SYSLIB0019
  • System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsIntPtr : SYSLIB0019
  • System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject : SYSLIB0019
  • System.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


Issue metadata

  • Issue type: breaking-change

Activity

  1. added
    breaking-change
    on Apr 23, 2021
  2. self-assigned this
    on Apr 23, 2021
  3. added and removed
    ⌚ Not Triaged
    on Apr 23, 2021
  4. added
    🏁 Release: .NET 6
    on May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 6breaking-change

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions