-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow unchecked in method or class signature, just like unsafe #604
Comments
Yes, please! Every time I implement GetHashCode I end up wrapping the entire method body with |
Unlikely because as a rule we like to avoid letting implementation details about a method leak outside its body. |
@gafter I understand, although isn't that the same as with |
@gafter Is it really leaking information about implementation details? It's not part of the method signature. |
@jnm2 Yes, |
@gafter I see this as a keystroke and multiple line saving feature, like auto get and set and expression bodies. Along the same lines we'd like to be able to use throw in an expression body. Along the same lines also we'd like to have this feature. Just so I understand, given that the method is identical from the outside, who actually loses out if you add an |
We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages. |
I was wondering why the
unchecked
context is not allowed as part of the method or class signature?Apart from having the same benefits as
unsafe
at method or class signature level, this change would introduce more consistency between both keywords, which is something I have always really appreciated about C# and the .NET Framework.Before:
After:
Applied to a class:
Is there anything I have missed why this hasn't been made possible in the past or was it simply the (probable) limited usage of
unchecked
in C# compared tounsafe
?The text was updated successfully, but these errors were encountered: