Skip to content

MSTEST0057 false positive when attribute has static field with initializer #7072

@gao-artur

Description

@gao-artur

MSTEST0057 reports a false positive when the attribute has a static field or property with an initializer. Not happens for const

public class DerivedTestMethodAttribute : TestMethodAttribute
{
    private static string Text { get; } = "I'm static property";
    private static readonly string _text = "I'm static field";

    public DerivedTestMethodAttribute([CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
        : base(callerFilePath, callerLineNumber)
    {
    }
}

MSTEST0057: TestMethodAttribute derived class 'AftTestMethodAttribute' should add CallerFilePath and CallerLineNumber parameters to its constructor

BTW, the documentation is missing for this diagnostic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions