Skip to content

Suggest generic link to show how to suppress compiler warnings #33722

Open

Description

@abdekker

The article briefly discusses the CS0184 warning. An improvement would be to add a generic link (to a separate page) at the bottom for how the warning can be disabled. This would probably need to be generic across all (level 1?) compiler warnings so you don't have to update hundreds of individual help pages.

Code snippet to generate the warning in a C# file, along with the #pragma to (temporarily) disable the warning.

#pragma warning disable CS0184
// Or "#pragma warning disable CS0184, CS0219" to disable multiple warnings

// Following would have generated the warning "The given expression is never of the provided ('int') type"
byte myByte = 5;
if (myByte is int)
DoSomethingElse();
else
DoSomething();

#pragma warning restore CS0184
// Or "#pragma warning restore CS0184, CS0219" to restore multiple warnings


Document Details

⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Activity

  1. BillWagner commented on Jan 26, 2023

    @BillWagner
    Member

    That's an excellent idea @abdekker

    I'll keep this open, and continue to apply it across the docs for compiler warnings and errors.

    Thanks!

  2. added
    in-pr
    on Nov 1, 2026
  3. added a commit that references this issue on Nov 30, 2026
    d4000cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotnet-csharp/svcerrors-warnings/subsvcin-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions