diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs index d1b641f95..101612fcd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs @@ -290,9 +290,8 @@ private static void CheckBraceToken(SyntaxNodeAnalysisContext context, SyntaxTok // may want to allow that and not have SA1500 report it as a style error. if (context.GetStyleCopSettings(context.CancellationToken).LayoutRules.AllowDoWhileOnClosingBrace) { - var openBracePreviousToken = openBraceToken.GetPreviousToken(includeZeroWidth: true); - - if (openBracePreviousToken.IsKind(SyntaxKind.DoKeyword)) + if (openBraceToken.Parent.IsKind(SyntaxKind.Block) + && openBraceToken.Parent.Parent.IsKind(SyntaxKind.DoStatement)) { return; }