Skip to content

Suppressing analyzer diagnostics in IDE should generate a GlobalSuppresions.cs file using UnconditionalSuppressMessage #2251

@mateoatr

Description

@mateoatr

Currently, if a user chooses to suppress the diagnostics produced by the trimmer analyzer and clicks on the option given by the IDE, a global suppressions file will be generated with a list of assembly-level SuppressMessage attributes. However, this does not work for the diagnostics generated by the trimmer analyzer, since these must be unconditionally suppressed, otherwise the trimmer will keep emitting warnings when publishing. We should look into generating a global suppressions file that uses UnconditionalSuppressMessage instead.

Example of the GlobalSuppressions.cs file that is today generated:

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Trimming", "IL2026:Methods annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions