-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Analyzer suggestion: unnecessary use of unsafe
#48031
Comments
I've wanted this for sure. Also have wanted the ability to move |
I'm interested in implementing this if it's approved in the design meeting. |
I'm willing to pre-emptively approve this. We would take this. Open question is on if it's feasible to encode the rules easily enough to put this in teh IDE. My preference would be more that this be done in the compiler with a hidden diagnostic. |
Design meeting notes: This should come from Compiler, request hidden diagnostic from the compiler. |
Simplifies BitHelper, basing it on span instead of having to accomodate both pointers and arrays, and avoids allocating the BitHelper instance. We now also clear the input optionally. Commit migrated from dotnet/corefx@82ce02d
Brief description:
We frequently find ourselves initially writing some method to use unsafe code / pointers, and so annotate the method as
unsafe
. Later, generally asSpan<T>
is employed more or as new framework APIs are utilized to improve the method, the method no longer uses pointers, but we sometimes forget to remove theunsafe
keyword. It would be nice-to-have if there were an analyzer we could enable to flag such uses ofunsafe
that could be removed.Languages applicable:
C#
Code example that the analyzer should report:
The text was updated successfully, but these errors were encountered: