Replies: 2 comments 3 replies
-
The restriction exists because optional parameters didn't exist when expression trees were created, and the team has steadfastly refused to expand their support (short of a hypothetical "Expressions2"). IMHO, optional parameters could be supported without breakage by lowering them the same way the compiler does: including the implicit parameter at the call site. The expression consumer would see nothing different than if the user manually wrote the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Support optional and named arguments in method calls in
Expression
treesMotivation
Errors are reported for calls in
Expression
trees when the call is missing an argument for an optional parameter, or when arguments are named. This results in unnecessary code and differences for expressions withinExpression
trees.The compiler restrictions should be removed if not needed.
For example, compiling the following with the .NET 10 preview SDK results in errors currently.
Detailed design
Drawbacks
Alternatives
Unresolved questions
It's unclear why the restrictions were added originally. An initial investigation hasn't revealed an issue supporting these cases.
Design meetings
Based on a suggestion from @roji to support optional parameters.
Beta Was this translation helpful? Give feedback.
All reactions