-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IObjectCreationExpression API shape #18115
Comments
Design Team Decision:
Open question: Do we need to still somehow ensure we expose IFieldReferenceExpression in the IOperation tree rooted at |
That's an interesting question. Can you add it to the questions for the design meeting? I see the benefit of it being in the tree. That way people can just register a single callback. One way we could do that would be to have IFieldInitializer point at the IFieldReferenceExpression instead of directly at the IFieldSymbol. Note: IFieldInitializer really seems to be defined for the actual field case. i.e. "private int i = 0" or "dim i, j, as new whatever()". I'm not sure i like that it is being used in the "new with" expression. |
Design Team Decision: NamedFieldInitializerSyntax, i.e. .Field = 2 we will return IAssignmentExpression that is Initializers for IObjectCreationExpression will be all IOperations instead of ISymbolInitializers We should probably have something like IObjectInitializer, which can contain several of these assignments and their invocations (add with arguments), For now we can say it's an array of IOperation.
|
blocked design decision on #18781 |
There are couple of changes here: 1. API change: `ImmutableArray<ISymbolInitializer> MemberInitializers` is changed to `ImmutableArray<IOperation> Initializers`. 2. Implementation changes: 1. Instead of returning the member initializers as synthesized ISymbolInitializer nodes, we now return member intializers as IAssignmentExpression nodes. This ensures completeness of IOperation tree. 2. Now we also return the collection intializer expressions within an object creation expression. Fixes dotnet#18115 There are 2 bugs still affecting this area: 1. dotnet#18781: IOperation API shape for collection initializer expressions 2. dotnet#19276: Missing Field/Property reference expression nodes in object creation initializer node
The shady part is MemberInitializers, which only expose a part of the IOperation tree within the object member initializer.
Let me give an example:
IOperation tree for object creation:
IOperation tree for it's child node, object member initializer:
IOperation tree for one of the child nodes of the member initializer, NamedFieldInitializerSyntax:
I think we either need to change
MemberInitializers
to return the entire IOperation tree for each initializer (which would be the IAssignmentExpression for the field initializer) OR replace MemberInitializers withInitializerOpt
of new OperationKind.ObjectMemberInitializer, which exposes all the initializer expressions.The text was updated successfully, but these errors were encountered: