Skip to content

Fix VB to C# assignment operators of parameterized properties#1229

Merged
GrahamTheCoder merged 5 commits intoicsharpcode:masterfrom
GrahamTheCoder:fix-1157-vb-parameterized-property-assignment-15193145234634278293
Mar 11, 2026
Merged

Fix VB to C# assignment operators of parameterized properties#1229
GrahamTheCoder merged 5 commits intoicsharpcode:masterfrom
GrahamTheCoder:fix-1157-vb-parameterized-property-assignment-15193145234634278293

Conversation

@GrahamTheCoder
Copy link
Member

@GrahamTheCoder GrahamTheCoder commented Mar 10, 2026

Fixes #1157 where shorthand assignment operators like += or -= were not properly resolved for parameterized properties during conversion from VB.NET to C#.

  • Updated MethodBodyExecutableStatementVisitor to correctly expand compound assignment operators (e.g. +=, -=, /=) to their corresponding setter method invocations (e.g. set_Item(0, get_Item(0) + 2)).
  • Added explicit handling and parameter type conversion support for Exponentiate assignments (which evaluate using Math.Pow).
  • Added AssignmentOperatorsParameterizedPropertiesAsync unit test to MethodStatementTests.cs to guarantee expected conversion logic holds valid.

PR created for task 15193145234634278293 started by @GrahamTheCoder


Gemini review

This pull request effectively addresses the conversion of compound assignment operators for parameterized properties from VB.NET to C#. The changes in MethodBodyExecutableStatementVisitor correctly expand these operators into the appropriate getter and setter method invocations, including special handling for exponentiation. The addition of the AssignmentOperatorsParameterizedPropertiesAsync unit test ensures these conversions are well-tested. I have one suggestion to refactor a small piece of duplicated code to improve maintainability.

google-labs-jules bot and others added 4 commits March 9, 2026 00:09
Fixes icsharpcode#1157 where shorthand assignment operators like "+=" or "-=" were not properly resolved for parameterized properties during conversion from VB.NET to C#.
- Updated MethodBodyExecutableStatementVisitor to correctly expand compound assignment operators to their corresponding setter invocations.
- Handles type conversions and `Math.Pow` logic for exponentiation explicitly when mapping back to the compound setter parameters.
- Add unit test AssignmentOperatorsParameterizedPropertiesAsync to verify expected behavior.

Co-authored-by: GrahamTheCoder <2490482+GrahamTheCoder@users.noreply.github.com>
@GrahamTheCoder GrahamTheCoder marked this pull request as ready for review March 11, 2026 00:41
@GrahamTheCoder GrahamTheCoder merged commit 2c2b64e into icsharpcode:master Mar 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VB -> C#: Assignment operators of parameterized properties are not resolved

1 participant