dotnet / dotnet/linker

The linker is unable to determine whether suppression is redundant when feature switches are used.

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

Description

```csharp
public static bool IsFeatureEnabled {
get => throw new NotImplementedException ();
}

[UnconditionalSuppressMessage ("Test", "IL2072")]
public static void Method()
{
if (IsFeatureEnabled) {
// Trigger IL2072 warning.
} else {
// Trimmer compatible code.
}
}
```

Let us assume we are using feature substitutions to set the return value of the `IsFeatureEnabled` getter to either true or false.

The linker is unable to determine whether the suppression on `Method` is redundant. Enabling the feature will make the suppression useful, disabling it makes the suppression redundant.

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.