dotnet / dotnet/linker

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

Open
#2,251 0 comments 0 reactions 0 assignees View on GitHub
area-Analyzers
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

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:

```C#

// 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 = "")]
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.