Skip to content

Commit

Permalink
Merge pull request #3749 from bjornhellander/feature/sa1118-collectio…
Browse files Browse the repository at this point in the history
…n-expression

Update SA1118 to allow multi-line collection expressions
  • Loading branch information
sharwell committed Dec 15, 2023
2 parents 2a917ff + 1e1d804 commit be49652
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,41 @@

namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Testing;
using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules;
using Xunit;

using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier<
StyleCop.Analyzers.ReadabilityRules.SA1118ParameterMustNotSpanMultipleLines>;

public partial class SA1118CSharp12UnitTests : SA1118CSharp11UnitTests
{
[Fact]
[WorkItem(3732, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3732")]
public async Task TestCollectionExpressionAsync()
{
var testCode = @"
class Foo
{
public void TestMethod()
{
AnotherMethod(
42,
[
1,
2,
3
]);
}
public void AnotherMethod(int x, int[] y)
{
}
}";

await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ internal class SA1118ParameterMustNotSpanMultipleLines : DiagnosticAnalyzer
SyntaxKind.ImplicitArrayCreationExpression,
SyntaxKindEx.WithExpression,
SyntaxKindEx.ImplicitObjectCreationExpression,
SyntaxKindEx.CollectionExpression,
};

/// <inheritdoc/>
Expand Down

0 comments on commit be49652

Please sign in to comment.