Skip to content

Change a default value of C# Conversion - #84628

Merged
333fred merged 12 commits into
dotnet:mainfrom
DoctorKrolic:default-cs-conversion
Aug 18, 2026
Merged

333fred merged 12 commits into
dotnet:mainfrom
DoctorKrolic:default-cs-conversion

Conversation

@DoctorKrolic

@DoctorKrolic DoctorKrolic commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: #35918

During foreach binding if the collection is an error type binder returned default(ForEachStatementInfo), which included CurrentConversion and ElementConversion. However due to the fact that a default value of internal ConversionKind was UnsetConversionKind, which, I guess, was meant for internal use inside the compiler, the default value of Conversion struct had Exists and IsReference properties return true. As it turned out, that internal kind isn't used anymore and all existing usages can become NoConversion without issues. So I removed the internal kind making NoConversion a new default. This is a breaking API change and I documented it as one, but I believe this is a correct way to go forward. There was only one place inside the whole roslyn that relied on this quirk

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Jul 26, 2026
@DoctorKrolic DoctorKrolic changed the title [WIP]: Make a default(Conversion) be Exists == false Change a default value of C# Conversion Aug 1, 2026
@DoctorKrolic
DoctorKrolic marked this pull request as ready for review August 1, 2026 11:51
@DoctorKrolic
DoctorKrolic requested review from a team as code owners August 1, 2026 11:51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@DoctorKrolic

Copy link
Copy Markdown
Contributor Author

@333fred I assume a breaking API change follows a similar process to an API proposal. If so, may you please schedule this one for a review session? Tagged you specificly since you are the person who seem to be usually doing it

@333fred

333fred commented Aug 6, 2026

Copy link
Copy Markdown
Member

Not sure that a bugfix really qualifies as a breaking change. I'll send an email about it though; feel free to tag me again if I haven't gotten back you in a week.

@333fred

333fred commented Aug 12, 2026

Copy link
Copy Markdown
Member

Compat council approved the general concept. Will try to review soon.

Comment thread docs/Breaking API Changes.md Outdated
Comment thread docs/Breaking API Changes.md Outdated
Comment thread docs/Breaking API Changes.md
@DoctorKrolic
DoctorKrolic requested a review from jjonescz August 14, 2026 19:34
@jjonescz
jjonescz requested review from a team and 333fred August 17, 2026 07:38

@333fred 333fred left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple of wording changes for the breaking change doc. Also needs a review from @dotnet/roslyn-ide.

Comment thread docs/Breaking API Changes.md Outdated
Comment thread docs/Breaking API Changes.md Outdated
DoctorKrolic and others added 2 commits August 18, 2026 19:24
Co-authored-by: Fred Silberberg <fred@silberberg.xyz>
Co-authored-by: Fred Silberberg <fred@silberberg.xyz>
@DoctorKrolic
DoctorKrolic requested a review from 333fred August 18, 2026 16:25

@333fred 333fred left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still needs a review from @dotnet/roslyn-ide.

@333fred
333fred enabled auto-merge (squash) August 18, 2026 18:40
@333fred
333fred merged commit 43b82c3 into dotnet:main Aug 18, 2026
29 of 30 checks passed
@DoctorKrolic
DoctorKrolic deleted the default-cs-conversion branch August 18, 2026 19:24
@333fred

333fred commented Aug 18, 2026

Copy link
Copy Markdown
Member

Thanks @DoctorKrolic!

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

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit conversion in foreach is incorrect

4 participants