dotnet / codeformatter

Tool that uses Roslyn to automatically rewrite the source to follow our coding styles
MIT License
1.24k stars 244 forks source link

Out parameters not handled correctly #272

Closed barjonas closed 6 years ago

barjonas commented 6 years ago

Repro steps

  1. Add a module-scoped variable called object myVariable.
  2. In a method body, call out to another method with an out parameter, out object myVariable.
  3. Make an assignment, this.myVariable = myVariable.
  4. Run everything through CodeFormatter with the default settings

Expected behavior

The module-scoped variable should be renamed _myVariable. The method-scoped variable should not be renamed. The assignment should now read _myVariable = myVariable.

Observed behavior

Everything is renamed myVariable_, presumably because the parser does not recognize that a new variable is being created from the out parameter. That changes the semantics and leaves an invalid assignment, _myVariable = myVariable_.