Skip to content

fix implementation of (readonly) auto property that is accessed through ++ (and similar) - #28

Merged
ltcmelo merged 5 commits into
masterfrom
p20
Jun 23, 2022
Merged

fix implementation of (readonly) auto property that is accessed through ++ (and similar)#28
ltcmelo merged 5 commits into
masterfrom
p20

Conversation

@ltcmelo

@ltcmelo ltcmelo commented Jun 22, 2022

Copy link
Copy Markdown
Contributor

A C# auto property can bet set within a constructor even if the property is declared with a get accessor only (these properties are "readonly"). So when we (manually) implement an auto property, we currently account for such set accesses when the access is within an assignment expression; but we must also account for them within pre/post increment/decrement expressions.

This PR extends, for pre/post increment/decrement expressions, the rewriting behaviour that already exists for assignment expressions. See the 2 new test cases.

Note: the code could have been more reusable if PrefixUnaryExpressionSyntax and PostfixUnaryExpressionSyntax had a common base class… or if we create an "adaptor" for these classes as we do for certain other syntaxes (but creating the adaptor is only worth it if we see this "pattern" occurring more often).

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.

2 participants