Skip to content

Add GetValueConversion extension methods for ICoalesceOperation - #85029

Merged
333fred merged 4 commits into
mainfrom
copilot/add-non-commonconversion-apis
Sep 2, 2026
Merged

Add GetValueConversion extension methods for ICoalesceOperation#85029
333fred merged 4 commits into
mainfrom
copilot/add-non-commonconversion-apis

Conversation

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

ICoalesceOperation.ValueConversion only exposes a CommonConversion, which drops the language-specific conversion details available on the C#/VB Conversion structs. IConversionOperation, ICompoundAssignmentOperation, and ISpreadOperation already have language-specific accessors; ICoalesceOperation did not.

ICoalesceOperation c = ...;
if (c.GetValueConversion().IsBoxing) ...;

Changes

  • CSharpExtensions.GetValueConversion(this ICoalesceOperation) — returns Microsoft.CodeAnalysis.CSharp.Conversion from the operation's ValueConversionConvertible; throws ArgumentNullException on null and ArgumentException when the operation did not come from C# code, matching GetInConversion/GetElementConversion.
  • VisualBasicExtensions.GetValueConversion(coalesceExpression As ICoalesceOperation) — VB counterpart with the same shape.
  • Resources — new ICoalesceOperationIsNotCSharpCoalesceOperation / ICoalesceOperationIsNotVisualBasicCoalesceOperation strings, with .xlf files regenerated via UpdateXlf.
  • Public API — entries added to both PublicAPI.Unshipped.txt files.
  • Tests — new cases in IOperationTests_ICoalesceOperation for both languages: null argument, identity conversion, boxing/widening-numeric, user-defined conversion (C#), and calling the other language's extension method (expects ArgumentException).

Named GetValueConversion per the approved API review, aligning with the ValueConversion property it complements.

@azure-pipelines

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

Co-authored-by: 333fred <2371880+333fred@users.noreply.github.com>
Copilot AI changed the title [WIP] Add non-CommonConversion based APIs for ICoalesceOperation.ValueConversion Add GetValueConversion extension methods for ICoalesceOperation Aug 25, 2026
@dotnet-policy-service dotnet-policy-service Bot added the Needs API Review Needs to be reviewed by the API review council label Aug 25, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging.

Copilot AI requested a review from 333fred August 25, 2026 17:09
@333fred
333fred marked this pull request as ready for review August 25, 2026 17:16
@333fred
333fred requested a review from a team as a code owner August 25, 2026 17:16
Copilot AI lite review requested due to automatic review settings August 25, 2026 17:16
@333fred
333fred requested a review from a team as a code owner August 25, 2026 17:16
@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds language-specific GetValueConversion extension methods for ICoalesceOperation in both the C# and Visual Basic compiler layers, enabling callers to retrieve the full language Conversion struct (rather than only CommonConversion) and aligning ICoalesceOperation with existing conversion-accessor patterns on other operation kinds.

Changes:

  • Add GetValueConversion extension methods on CSharpExtensions and VisualBasicExtensions that return the language Conversion and throw ArgumentNullException/ArgumentException consistent with sibling APIs.
  • Add new resource strings (and regenerated .xlf entries) for the cross-language ArgumentException messages.
  • Add C#/VB unit tests covering null-argument behavior, representative conversion shapes, and cross-language extension invocation failures.
Show a summary per file
File Description
src/Compilers/CSharp/Portable/CSharpExtensions.cs Adds CSharpExtensions.GetValueConversion(this ICoalesceOperation) returning C# Conversion with language validation and consistent exceptions.
src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb Adds VisualBasicExtensions.GetValueConversion(coalesceExpression As ICoalesceOperation) returning VB Conversion with language validation and consistent exceptions.
src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_ICoalesceOperation.cs Adds tests for null argument, identity/boxing/user-defined conversions, and calling VB extension on C# operation.
src/Compilers/VisualBasic/Test/IOperation/IOperation/IOperationTests_ICoalesceOperation.vb Adds tests for null argument, identity/widening numeric conversions, and calling C# extension on VB operation.
src/Compilers/CSharp/Portable/CSharpResources.resx Adds ICoalesceOperationIsNotCSharpCoalesceOperation resource string.
src/Compilers/VisualBasic/Portable/VBResources.resx Adds ICoalesceOperationIsNotVisualBasicCoalesceOperation resource string.
src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt Adds unshipped public API entry for C# GetValueConversion.
src/Compilers/VisualBasic/Portable/PublicAPI.Unshipped.txt Adds unshipped public API entry for VB GetValueConversion.
src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf Adds localized entry placeholder for new C# resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.cs.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.de.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.es.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.fr.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.it.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.ja.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.ko.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.pl.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.pt-BR.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.ru.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.tr.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hans.xlf Adds localized entry placeholder for new VB resource.
src/Compilers/VisualBasic/Portable/xlf/VBResources.zh-Hant.xlf Adds localized entry placeholder for new VB resource.

Review details

  • Files reviewed: 34/34 changed files
  • Comments generated: 0
  • Review effort level: Lite

@333fred

333fred commented Aug 25, 2026

Copy link
Copy Markdown
Member

@dotnet/roslyn-compiler for reviews

@333fred

333fred commented Aug 25, 2026

Copy link
Copy Markdown
Member

@copilot execute a full build to make sure that all things are updated.

Co-authored-by: 333fred <2371880+333fred@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 25, 2026 18:17

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot execute a full build to make sure that all things are updated.

The full ./build.sh completed successfully (0 errors). It regenerated and I committed the Semantic Search API baselines in e0cee9a.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 36/36 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings August 28, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 36/36 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@333fred

333fred commented Aug 31, 2026

Copy link
Copy Markdown
Member

@RikkiGibson for a second review

@333fred

333fred commented Sep 2, 2026

Copy link
Copy Markdown
Member

@dotnet/roslyn-compiler @RikkiGibson for a second review

@RikkiGibson

Copy link
Copy Markdown
Member

Taking a look

@333fred
333fred merged commit a078752 into main Sep 2, 2026
26 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Sep 2, 2026
@RikkiGibson
RikkiGibson deleted the copilot/add-non-commonconversion-apis branch September 2, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs API Review Needs to be reviewed by the API review council

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add non-CommonConversion based APIs for ICoalesceOperation.ValueConversion

5 participants