Skip to content

MA0182: FP when type is only used in type check #1095

Description

@drieseng

Version of the Meziantou.Analyzer NuGet package

3.0.48

Rule Identifier

MA0182

Target Framework

.NET 10

C# Language version

c# 13

Description

MA0182 is reported when an internal class or interface is only ever used in a type check:

public sealed class Foo
{
    public static string? Run(object x)
    {
        if (x is IRunnable)
        {
            return null;
        }

        return "X";
    }
}

internal interface IRunnable
{
    void Run();
}

Not sure if this is intentional or not.
Removing the type would result in a build failure, but I'm ok if you consider this by design.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions