Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

C#: Replace initializer splitting with an ObjectInitMethod.#20922

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
aschackmull wants to merge8 commits intogithub:main
base:main
Choose a base branch
Loading
fromaschackmull:csharp/object-initializer

Conversation

@aschackmull
Copy link
Contributor

No description provided.

@aschackmullaschackmullforce-pushed thecsharp/object-initializer branch 2 times, most recently from49eed3a to0ef7beeCompareNovember 27, 2025 13:21
Copy link
Contributor

@michaelnebelmichaelnebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Uh, very neat!
Just some quick initial comments. It appears that there are some tests failing.

{
internalsealedclassObjectInitMethod:CachedEntity,IMethodEntity
{
TypeContainingType{get;}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

private?

aschackmull reacted with thumbs up emoji
this.ContainingType=containingType;
}

publicstringName=>"<object initializer>";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can be made a readonly field.

aschackmull reacted with thumbs up emoji
@michaelnebel
Copy link
Contributor

Do you also intend to model some synthetic assignments in the new synthetic method?

@aschackmull
Copy link
ContributorAuthor

Do you also intend to model some synthetic assignments in the new synthetic method?

The assignments are already extracted as top-level expressions in the enclosing class. We could move them into this new method - that's what Java does, but Java also allow one to write a chunk of code that goes directly into the object initializer, so the situation there is slightly different. However, I opted not to do that since it would be a much more invasive change and require us to change any current QL code that relies on identifying field initializers as they would have moved and would look different. Though, if we were building from scratch then I would have put the assignments inside the method, but as it stands I don't think it's worth it to make the change.

michaelnebel reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@michaelnebelmichaelnebelmichaelnebel left review comments

Copilot code reviewCopilotAwaiting requested review from CopilotCopilot will automatically review once the pull request is marked ready for review

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@aschackmull@michaelnebel

[8]ページ先頭

©2009-2025 Movatter.jp