Replies: 2 comments 4 replies
-
This sounds like it could easily be accomplished by an analyzer. The parameter or the method would have an attribute, e.g.: public void UpdateScreen([RequireNamedArguments] bool showingTitle)
// or
[RequireNamedArguments]
public void UpdateScreen(bool showingTitle) The analyzer would then find all calls of methods with the attribute and produce a diagnostic if the call didn't use named arguments. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Just to point that there is similar suggestion and prototype for F#: Such solution should be understood by the different compilers targetting the CLR. Thanks to @charlesroddie for pointing it out. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to require certain arguments to be called with a name argument label.
Currently I can sort of fake this requirement by providing a dummy optional parameter as the first parameter when all the arguments are optional.
This is how I must call this now.
The below will not work because of the dummy first optional argument and this is intentional.
This would work though:
It would be awesome if I could require a name argument like this:
or something like this.
alternatively if could be added to the method.
Currently I am not able to require it in non optional arguments which is where I would want this to work.
The advantage is that the named argument would be required at the call site thus giving more meaningful information to the caller on what the parameters do at a glance.
This could work after this is implemented: #518
Beta Was this translation helpful? Give feedback.
All reactions