Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Proposal]: nested members in with and object creation #4587

Closed
1 of 4 tasks
jcouv opened this issue Mar 26, 2021 · 2 comments
Closed
1 of 4 tasks

[Proposal]: nested members in with and object creation #4587

jcouv opened this issue Mar 26, 2021 · 2 comments

Comments

@jcouv
Copy link
Member

jcouv commented Mar 26, 2021

nested members in with and object creation

  • Proposed
  • Prototype: Not Started
  • Implementation: Not Started
  • Specification: Not Started

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 in with 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

@jnm2
Copy link
Contributor

jnm2 commented Mar 26, 2021

Existing discussion on nested with expressions: #77

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) };

@DustinCampbell
Copy link
Member

Here's another potential alternate syntax:

methodCallExpression with
{
    Method with { Name = "MethodName" }
}

@333fred 333fred added this to the Needs More Work milestone Jan 25, 2022
@dotnet dotnet locked and limited conversation to collaborators Nov 19, 2024
@dotnet dotnet unlocked this conversation Jan 6, 2025
@dotnet dotnet locked and limited conversation to collaborators Jan 6, 2025
@333fred 333fred converted this issue into discussion #9002 Jan 6, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

4 participants