-
Notifications
You must be signed in to change notification settings - Fork 468
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
[CallerMustBeUnsafe] type attribute #972
Comments
As mentioned in https://github.com/dotnet/corefx/issues/42251#issuecomment-553310965, I don't think mixing language concepts ( My primary reason is that it is just asking users to change a setting in their project file and add an Truth is there are classes of APIs that are more prone to produce runtime errors (some of which are unrecoverable) and more "safe" APIs. Denoting APIs with Applied to the API mentioned in the above example, I'd suggest a |
I would rather focus energy on analyzers to help users correctly use these APIs. The attribute doesn't seem to add clarity to the code, but rather confuses concepts of pointers with other code and raises a bunch of questions about where the attribute should and should not be applied. |
Ported from dotnet/roslyn#8663
From https://github.com/dotnet/coreclr/issues/3143
To mark a function to be only be able to be called in an unsafe block.
It came up as an issue with having an
IntPtr
based api forVector.Copy
be equally could apply to something like a .ctor where you are passing an internal buffer to use (e.g. https://github.com/dotnet/coreclr/issues/3142)Or risk of use of buffers with overlapped I/O tasks and dispose dotnet/corefx#5954 (comment)
To indicate that the caller is aware there are risks and to be careful. What I am suggesting is something where .ctor 2 is forced to be
unsafe
in the same way .ctor 3 is:e.g.
The text was updated successfully, but these errors were encountered: