Skip to content

Commit be49652

Browse files
authored
Merge pull request #3749 from bjornhellander/feature/sa1118-collection-expression
Update SA1118 to allow multi-line collection expressions
2 parents 2a917ff + 1e1d804 commit be49652

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1118CSharp12UnitTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,41 @@
33

44
namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules
55
{
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Microsoft.CodeAnalysis.Testing;
69
using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules;
10+
using Xunit;
11+
12+
using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<
13+
StyleCop.Analyzers.ReadabilityRules.SA1118ParameterMustNotSpanMultipleLines>;
714

815
public partial class SA1118CSharp12UnitTests : SA1118CSharp11UnitTests
916
{
17+
[Fact]
18+
[WorkItem(3732, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3732")]
19+
public async Task TestCollectionExpressionAsync()
20+
{
21+
var testCode = @"
22+
class Foo
23+
{
24+
public void TestMethod()
25+
{
26+
AnotherMethod(
27+
42,
28+
[
29+
1,
30+
2,
31+
3
32+
]);
33+
}
34+
35+
public void AnotherMethod(int x, int[] y)
36+
{
37+
}
38+
}";
39+
40+
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
41+
}
1042
}
1143
}

StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ internal class SA1118ParameterMustNotSpanMultipleLines : DiagnosticAnalyzer
8787
SyntaxKind.ImplicitArrayCreationExpression,
8888
SyntaxKindEx.WithExpression,
8989
SyntaxKindEx.ImplicitObjectCreationExpression,
90+
SyntaxKindEx.CollectionExpression,
9091
};
9192

9293
/// <inheritdoc/>

0 commit comments

Comments
 (0)