How to get Resharper to show analyzers errors as resharper errors
Is there a way we can show (some) analyzers errors as resharper errors in the errors view, so we can easily navigate between those errors?
The long story:
We used the old StyleCop for many years. We have been using especially the rule “SA1005: Single line comment should begin with a space.” in the daily programming. When we have to comment out some piece of code temporary so we use “//” without a space and we set TODO markers with “//TODO" in the same manner so it always produce a resharper error without failing the build itself. So this was always visible to us via the resharper errors view and allowed us to quickly navigate between those errors with the reshaper short cut “go to next error”.
We finally switched from the legacy StyleCop to StyleCopAnalyzers, but our workflow is broken now. We found no way to enable the rule to be an error only for reshaper. If we set the severity of SA1005 to error in the .editorconfig, we see this error also in resharper error view but it also fails the build. So we can not use it as usual in our workflow.
Is there a way to get this working?
Please sign in to leave a comment.
No, there is now way to have roslyn analyzer's inspections as errors in ReSharper and as non-errors during build.
Hi Ivan,
Thanks for your reply.
Our workflow has been broken for months now, and we're still looking for a solution. I understand that there's no way to display Roslyn inspections as ReSharper errors without causing build errors. However, we're hoping there might be another way to achieve what we're looking for.
Specifically, we want the old rule “SA1005: Single-line comment should begin with a space” to be treated as a ReSharper error.
We were hoping to find this rule—or something similar—under Code Inspection → Inspection Severity, so we could simply enable it. Unfortunately, nothing like that seems to be available.
We also tried setting up a custom pattern under Code Inspection → Custom Patterns, but when we enter “//” as the search pattern, the Add button remains disabled, so we couldn’t save or test it.
Do you have any advice or ideas on how we could solve this issue?
Best regards,
Viktor
Hi Viktor,
Probably,
To-do Explorercan do the job. You can modify (or remove) builtinTodopattern under Options→Tools→To-do Explorer to exclude comments with no space before TODO:(?<=\W)(?<TAG>TODO)(\W|$)(.*)and add new pattern for TODO without space with
Erroricon:after it all
TODOcomments without trainling space will be shown inTo-do Explorer: