Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DiagnosticDescriptor: Support fading out code different from the primary location #6697

Open
martin-strecker-sonarsource opened this issue Feb 1, 2023 · 0 comments
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Cleanup Improve and cleanup code base

Comments

@martin-strecker-sonarsource
Copy link
Contributor

Some rules fade out code to indicate unused code:

image

We use the bool fadeOutCode parameter to make the IDE aware of unused code:

public static DiagnosticDescriptor Create(AnalyzerLanguage language, RuleDescriptor rule, string messageFormat, bool? isEnabledByDefault, bool fadeOutCode) =>

This falls short in cases like above because the code is not just faded out but also squiggled. There is a more flexible way used by Roslyn where the out-fading can be specified separate from the primary location. So in cases like above, we could squiggle the method name and fade out the entire declaration.

These are the rules that fade out code at the moment and may benefit from a more fine grained fadeOutCode behavior.

  • S3949 - Calculations should not overflow
  • S1144 - Unused private types or members should be removed
  • S4487 - Unread "private" fields should be removed
  • S2437 - Silly bit operations should not be performed

Original discussion #6679 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Cleanup Improve and cleanup code base
Projects
None yet
Development

No branches or pull requests

2 participants