Add GetValueConversion extension methods for ICoalesceOperation - #85029
Conversation
|
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>
CommonConversion based APIs for ICoalesceOperation.ValueConversion|
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. |
|
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. |
There was a problem hiding this comment.
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
GetValueConversionextension methods onCSharpExtensionsandVisualBasicExtensionsthat return the languageConversionand throwArgumentNullException/ArgumentExceptionconsistent with sibling APIs. - Add new resource strings (and regenerated
.xlfentries) for the cross-languageArgumentExceptionmessages. - 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
|
@dotnet/roslyn-compiler for reviews |
|
@copilot execute a full build to make sure that all things are updated. |
Co-authored-by: 333fred <2371880+333fred@users.noreply.github.com>
|
@RikkiGibson for a second review |
|
@dotnet/roslyn-compiler @RikkiGibson for a second review |
|
Taking a look |
ICoalesceOperation.ValueConversiononly exposes aCommonConversion, which drops the language-specific conversion details available on the C#/VBConversionstructs.IConversionOperation,ICompoundAssignmentOperation, andISpreadOperationalready have language-specific accessors;ICoalesceOperationdid not.Changes
CSharpExtensions.GetValueConversion(this ICoalesceOperation)— returnsMicrosoft.CodeAnalysis.CSharp.Conversionfrom the operation'sValueConversionConvertible; throwsArgumentNullExceptionon null andArgumentExceptionwhen the operation did not come from C# code, matchingGetInConversion/GetElementConversion.VisualBasicExtensions.GetValueConversion(coalesceExpression As ICoalesceOperation)— VB counterpart with the same shape.ICoalesceOperationIsNotCSharpCoalesceOperation/ICoalesceOperationIsNotVisualBasicCoalesceOperationstrings, with.xlffiles regenerated viaUpdateXlf.PublicAPI.Unshipped.txtfiles.IOperationTests_ICoalesceOperationfor both languages: null argument, identity conversion, boxing/widening-numeric, user-defined conversion (C#), and calling the other language's extension method (expectsArgumentException).Named
GetValueConversionper the approved API review, aligning with theValueConversionproperty it complements.CommonConversionbased APIs forICoalesceOperation.ValueConversion#84905