-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Private static field causes false positive for analyzer rule MSTEST0005 #4590
Comments
This is actually a correct behavior. Most likely you are using the |
Let disagree that it's ok that a rule for a property is triggered by a field. Why? For an incorrectly stored TextContext, there is already a different rule: MSTEST0024. Overall, I found that TestContext is a messed up API:
|
I agree that's the TestContext API is fully broken and that's why I want to change it but that implies a massive breaking change and so a massive pushback from users. We have been thinking about migration solution with @Youssef1313 and I think we have a solid design for V4. |
Analyzer wids, there is one concern for me here. We already have a separate analyzer specifically about static TestContext which is not enabled by default. But then MSTEST0005 is duplicate part of that logic which is enabled by default as warning. Do we want this case to be warning by default? Or should we let it be handled by MSTEST0024 which is not warning by default. API wise, yeah we need to really change the design around TestContext. |
Here are my scenarios of using
I was looking for a way to perform no. 1 without using TestContext, but apparently it's the only way. Unlike all others, which allow a workaround. Please suggest a path forward, if any. Meanwhile, I submitted a small change to the doc, please take a look too: MicrosoftDocs/visualstudio-docs#10568 |
Describe the bug
A
private static
field of typeTestContext
causes a false positive for rule MSTEST0005:Steps To Reproduce
The following code:
causes the following warning:
Expected behavior
A field does not trigger a rule for a property.
Actual behavior
It does.
Additional context
The text was updated successfully, but these errors were encountered: