-
Notifications
You must be signed in to change notification settings - Fork 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
Discussion: ref this vs this ref in ref extension methods (15.6, as a 7.2 bug fix) #1022
Comments
Tagging @VSadov in case something to add. |
@jcouv @VSadov Any news here? My impression is that this can't be done within 15.5 timeframe but maybe as part of #946? And tbh I can't see the rationale behind the current restriction. |
You can change the |
@benaadams |
Makes what would define an extension very explicit e.g. What would be readonly ref extension? e.g.
|
I also prefer |
Both We could allow parameter modifiers in any order and just picked one order to not allow more than necessary. I.E. it can be relaxed to make combinations like |
I supposed PS: for comparison, consider |
FYI This was discussed in LDM https://github.com/dotnet/csharplang/blob/master/meetings/2017/LDM-2017-12-04.md |
Keeping the issue open so that it appears in the milestone as expected. |
Currently
this ref int
is not permitted and you need to useref this int
while throughout the languageref T
denotes a "ref type" and you may addthis
modifier on a parameter to define an extension method, so it would be sensible to usethis ref int
to define a ref extensions method. That being said, the restriction seems arbitrary, both could be allowed but IMOthis ref int
looks more natural based on current rules.As a minor point, the fact that all extension method's parameter lists start with
this
makes it easier to scan for extension methods in a static class.LDM:
The text was updated successfully, but these errors were encountered: