Don't write back into a method call when it's ByRef argument #1125
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.
Problem
ByRef argument w/o parentheses is treated like a writable variable, even if it's a method:
becomes
Solution
Any comments on the approach taken, its consistency with surrounding code, etc.
The adjustment itself is very minor: return
RefConversion.PreAssigment
fromGetRefConversion
when the symbol is anIMethodSymbol
.Which part of this PR is most in need of attention/improvement?
I've excluded
ReturnsByRef == false && ReturnsByRefReadonly == false
, same as with properties. This generates code like this atm:I haven't added any tests for this though, because of the whole problematic with solution tests involving C# ref returns from VB.NET.
Also, this code isn't necessarily correct if the property or method involved has side effects. It should use a temporary ref variable, something like this:
Unless there is an easy way to do that, I'd say it's out of scope of this PR.
At least one test covering the code changed