Skip to content

Commit 1b7274c

Browse files
authored
Merge pull request #2309 from KlemensE/master
Fixes issue #2306
2 parents bd8424c + 65b6ca2 commit 1b7274c

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1513UnitTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,23 @@ public void MultiLineLinqQuery()
358358
}).ToList();
359359
}
360360
361+
// This is a regression test for https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2306
362+
public void MultiLineGroupByLinqQuery()
363+
{
364+
var someQuery = from f in Enumerable.Empty<int>()
365+
group f by new
366+
{
367+
f,
368+
}
369+
into a
370+
select a;
371+
372+
var someOtherQuery = from f in Enumerable.Empty<int>()
373+
group f by new { f }
374+
into a
375+
select a;
376+
}
377+
361378
// This is a regression test for https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1049
362379
public object[] ExpressionBodiedProperty =>
363380
new[]

StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1513ClosingBraceMustBeFollowedByBlankLine.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,15 @@ private void AnalyzeCloseBrace(SyntaxToken token)
230230
return;
231231
}
232232

233-
if (IsPartOf<QueryExpressionSyntax>(token) && ((nextToken.Parent is QueryClauseSyntax) || (nextToken.Parent is SelectOrGroupClauseSyntax)))
233+
if (IsPartOf<QueryExpressionSyntax>(token))
234234
{
235-
// the close brace is part of a query expression
236-
return;
235+
if (nextToken.Parent is QueryClauseSyntax
236+
|| nextToken.Parent is SelectOrGroupClauseSyntax
237+
|| nextToken.Parent is QueryContinuationSyntax)
238+
{
239+
// the close brace is part of a query expression
240+
return;
241+
}
237242
}
238243

239244
if (IsPartOf<ArgumentListSyntax>(token))

0 commit comments

Comments
 (0)