Skip to content

False positive IDE0079 when suppressing CA1859 #83970

@TobiasKnauss

Description

@TobiasKnauss

The issue is similar to "False positive IDE0079" #51884

Version Used:
Microsoft Visual Studio Professional 2022
Version 17.14.33 (May 2026)
VisualStudio.17.Release/17.14.33+37314.3.-may.2026-
Microsoft .NET Framework
Version 4.8.09221

Steps to Reproduce:

using System;
namespace Test;

internal interface ITest
{
  string Name { get; }
}

internal class CTest : ITest
{
  public string Name { get; }
  public CTest (string name) { Name = name; }
}

internal sealed class Program
{
  private static void Main (string[] args)
  {
    var oTest = new CTest ("ABC");
    ITest iTest = oTest;
    Console.WriteLine (iTest.Name);
  }
}
Image

But after adding a suppression attribute:

internal sealed class Program
{
  [System.Diagnostics.CodeAnalysis.SuppressMessage ("Performance", "CA1859:Use concrete types when possible for improved performance", Justification = "<Pending>")]
  private static void Main (string[] args)
  {
    var oTest = new CTest ("ABC");
    ITest iTest = oTest;
    Console.WriteLine (iTest.Name);
  }
}

the analyzer complains about an unneeded attribute:

Image

Diagnostic Id:

Warning (active) CA1859 Using concrete types avoids virtual or interface call overhead and enables inlining.
Message (active) IDE0079 Remove unnecessary suppression

Expected Behavior:

The analyzer should not report IDE0079.

Actual Behavior:

The analyzer falsely reports IDE0079.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions