Skip to content

False Positive with IDE0370 #81632

@Evangelink

Description

@Evangelink

Version Used: VS Insiders [11304.161]

Steps to Reproduce: Open testf solution.

A minimal repro, with source-code provided, is ideal. Most compiler/language issues can be distilled into a snippet that can be pasted into .NET Lab.

Diagnostic Id: IDE0370 Suppression is unecessary

Expected Behavior:

No IDE0370 on the snippet below because GetMethod returns nullable.

Actual Behavior:

public void HasCorrectClassOrAssemblyInitializeSignatureShouldReturnTrueForTestMethods()
{
    MethodInfo methodInfo = typeof(DummyTestClass).GetMethod("PublicStaticMethodWithTC")!; // IDE0370 here
    methodInfo.HasCorrectClassOrAssemblyInitializeSignature().Should().BeTrue();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions