unsafe
keyword should be marked as redundant if the using unsafe directive doesn't require it
#67988
Labels
unsafe
keyword should be marked as redundant if the using unsafe directive doesn't require it
#67988
Summary
If a "using unsafe" directive could also be a regular using directive, a new analyzer/fixer could identify and remove such redundant keywords.
Background and Motivation
It's legal, albeit pointless, to use a "using unsafe" or "using static unsafe" directive with types that would also be legal without the
unsafe
keyword. Examples:Proposed Feature
Either a compiler diagnostic or an
IDExxxx
diagnostic (whichever is better suited for this scenario) that reports that theunsafe
keyword is redundant. This could be complemented by a new code fixer that offers to remove that keyword.Alternative Designs
n/a
The text was updated successfully, but these errors were encountered: