RoslynNUnitLight icon indicating copy to clipboard operation
RoslynNUnitLight copied to clipboard

Analyzer that transfers data to CodeFixProvider using Properties cannot be tested

Open bkoelman opened this issue 10 years ago • 4 comments

An Analyzer that reports Diagnostics with Properties (to transfer data to it's CodeFixProvider) cannot be tested with this framework.

@DustinCampbell Please change CodeFixTestFixture.TestCodeFix to first run the analyzer and transfer it's properties -or- provide an additional argument (or overload) so that unittests can pass in properties.

bkoelman avatar May 06 '15 00:05 bkoelman

I'll take a look. Thanks for the request!

DustinCampbell avatar May 08 '15 11:05 DustinCampbell

@DustinCampbell To have a bit more experimentation freedom, I took the existing sources here and added them directly into my analyzer project. And modified them heavily. What I now have is all supported features (additional references, custom filename, Diagnostic.Properties support), and also support for verifying diagnostics that report multiple markup points [|x|] in code. Also, each associated fix provider can report multiple fixes, and the framework verifies them all. Lastly, I referenced Fluent Assertions, because the cryptic NUnit assertion messages like ... \r\nstring M(\r\n .... differs at index 39 from multiline code blocks are hard to understand.

I'd love to share it with you and others in a few days, so you can take a look. I'd be interested in your feedback obviously. But the code needs some cleanup and I have other duties this weekend. And I'm not sure what would be the best way to share; a formatted comment, a Gist, a repository, something else?

Oh, by the way, thanks for your talk What's New in C# 6 and Visual Basic 14.

bkoelman avatar May 08 '15 12:05 bkoelman

Could you split that into multiple PRs? Several of those changes, such as the FluentAssertions dependency, seem like they should be considered separately.

DustinCampbell avatar May 08 '15 12:05 DustinCampbell

Also, I've got some ideas for making setup more flexible as well. I'm going to try them in another branch. Maybe we can all converge. :smile:

DustinCampbell avatar May 08 '15 13:05 DustinCampbell