Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppression via preprocessor directive is considered unnecessary for some diagnostics #78073

Open
just-ero opened this issue Apr 8, 2025 · 3 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@just-ero
Copy link

just-ero commented Apr 8, 2025

Full issue information + repro project:
https://github.com/just-ero/roslyn-issues-repros/tree/main/5.0.0/000_CustomDiagnosticSuppression

Version

Roslyn: 5.0.0-1.25204.1 (ad1c386)

Steps to Reproduce

  1. Add the following code wherever syntactically applicable:
    #pragma warning disable SYSLIB1054
    
    class C
    {
        [DllImport("_")]
        static extern void M();
    }
  2. Target .NET 7.0 or higher.

Expected Behavior

The suppression of SYSLIB1054 is not considered unnecessary.

Actual Behavior

It is.


SYSLIB1054 emitted Suppression marked as unnecessary

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 8, 2025
@just-ero
Copy link
Author

just-ero commented Apr 8, 2025

The problem occurs for other diagnostics as well, for example for the EF* family of diagnostics.

@jaredpar jaredpar transferred this issue from dotnet/roslyn Apr 8, 2025
@hamarb123
Copy link

hamarb123 commented Apr 8, 2025

I've also seen this issue in VS with other diagnostics (but I hadn't tracked down the specific circumstances to cause it yet, but the one listed here seems about right). This is also a roslyn issue, not a runtime issue.

@just-ero
Copy link
Author

just-ero commented Apr 8, 2025

Due to apparent confusion on the target repo for this issue, I've attached two screenshots showing both the SYSLIB1054 diagnostic being emitted without the suppression, as well as the suppression being marked as unnecessary when included.

@jaredpar jaredpar transferred this issue from dotnet/runtime Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

3 participants