dotnet / dotnet/linker

UnconditionalSuppressMessage on static field initializer doesn't suppress linker warning

Open
#2,648 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

Another case where the linker doesn't understand compiler-generated code well enough to figure out the C# semantics of a suppression. It goes both ways - a suppression targeting the cctor via the `Target` syntax isn't recognized by the analyzer.

```csharp
// suppresses in linker only
[assembly: UnconditionalSuppressMessage("", "IL2026", Scope = "member", Target = "M:C.#cctor")]

// suppresses in analyzer only
[assembly: UnconditionalSuppressMessage("", "IL2026", Scope = "member", Target = "F:C.r")]

class C {
// suppresses in analyzer only
[UnconditionalSuppressMessage("", "IL2026")]
static int r = RUC();

[RUC("")]
static int RUC() => 0;
}
```

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.