-
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
Add IOperation support for ILocalFunctionStatement #20177
Add IOperation support for ILocalFunctionStatement #20177
Conversation
Tagging @dotnet/analyzer-ioperation @dotnet/roslyn-compiler for review |
private static ILocalFunctionStatement CreateBoundLocalFunctionStatementOperation(BoundLocalFunctionStatement boundLocalFunctionStatement) | ||
{ | ||
IMethodSymbol localFunctionSymbol = boundLocalFunctionStatement.Symbol; | ||
Lazy<IBlockStatement> body = new Lazy<IBlockStatement>(() => (IBlockStatement)Create(boundLocalFunctionStatement.Body)); |
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.
Can we assert that the body is in fact a block statement before the lazy, that way if it ever fails it'll fail in a helpful location with a better stack? #ByDesign
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.
Can we assert that the body is in fact a block statement before the lazy, that way if it ever fails it'll fail in a helpful location with a better stack?
It looks like Body is statically typed as BoundBlock.
In reply to: 121546721 [](ancestors = 121546721)
@@ -0,0 +1,309 @@ | |||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
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.
Can you add some tests for invalid local function syntax? Such as int Local() => ;
#Resolved
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.
/// </summary> | ||
internal abstract partial class BaseLocalFunctionStatement : Operation, ILocalFunctionStatement | ||
{ | ||
protected BaseLocalFunctionStatement(IMethodSymbol localFunctionSymbol, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) : |
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.
ITypeSymbol type, Optional constantValue [](start = 115, length = 48)
Are these ever not null? #Closed
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.
I have used the common pattern already used in this generated file.
In reply to: 121588312 [](ancestors = 121588312)
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.
Added a note to #19720 (comment) to address this review comment.
public LazyLocalFunctionStatement(IMethodSymbol localFunctionSymbol, Lazy<IBlockStatement> body, bool isInvalid, SyntaxNode syntax, ITypeSymbol type, Optional<object> constantValue) | ||
: base(localFunctionSymbol, isInvalid, syntax, type, constantValue) | ||
{ | ||
_lazyBody = body ?? throw new System.ArgumentNullException("body"); |
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.
"body" [](start = 71, length = 6)
Use nameof? #Closed
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.
Use nameof?
It looks like there was no any response to this comment (#20177 (review)). #Closed
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.
I have used the existing pattern in this file. @heejaechang may want to address this in the generator. #Closed
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.
I am confused, are you actually running a generator, or adding this code manually. If the latter, please consider addressing provided feedback. For feedback you didn't addressed because of using existing pattern, pleas open issues to follow up (applies to other similar comments). #Closed
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.
I didn't address feedback as this will eventually become a generated file. I can file issues so we can address them in the generator when it is eventually checked in. Does that seem fine?
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.
I can file issues so we can address them in the generator when it is eventually checked in. Does that seem fine?
Yes, as long as we have issues tracking the debt. #Closed
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.
@AlekseyTs Added a note to #19720 (comment) to address this review comment.
bool isInvalid = boundLocalFunctionStatement.HasErrors; | ||
SyntaxNode syntax = boundLocalFunctionStatement.Syntax; | ||
ITypeSymbol type = null; | ||
Optional<object> constantValue = default(Optional<object>); |
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.
Optional constantValue = default(Optional); [](start = 12, length = 59)
This and the previous statement should be pushed into the constructor, I think. #Closed
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.
I have followed the general pattern used in this file. Heejae, you might want to take care of this when we checkin the generator.
In reply to: 121589002 [](ancestors = 121589002)
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.
@AlekseyTs Added a note to #19720 (comment) to address this review comment.
IReturnStatement (OperationKind.ReturnStatement) (Syntax: 'x + Local2(p1)') | ||
IBinaryOperatorExpression (BinaryOperationKind.IntegerAdd) (OperationKind.BinaryOperatorExpression, Type: System.Int32) (Syntax: 'x + Local2(p1)') | ||
Left: ILocalReferenceExpression: x (OperationKind.LocalReferenceExpression, Type: System.Int32) (Syntax: 'x') | ||
Right: IInvocationExpression (static System.Int32 Local2(System.Int32 p1)) (OperationKind.InvocationExpression, Type: System.Int32) (Syntax: 'Local2(p1)') |
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.
static [](start = 38, length = 6)
interesting, display says the local function is static. @agocke is this intentional? #Closed
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.
Aleksey, this is due to the dumper printing out "static" when operation.Instance is null. See here: http://source.roslyn.io/#Roslyn.Test.Utilities/Compilation/OperationTreeVerifier.cs,539
In reply to: 121589587 [](ancestors = 121589587)
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 due to the dumper printing out "static" when operation.Instance is null.
We should fix that. The dumper should show what is there, not invent things to confuse people. #Closed
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.
Filed #20194
Done with review pass. #Closed |
Done with review pass. #Closed |
retest windows_debug_vs-integration_prtest please |
retest windows_release_vs-integration_prtest please |
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.
LGTM
…alFunctionStatement
Ignoring the vs integration test failures, these are still not up yet. |
Fixes #19902