-
Notifications
You must be signed in to change notification settings - Fork 291
MSTEST0057 triggers on static constructors #6935
Copy link
Copy link
Labels
Description
Describe the bug
When a class deriving from TestMethodAttribute has a static constructor, MSTEST0057 is triggered suggesting adding [CallerFilePath] and [CallerLineNumber], despite the class already having the suggested constructor.
Steps To Reproduce
In this case the fixer suggest adding a constructor identical to the existing constructor.
public class MyTestMethodAttribute : TestMethodAttribute // <-- MSTEST0057 is triggered
{
static DateTimeOffset s_field = new();
public MyTestMethodAttribute([CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
: base(callerFilePath, callerLineNumber)
{
}
}This this case the fixer suggests adding [CallerFilePath] and [CallerLineNumber] to the static constructor.
public class SomeTestMethodAttribute : TestMethodAttribute
{
static SomeTestMethodAttribute() // <-- MSTEST0057 is triggered
{
}
public SomeTestMethodAttribute([CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
: base(callerFilePath, callerLineNumber)
{
}
}Expected behavior
MSTEST0057 should not be triggered.
Actual behavior
MSTEST0057 is triggered.
Additional context
Reactions are currently unavailable