Skip to content

Commit 390b565

Browse files
author
David Grieser
committed
Update SA1513 to not require a blank line before linq 'into' keyword
1 parent f66d17d commit 390b565

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1513CSharp12UnitTests.cs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,76 @@ public Foo[] TestMethod() =>
3232

3333
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false);
3434
}
35+
36+
[Fact]
37+
public async Task TestJoinIntoClauseSyntaxQueryExpressionAsync()
38+
{
39+
var testCode = @"
40+
using System.Collections.Generic;
41+
using System.Linq;
42+
43+
public class JoinIntoClauseSyntaxQueryExpressionTest
44+
{
45+
public JoinIntoClauseSyntaxQueryExpressionTest()
46+
{
47+
List<Foo> fooList =
48+
[
49+
new(1, ""First""),
50+
new(2, ""Second""),
51+
new(3, ""Third""),
52+
new(1, ""Fourth"")
53+
];
54+
55+
List<Bar> barList =
56+
[
57+
new(1, ""First""),
58+
new(2, ""Second""),
59+
new(3, ""Third"")
60+
];
61+
62+
var query =
63+
from foo in fooList
64+
join bar in barList
65+
on new
66+
{
67+
foo.Id,
68+
foo.Name
69+
}
70+
equals new
71+
{
72+
bar.Id,
73+
bar.Name
74+
}
75+
into grouping
76+
from joined in grouping.DefaultIfEmpty()
77+
select new
78+
{
79+
joined.Id,
80+
BarName = joined.Name,
81+
FooName = foo.Name
82+
};
83+
}
84+
85+
private class Foo(
86+
int id,
87+
string name)
88+
{
89+
public int Id { get; } = id;
90+
91+
public string Name { get; } = name;
92+
}
93+
94+
private class Bar(
95+
int id,
96+
string name)
97+
{
98+
public int Id { get; } = id;
99+
100+
public string Name { get; } = name;
101+
}
102+
}";
103+
104+
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false);
105+
}
35106
}
36107
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ private void AnalyzeCloseBrace(SyntaxToken token)
238238
{
239239
if (nextToken.Parent is QueryClauseSyntax
240240
|| nextToken.Parent is SelectOrGroupClauseSyntax
241-
|| nextToken.Parent is QueryContinuationSyntax)
241+
|| nextToken.Parent is QueryContinuationSyntax
242+
|| nextToken.Parent is JoinIntoClauseSyntax)
242243
{
243244
// the close brace is part of a query expression
244245
return;

0 commit comments

Comments
 (0)