Skip to content

Commit 2081d85

Browse files
authored
Merge pull request #3820 from Devigus-Engineering-AG/feature/sa1513-linq-into
Update SA1513 to not require a blank line before linq 'into' keyword
2 parents 6327501 + 297d44c commit 2081d85

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules
88
using Microsoft.CodeAnalysis.Testing;
99
using StyleCop.Analyzers.Test.CSharp11.LayoutRules;
1010
using Xunit;
11-
1211
using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
1312
StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine,
1413
StyleCop.Analyzers.LayoutRules.SA1513CodeFixProvider>;

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,5 +1034,72 @@ public class TestClass
10341034

10351035
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false);
10361036
}
1037+
1038+
[Fact]
1039+
public async Task TestJoinIntoClauseSyntaxQueryExpressionAsync()
1040+
{
1041+
var testCode = @"
1042+
using System.Collections.Generic;
1043+
using System.Linq;
1044+
1045+
public class JoinIntoClauseSyntaxQueryExpressionTest
1046+
{
1047+
public JoinIntoClauseSyntaxQueryExpressionTest()
1048+
{
1049+
List<Foo> fooList = new List<Foo>();
1050+
List<Bar> barList = new List<Bar>();
1051+
1052+
var query =
1053+
from foo in fooList
1054+
join bar in barList
1055+
on new
1056+
{
1057+
foo.Id,
1058+
foo.Name
1059+
}
1060+
equals new
1061+
{
1062+
bar.Id,
1063+
bar.Name
1064+
}
1065+
into grouping
1066+
from joined in grouping.DefaultIfEmpty()
1067+
select new
1068+
{
1069+
joined.Id,
1070+
BarName = joined.Name,
1071+
FooName = foo.Name
1072+
};
1073+
}
1074+
1075+
private class Foo
1076+
{
1077+
public Foo(int id, string name)
1078+
{
1079+
this.Id = id;
1080+
this.Name = name;
1081+
}
1082+
1083+
public int Id { get; }
1084+
1085+
public string Name { get; }
1086+
}
1087+
1088+
private class Bar
1089+
{
1090+
public Bar(int id, string name)
1091+
{
1092+
this.Id = id;
1093+
this.Name = name;
1094+
}
1095+
1096+
public int Id { get; }
1097+
1098+
public string Name { get; }
1099+
}
1100+
}";
1101+
1102+
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false);
1103+
}
10371104
}
10381105
}

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)