Skip to content

Expose several SyntaxGenerator methods.#41416

Merged
CyrusNajmabadi merged 3 commits intodotnet:masterfrom
CyrusNajmabadi:publicMethods
Feb 27, 2020
Merged

Expose several SyntaxGenerator methods.#41416
CyrusNajmabadi merged 3 commits intodotnet:masterfrom
CyrusNajmabadi:publicMethods

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 5, 2020 04:47
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this happens in tests, which explicitly call into the simplifier with specific subnodes. in the test we call on an invocation expression with a null expression child.

@jinujoseph jinujoseph added Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. labels Feb 5, 2020
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

poke @jasonmalinowski . This actually came from a gitter request from a customer who was trying to use syntax generator but produce member bindings. we (i.e. me) clearly felt the need for this as well with IDE features. We just never made public :(

Copy link
Copy Markdown
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Addition of the API seems good, but I don't get what the second part of this PR is. It looks like a fix that was intended to benefit from the API change, but then didn't?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm just going to say this list of where clauses is terrifyingly long.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

:)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why isn't this calling Syntaxfactory.ElementBindingExpression then? And then why do we need the overrides at all?

(This PR seems to expose a common way to create these, and then the feature gets a way to avoid use of that API...?)

Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi CyrusNajmabadi Feb 11, 2020

Choose a reason for hiding this comment

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

So the design here is that you express the high level idea at the generator level, it then produces the right low-level C#/VB syntax for that concept. It turns out that syntax-level concept of an element binding for VB is an invocation expressoin. i.e. when you want to index into a nullable array in VB, you just write: a?(1), while in C# you do a?[1].

So this allows feature to say "i need to index into a nullable array" and get the right syntax without having to know about VB.

N/m i see what you're saying. The issue here is that it wants to create the invocation using the full arg list it had before, i.e. not a List<ArgumentSyntax> but a ArgumentListSyntax. The generators are not designed for that case. So this feature still does the work of doing it manually, but the generator at least exposes the entrypoint the customer and others would find valuable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we split the two PRs then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Up to you. Seems excessive to me. If you want that, LMK :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, we probably should, or at least rebase the changes and break up the history. If we have to revert either the API change or the behavior change we don't want to accidentally revert the other one with it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. i will do that now.

Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

c

SyntaxGEnerator will be updated to produce tehse nodes, but in a more abstract manner (i.e. without tokens/trivia).
This is not what this feature wants, so we're hardcoding the behavior it needs directly in the feature itself.
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

@jasonmalinowski I have rebased :)

@jasonmalinowski
Copy link
Copy Markdown
Member

Thanks for the split, makes it a lot clearer on your intent.

@CyrusNajmabadi CyrusNajmabadi merged commit 9c0370c into dotnet:master Feb 27, 2020
@CyrusNajmabadi CyrusNajmabadi deleted the publicMethods branch February 27, 2020 19:12
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

Thanks!

@jinujoseph jinujoseph added this to the 16.6.P2 milestone Feb 28, 2020
Sliptory added a commit to Sliptory/roslyn that referenced this pull request Feb 28, 2020
…hods"

This reverts commit 9c0370c, reversing
changes made to eb6a462.
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.

3 participants