Skip to content
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

SX1101 incorrectly reported for parameter that hides field #1707

Closed
sharwell opened this issue Oct 29, 2015 · 5 comments
Closed

SX1101 incorrectly reported for parameter that hides field #1707

sharwell opened this issue Oct 29, 2015 · 5 comments
Assignees
Milestone

Comments

@sharwell
Copy link
Member

SX1101 is reported for the use of this. in the following code. The code fix results in a compilation warning (assignment made to same variable) and (more importantly) a change in code behavior.

class ClassName
{
  int items;
  void Method(int items)
  {
    this.items = items;
  }
}
@vweijsters
Copy link
Contributor

Grabbing this

@vweijsters
Copy link
Contributor

@sharwell How did you get this code to produce an SX1101 diagnostic?
This case is covered by the VerifyThatNecessaryPrefixWillNotProduceDiagnosticsAsync test case and works fine for me.

@sharwell
Copy link
Member Author

  1. I enabled SX1101 and disabled SA1101 in StyleCop.Analyzers.ruleset.
  2. I ran fix all in solution for SX1101.
  3. I reverted just the change to StyleCop.Analyzers.ruleset.
  4. I ran fix all in solution for SA1101.

After the above steps, you can diff the current code against HEAD to see the places where the SX1101 code fix made a mistake.

This bug report was a simplification of one group of issues I saw in the result.

@vweijsters
Copy link
Contributor

OK, that is clear. Unfortunately for the description you picked the only example that is already handled 😉

@sharwell
Copy link
Member Author

Just my luck! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants