Expose several SyntaxGenerator methods.#41416
Conversation
There was a problem hiding this comment.
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.
|
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 :( |
jasonmalinowski
left a comment
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I'm just going to say this list of where clauses is terrifyingly long.
There was a problem hiding this comment.
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...?)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Should we split the two PRs then?
There was a problem hiding this comment.
Up to you. Seems excessive to me. If you want that, LMK :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Sounds good. i will do that now.
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.
481ed2a to
d54bb5e
Compare
|
@jasonmalinowski I have rebased :) |
|
Thanks for the split, makes it a lot clearer on your intent. |
|
Thanks! |
No description provided.