roslynator
roslynator copied to clipboard
Invalid analyzer results in projects which target multiple frameworks with different language versions
I have a project which is multi-targeted to .NET 4.7.2 and .NET 8. However, I am seeing Roslynator analyzer suggestions that are only valid for one of the target frameworks. For example, RCS1058 "compound assignment" is only valid for language version 8 or above but .NET 4.7.2 uses language version 7.3. The analyzer highlights the affected code but a potential fix is only provided when I have .NET 8 version of the project selected in the top-left dropdown in the editor.
Obviously there is some use to being able to see an analyzer result even if it can only be applied for some of the target frameworks. However, it also means that I'm seeing a lot of analyzer highlighting in the code that I can't / don't want to fix.
What if analyzers only displayed results for the currently selected target framework, as per the dropdown in the top left corner of the editor?