-
Notifications
You must be signed in to change notification settings - Fork 470
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
Support ForEachVariableStatement in stackalloc analyzer #6286
Conversation
@@ -71,7 +72,7 @@ static bool ShouldWarn(IOperation? op, SyntaxNode node) | |||
foreach (IOperation child in block.Operations) | |||
{ | |||
if (child.Syntax.SpanStart > node.SpanStart && | |||
(child is IReturnOperation || (child is IBranchOperation branch && branch.BranchKind == BranchKind.Break))) | |||
(child is IReturnOperation or IBranchOperation { BranchKind: BranchKind.Break })) |
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.
No behavior change here. only a minor stylish change.
@@ -88,7 +89,7 @@ static bool ShouldWarn(IOperation? op, SyntaxNode node) | |||
} | |||
|
|||
// Warn as needed. | |||
if (ShouldWarn(ctx.SemanticModel.GetOperationWalkingUpParentChain(ctx.Node, default), ctx.Node)) | |||
if (ShouldWarn(ctx.SemanticModel.GetOperationWalkingUpParentChain(ctx.Node, ctx.CancellationToken), ctx.Node)) |
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 an unrelated improvement.
case SyntaxKind.ForEachVariableStatement: | ||
var foreachStatement = (CommonForEachStatementSyntax)node; |
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 the main fix.
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.
Thanks!
No description provided.