Fix VB to C# assignment operators of parameterized properties#1229
Merged
GrahamTheCoder merged 5 commits intoicsharpcode:masterfrom Mar 11, 2026
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1157 where shorthand assignment operators like
+=or-=were not properly resolved for parameterized properties during conversion from VB.NET to C#.MethodBodyExecutableStatementVisitorto correctly expand compound assignment operators (e.g.+=,-=,/=) to their corresponding setter method invocations (e.g.set_Item(0, get_Item(0) + 2)).Math.Pow).AssignmentOperatorsParameterizedPropertiesAsyncunit test toMethodStatementTests.csto 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
MethodBodyExecutableStatementVisitorcorrectly expand these operators into the appropriate getter and setter method invocations, including special handling for exponentiation. The addition of theAssignmentOperatorsParameterizedPropertiesAsyncunit test ensures these conversions are well-tested. I have one suggestion to refactor a small piece of duplicated code to improve maintainability.