Skip to content
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

Merged
merged 1 commit into from
Nov 23, 2022

Conversation

Youssef1313
Copy link
Member

No description provided.

@Youssef1313 Youssef1313 requested a review from a team as a code owner November 23, 2022 12:25
@@ -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 }))
Copy link
Member Author

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))
Copy link
Member Author

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.

Comment on lines +41 to +42
case SyntaxKind.ForEachVariableStatement:
var foreachStatement = (CommonForEachStatementSyntax)node;
Copy link
Member Author

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.

@mavasani mavasani enabled auto-merge November 23, 2022 12:49
@mavasani mavasani merged commit 29bcd1c into dotnet:main Nov 23, 2022
@github-actions github-actions bot added this to the vNext milestone Nov 23, 2022
@Youssef1313 Youssef1313 deleted the stackalloc-analyzer branch November 23, 2022 13:01
@Youssef1313 Youssef1313 mentioned this pull request Nov 23, 2022
Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants