roslyn-sdk icon indicating copy to clipboard operation
roslyn-sdk copied to clipboard

Improve exception message when VerifyCodeFixAsync(code, code) fails

Open Youssef1313 opened this issue 4 years ago • 2 comments

See https://github.com/dotnet/roslyn-analyzers/pull/4700/files#r558434203

Youssef1313 avatar Jan 15 '21 16:01 Youssef1313

What was the old exception message? Do you have a suggestion for specific improvement?

sharwell avatar Jun 23 '21 17:06 sharwell

@sharwell Message:

    Microsoft.CodeAnalysis.Testing.Verifiers.EqualWithMessageException : Context: Iterative code fix application
    Expected '0' iterations but found '1' iterations.

The scenario was: A codefix is offered with no changes, i.e:

image

It didn't make sense to me at that time. While now I think it makes sense, it may be confusing to people new to writing analyzers. A more clear message would be something similar to "Expected no codefixes, found a code fix that doesn't change code".

Youssef1313 avatar Jun 23 '21 17:06 Youssef1313