-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Brace completion and IOperation for with
expression
#44712
Changes from 12 commits
52b4c8a
26c5612
154b634
c833047
57048ed
96f7341
dceba97
751af04
b9cc321
5580493
9d3ee98
b612da6
60406da
81dc5a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6982,5 +6982,19 @@ public override IOperation VisitUsingDeclaration(IUsingDeclarationOperation oper | |
throw ExceptionUtilities.Unreachable; | ||
} | ||
|
||
public override IOperation VisitWithExpression(IWithExpressionOperation operation, int? argument) | ||
{ | ||
EvalStackFrame frame = PushStackFrame(); | ||
// Initializer is removed from the tree and turned into a series of statements that assign to the cloned instance | ||
IOperation visitedInstance = Visit(operation.Value); | ||
|
||
IOperation cloned = operation.CloneMethod is null | ||
? MakeInvalidOperation(visitedInstance.Type, visitedInstance) | ||
: new InvocationOperation(operation.CloneMethod, visitedInstance, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is Clone method an instance method? #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it is an instance method #Resolved |
||
isVirtual: false, arguments: ImmutableArray<IArgumentOperation>.Empty, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Based on #44852, the call probably should be virtual There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Will fix in a follow-up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlekseyTs It looks like Andy fixed this already (we now have |
||
semanticModel: null, operation.Syntax, operation.Type, operation.ConstantValue, isImplicit: true); | ||
|
||
return PopStackFrame(frame, HandleObjectOrCollectionInitializer(operation.Initializer, cloned)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ | |
UnusedOperationKinds indicates kinds that are currently skipped by the OperationKind | ||
enum. They can be used by future nodes by inserting those nodes at the correct point | ||
in the list. | ||
|
||
When implementing new operations, run tests with additional IOperation validation enabled. | ||
You can test with `Build.cmd -testIOperation`. | ||
Or to repro in VS, you can do `set ROSLYN_TEST_IOPERATION=true` then `devenv`. | ||
--> | ||
|
||
<UnusedOperationKinds> | ||
|
@@ -3001,4 +3005,30 @@ | |
</Comments> | ||
</Property> | ||
</Node> | ||
<Node Name="IWithExpressionOperation" Base="IOperation" ChildrenOrder="Value,Initializer"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we would want a special rewrite for this node in CFG, something very similar to a an object initializer operation #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please run all tests with -testIOperation switch locally and confirm that none of the failures are related to the feature. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we need to adjust OperationCloner for this node #Closed |
||
<Comments> | ||
<summary> | ||
Represents cloning of an object instance. | ||
<para> | ||
Current usage: | ||
(1) C# with expression. | ||
</para> | ||
</summary> | ||
</Comments> | ||
<Property Name="Value" Type="IOperation"> | ||
<Comments> | ||
<summary>Value to be cloned.</summary> | ||
</Comments> | ||
</Property> | ||
<Property Name="CloneMethod" Type="IMethodSymbol"> | ||
<Comments> | ||
<summary>Clone method to be invoked on the value.</summary> | ||
</Comments> | ||
</Property> | ||
<Property Name="Initializer" Type="IObjectOrCollectionInitializerOperation"> | ||
<Comments> | ||
<summary>With collection initializer.</summary> | ||
</Comments> | ||
</Property> | ||
</Node> | ||
</Tree> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a generated file, should probably modify XML instead #Resolved