icsharpcode / NRefactory

NRefactory - Refactoring Your C# Code
684 stars 262 forks source link

Ported SuggestUseVarKeywordEvidentAnalyzer in NR6Pack using Roslyn #485

Closed Kavignon closed 9 years ago

Kavignon commented 9 years ago

See commit message.

P.S I would like to know how I can add diagnostic messages in my tests so I'll know that when I want them to "fail", I can add the diagnostic result I'm expecting so that the test will "pass" again.

Thank you ! @mkrueger

mkrueger commented 9 years ago

btw. about the diagnostic message: all asserts have an overload which take a message as last parameter.

mkrueger commented 9 years ago

Hi

I fixed a few things - please take a look and feel free to ask any questions:

https://github.com/icsharpcode/NRefactory/commit/b23ea69e75c70a9defad9a25be602e7225748989

Esp. the tests are informative.

The Analyze method shouldn't require any messages because it reports everything needed to be known.

Mark the area where the diagnostic runs with $ - and check the code fix as well (if there is any - in that case the code fix wasn't working).

Code fixes worked a bit different in NR5 - for roslyn we always need to provide one, if one is available.

I like that you introduced helper methods for the cases - that's more readable - good work.

I changed the ordering of the parameters a bit - for roslyn calls like GetTypeInfo or GetSymbolInfo always give the cancellationToken (for all methods that take that). The analyzers are working on a background thread that can be canceled and cancellation should be done ASAP.

Regards Mike

Rpinski commented 9 years ago

Hi,

unfortunately the code didn't test whether there is an initializer expression at all. That has caused many exceptions. I've fixed that in f600d330b1a79c2d38d7389e5abebcd8c7edda4d.

Best regards, Andreas