Skip to content

Fix issue where a write wasn't detected in make-readonly #2#26303

Merged
jinujoseph merged 4 commits intodotnet:masterfrom
CyrusNajmabadi:makeReadOnlyDeconstruction
Apr 24, 2018
Merged

Fix issue where a write wasn't detected in make-readonly #2#26303
jinujoseph merged 4 commits intodotnet:masterfrom
CyrusNajmabadi:makeReadOnlyDeconstruction

Conversation

@CyrusNajmabadi
Copy link
Contributor

Followup to #26301

Fixes #26264

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 21, 2018 01:28
@CyrusNajmabadi
Copy link
Contributor Author

tagging @jcouv @dotnet/roslyn-ide @Neme12

@jcouv jcouv added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Apr 21, 2018
@jcouv jcouv added this to the 15.8 milestone Apr 21, 2018
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks

@CyrusNajmabadi
Copy link
Contributor Author

@mavasani @heejaechang could you take a look?

return false;
}

public static bool IsAttributeNamedArgumentIdentifier(this ExpressionSyntax expression)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i moved this function down as it was accidentally added between IsWrittenTo and IsOnlyWrittenTo.

///
/// copied from SyntaxExtensions.GetContainingDeconstruction
/// </summary>
private static bool IsExpressionOfArgumentInDeconstruction(ExpressionSyntax expr)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

talked to @jcouv and he says this is hte right way to determine if you're on the assignment part of a deconstruction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcouv Wasn't there some "get me the deconstruction info" API we could call instead? Even if we don't use it, just call it and check if the result is null? My worry being this is subtle and probably subject to change as the compiler does new things.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a semantic model API has a GetDeconstructionInfo. Looking at it, it seems I didn't add compiler tests (filed #26352 just now) :-S
I think it will only return something if you pass in an assignment or foreach syntax nodes.
That means you could indeed just check that you're on the left of an assignment (unwrapping tuples) and that the assignment is a deconstruction (using GetDeconstructionInfo).

I'm not sure that buys much (you still need to walk up the node's ancestors to find an assignment or foreach), and that's doing some binding work, so I'd recommend sticking with a purely syntactic check, as currently implemented in the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcouv How does this appear through IOperatoin? is is possible it's better? or would we still be lacking the info that this is a write and not a read?

@CyrusNajmabadi
Copy link
Contributor Author

@jinujoseph @dotnet/roslyn-ide can i get another pair of eyes on this simple PR?

@CyrusNajmabadi
Copy link
Contributor Author

@jcouv Feel free to merge. @jasonmalinowski Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants