Skip to main content
ai-slop/csharp-suppressed-warningmanual fix

Unexplained warning suppression.

A `#pragma warning disable` with no comment, or a `[SuppressMessage]` with no real `Justification`. The analyzer finding is hidden and nobody knows why.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

csharp-suppressed-warning.cs
✗ Flagged
#pragma warning disable CS8618
public class CustomerDto
{
    public string Email { get; set; }
}

[SuppressMessage("Design", "CA1031", Justification = "<Pending>")]
public void Refresh() => _cache.Reload();
Why this trips

Deterministic line match: flags `#pragma warning disable` without a trailing `//` comment or a comment on the previous non-blank line, and `SuppressMessage(` whose `Justification` is missing, empty, `pending`, `<Pending>`, or `todo`.

csharp-suppressed-warning.cs
✓ Clean
public class CustomerDto
{
    public required string Email { get; set; }
}

[SuppressMessage("Design", "CA1031", Justification = "Cache refresh is best-effort; failures are logged inside Reload")]
public void Refresh() => _cache.Reload();
What changed

Fix the warning. If suppression is justified, state the reason in a comment or the Justification, and prefer a scoped disable/restore pair over a file-wide disable.

Agents silence compiler and analyzer warnings to get a clean build instead of fixing the underlying issue, and generated suppressions often keep the `<Pending>` placeholder.

How this rule is justified.

Rule id

ai-slop/csharp-suppressed-warning

Enforcing engine

ai-slop

Detector strategy

Deterministic line match: flags `#pragma warning disable` without a trailing `//` comment or a comment on the previous non-blank line, and `SuppressMessage(` whose `Justification` is missing, empty, `pending`, `<Pending>`, or `todo`.

Legitimate code that is NOT flagged

`#pragma warning restore`, disables explained by an adjacent comment, and `[SuppressMessage]` attributes with a real Justification are not flagged.

Evidence

Part of aislop's C# rule set. First-class C# support, including C#-specific AI-slop rules, arrived in aislop v0.14.1.