Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SA1118 to allow multi-line collection expressions #3749

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -69,5 +69,6 @@ internal static class SyntaxKindEx
public const SyntaxKind RecordDeclaration = (SyntaxKind)9063;
public const SyntaxKind FunctionPointerUnmanagedCallingConventionList = (SyntaxKind)9066;
public const SyntaxKind RecordStructDeclaration = (SyntaxKind)9068;
public const SyntaxKind CollectionExpression = (SyntaxKind)9076;
}
}
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
Loading