Skip to content
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

Missing docs and example on object initializer that lacks a new keyword #12979

Open
AArnott opened this issue Jun 24, 2019 — with docs.microsoft.com · 5 comments
Open
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc fundamentals/subsvc Pri2
Milestone

Comments

Copy link
Contributor

AArnott commented Jun 24, 2019

From C# ecma spec 12.7.11.3 it is possible to initialize values into a member using a = { } syntax (note the lack of the new keyword). By this it's possible to initialize a new object deeply within its properties that may not even make a setter available. This is very interesting and useful, and should be documented here.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@BillWagner BillWagner added P2 and removed ⌚ Not Triaged Not triaged labels Jul 2, 2019
@BillWagner BillWagner added this to the Backlog milestone Jul 2, 2019
@BillWagner
Copy link
Member

Thanks for writing this up @AArnott

I’ve added it to our backlog to update when we next update this topic.

@BillWagner BillWagner added 🗃️ Technology - C# Fundamentals doc-enhancement Improve the current content [org][type][category] and removed Source - Docs.ms labels Oct 17, 2019
@PRMerger7 PRMerger7 added the Pri2 label Jan 16, 2021
@dotnet-bot dotnet-bot added the won't fix Issues that were closed as part of automated backlog grooming label Jan 25, 2021
@dotnet-bot
Copy link
Contributor

This issue has been closed as part of the issue backlog grooming process outlined in #22351.

That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the @dotnet/docs team for visibility.

@AArnott
Copy link
Contributor Author

AArnott commented Jan 26, 2021

This feature is a gem in the C# language that really should be made known, and otherwise isn't documented anywhere that I can find.

@akamud
Copy link

akamud commented Apr 29, 2022

I was losing my mind over this until I found this issue.

ReSharper suggested I'd do this in a code I was writing and I thought to myself: I have never seen this before, is this new? I couldn't figure out how I've never seen this with more than 10 years working with C# and just couldn't understand what was this, specially when I read through the object initializer docs and didn't find any mention to this either.

Is this being worked on?

@ProTip
Copy link

ProTip commented Apr 23, 2023

After discovering this worked in Rider I spent well over an hour Googling and re-reading the documentation trying to figure out why it worked and where it was documented.

@AArnott AArnott removed the won't fix Issues that were closed as part of automated backlog grooming label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc fundamentals/subsvc Pri2
Projects
None yet
Development

No branches or pull requests

8 participants