Skip to content

Commit

Permalink
Merge pull request #3820 from Devigus-Engineering-AG/feature/sa1513-l…
Browse files Browse the repository at this point in the history
…inq-into

Update SA1513 to not require a blank line before linq 'into' keyword
  • Loading branch information
sharwell authored Apr 3, 2024
2 parents 6327501 + 297d44c commit 2081d85
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp11.LayoutRules;
using Xunit;

using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier<
StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine,
StyleCop.Analyzers.LayoutRules.SA1513CodeFixProvider>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,5 +1034,72 @@ public class TestClass

await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false);
}

[Fact]
public async Task TestJoinIntoClauseSyntaxQueryExpressionAsync()
{
var testCode = @"
using System.Collections.Generic;
using System.Linq;
public class JoinIntoClauseSyntaxQueryExpressionTest
{
public JoinIntoClauseSyntaxQueryExpressionTest()
{
List<Foo> fooList = new List<Foo>();
List<Bar> barList = new List<Bar>();
var query =
from foo in fooList
join bar in barList
on new
{
foo.Id,
foo.Name
}
equals new
{
bar.Id,
bar.Name
}
into grouping
from joined in grouping.DefaultIfEmpty()
select new
{
joined.Id,
BarName = joined.Name,
FooName = foo.Name
};
}
private class Foo
{
public Foo(int id, string name)
{
this.Id = id;
this.Name = name;
}
public int Id { get; }
public string Name { get; }
}
private class Bar
{
public Bar(int id, string name)
{
this.Id = id;
this.Name = name;
}
public int Id { get; }
public string Name { get; }
}
}";

await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ private void AnalyzeCloseBrace(SyntaxToken token)
{
if (nextToken.Parent is QueryClauseSyntax
|| nextToken.Parent is SelectOrGroupClauseSyntax
|| nextToken.Parent is QueryContinuationSyntax)
|| nextToken.Parent is QueryContinuationSyntax
|| nextToken.Parent is JoinIntoClauseSyntax)
{
// the close brace is part of a query expression
return;
Expand Down

0 comments on commit 2081d85

Please sign in to comment.