Closed Hosch250 closed 9 years ago
This might shed some light on how to fix this: http://marcinjuraszek.com/2014/05/solution-wide-rename-from-code-fix-provider-fix-async-method-naming.html
This affects two analyzers:
I tried to implement this, and succeeded to a certain extent. However, certain of the tests are failing because semanticModel.GetDeclaredSymbol(identifierParent, cancellationToken);
returns null. This appears to only happen for variable/field types. A related issue is that context.SemanticModel.GetDeclaredSymbol(declarationExpression);
returns null for fields and event fields (which I discovered while working on #87). Is this an expected result, or should I create an issue on Roslyn?
A potential alternative solution is: https://social.msdn.microsoft.com/Forums/en-US/82092185-bf21-4802-9f04-b6238a47cebd/finding-usage-of-a-symbol?forum=roslyn. Specifically, the first answer.
If I recall correctly, this might be because GetDeclaredSymbol()
only works on (certain?) declarations. You might need to use another GetSymbol()
method for certain types. However can't you use the Renamer
for this?
I was using the Renamer. The Renamer needs to have the symbol passed in, and fields/event fields return null.
Did you try it with GetSymbolInfo()
as well?
Say I have this:
And I apply the Rename fix to
foo
at the definition. I get: