[Proposal]: nested members in with
and object creation
#9002
Unanswered
jcouv
asked this question in
Language Ideas
Replies: 2 comments
-
Existing discussion on nested Could there be names in scope to avoid doing a deep traversal twice? A common scenario (usually deeper): // Names in scope after '=': NestedThing, Collection
thing = thing with { NestedThing.Collection = Collection.Remove(value) }; As opposed to: thing = thing with { NestedThing.Collection = thing.NestedThing.Collection.Remove(value) }; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's another potential alternate syntax: methodCallExpression with
{
Method with { Name = "MethodName" }
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
nested members in
with
and object creationChampion issue: #9003
Summary
If we go ahead and add support for extended names in property patterns (
if (e is MethodCallExpression { Method.Name: "MethodName" })
), it makes sense for symmetry to allow this inwith
and object creation expressions:methodCallExpression with { Method.Name = "MethodName" }
new MethodCallExpression(...) { Method.Name = "MethodName" }
Motivation
This is particularly useful in the
with
expression, so you don't have to write:methodCallExpression with { Method = methodCallExpression.Method with { Name = "MethodName" } }
Detailed design
Drawbacks
Alternatives
Unresolved questions
Design meetings
Beta Was this translation helpful? Give feedback.
All reactions