Skip to content
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 @@ -21,8 +21,7 @@ public partial class SA1137CSharp12UnitTests : SA1137CSharp11UnitTests
/// <param name="lineEnding">The line ending used in the source.</param>
/// <returns>A task representing the asynchronous operation.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
[WorkItem(3296, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3296")]
public async Task TestInlineCollectionExpressionClosingBracketAsync(string lineEnding)
{
Expand Down Expand Up @@ -57,8 +56,7 @@ await VerifyCSharpFixAsync(
/// <param name="lineEnding">The line ending used in the source.</param>
/// <returns>A task representing the asynchronous operation.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
[WorkItem(3296, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3296")]
public async Task TestCollectionExpressionClosingBracketAfterLeadingCommentAsync(string lineEnding)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public int TestMethod((int nameA, int nameB) p1, (int, int) p2, (int, int nameC)
/// <param name="lineEnding">The line ending to use for the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task ValidateMetadataNameReferencesAsync(string lineEnding)
{
var testCode = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ public int Property3
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
[WorkItem(1934, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1934")]
public async Task SummaryInParagraphCanBeFixedAsync(string lineEnding)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestMethodWithOneLineThreeSlashCommentAsync(string lineEnding)
{
var testCode = @"public class TypeName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ namespace Bar
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestMissingFileHeaderWithLeadingTriviaAsync(string lineEnding)
{
var testCode = @"{|#0:|}#define MYDEFINE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class SA1634UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFileHeaderWithMissingCopyrightTagAsync(string lineEnding)
{
var testCode = @"{|#0://|} <author>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class SA1635UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFileHeaderWithShorthandCopyrightAsync(string lineEnding)
{
var testCode = @"// {|#0:<copyright|} file=""Test0.cs"" company=""FooCorp""/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public class SA1636UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The document line ending.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestMultilineCopyrightPreservesLineEndingsAsync(string lineEnding)
{
this.useMultiLineHeaderTestSettings = true;
Expand Down Expand Up @@ -83,8 +82,7 @@ namespace Bar
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFileHeaderWithDifferentCopyrightMessageAsync(string lineEnding)
{
var testCode = @"// {|#0:<copyright|} file=""Test0.cs"" company=""FooCorp"">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class SA1637UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestCopyrightElementWithoutFileAttributeAsync(string lineEnding)
{
var testCode = @"// {|#0:<copyright|} company=""FooCorp"">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class SA1638UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestCopyrightElementWithMismatchingFileAttributeAsync(string lineEnding)
{
var testCode = @"// {|#0:<copyright|} file=""wrongfile.cs"" company=""FooCorp"">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class SA1640UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestCopyrightElementWithoutCompanyAttributeAsync(string lineEnding)
{
var testCode = @"// {|#0:<copyright|} file=""Test0.cs"">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class SA1641UnitTests : FileHeaderTestBase
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestCopyrightElementWithWrongCompanyAttributeAsync(string lineEnding)
{
var testCode = @"// {|#0:<copyright|} file=""Test0.cs"" company=""WrongCompany"">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public class ClassName
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestTopLevelPlaceholderAsync(string lineEnding)
{
var testCode = @"namespace FooNamespace
Expand Down Expand Up @@ -97,8 +96,7 @@ public class ClassName
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestEmbeddedPlaceholderAsync(string lineEnding)
{
var testCode = @"namespace FooNamespace
Expand Down
23 changes: 7 additions & 16 deletions test/StyleCop.Analyzers.Test/Helpers/CommonData.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.Helpers
{
using Xunit;
namespace StyleCop.Analyzers.Test.Helpers;

using Xunit;

internal static class CommonData
{
public static TheoryData<string> EndOfLineSequences
{
get
{
var result = new TheoryData<string>();
result.Add("\n");
result.Add("\r\n");
return result;
}
}
}
internal static class CommonData
{
public static TheoryData<string> EndOfLineSequences =>
new TheoryData<string>("\n", "\r\n");
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestLiteralParenthesisAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ public async Task TestMethodDeclarationAsync()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestMethodDeclarationWithLineEndingAsync(string lineEnding)
{
const string keywordLine = "void {|#0:MemberName|}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public abstract class SA1402ForBlockDeclarationUnitTestsBase : FileMayOnlyContai
protected abstract bool IsConfiguredAsTopLevelTypeByDefault { get; }

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestTwoGenericElementsAsync(string lineEnding)
{
var testCode = @"%1 Foo<T1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestSuppressionWithNoJustificationAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestAdditionMultiplicationAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestOrAndAndAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestCodeFixAsync(string lineEnding)
{
var oldSource = @"public class Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public void Bar()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestCodeFixAsync(string lineEnding)
{
var oldSource = @"public class Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public async Task TestFileWithWrongEncodingAsync(int codepage)
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFileWithUtf8EncodingWithoutBOMAsync(string lineEnding)
{
var source = "class TypeName\n{\n}\n".ReplaceLineEndings(lineEnding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ void Foo()
/// <param name="lineEnding">The line ending to use in the test code.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous unit test.</returns>
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task VerifyObjectInitializerAsync(string lineEnding)
{
var testCode = @"
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1300UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public async Task TestUpperCaseNamespaceAsync()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestLowerCaseNamespaceAsync(string lineEnding)
{
var testCode = @"namespace {|#0:test|}
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1302UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace StyleCop.Analyzers.Test.NamingRules
public class SA1302UnitTests
{
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestInterfaceDeclarationDoesNotStartWithIAsync(string lineEnding)
{
var testCode = @"
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1303UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace StyleCop.Analyzers.Test.NamingRules
public class SA1303UnitTests
{
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestConstFieldStartingWithLowerCaseAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1304UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ public async Task TestFieldInNativeMethodsClassAsync()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestInternalReadonlyFieldStartingWithLowerCaseAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1306UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ public async Task TestFieldWithTrailingUnderscoreAsync()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFieldWithCodefixRenameConflictAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1307UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ public async Task TestThatDiagnosticIsReported_MultipleFieldsWithConflictAsync(s
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFieldStartingWithVerbatimIdentifierAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1308UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public async Task TestFieldStartingWithPrefixesToTriggerDiagnosticAsync()
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestMUnderscoreOnlyAsync(string lineEnding)
{
var originalCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1309UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace StyleCop.Analyzers.Test.NamingRules
public class SA1309UnitTests
{
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFieldStartingWithAnUnderscoreAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1310UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace StyleCop.Analyzers.Test.NamingRules
public class SA1310UnitTests
{
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestFieldWithUnderscoreAsync(string lineEnding)
{
var testCode = @"public class ClassName
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1311UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace StyleCop.Analyzers.Test.NamingRules
public class SA1311UnitTests
{
[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestStaticReadonlyFieldStartingWithLowerCaseAsync(string lineEnding)
{
var testCode = @"public class Foo
Expand Down
3 changes: 1 addition & 2 deletions test/StyleCop.Analyzers.Test/NamingRules/SA1312UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void MethodName(string bar, string Car)
}

[Theory]
[InlineData("\n")]
[InlineData("\r\n")]
[MemberData(nameof(CommonData.EndOfLineSequences), MemberType = typeof(CommonData))]
public async Task TestThatDiagnosticIsReported_SingleVariableAsync(string lineEnding)
{
var testCode = @"public class TypeName
Expand Down
Loading
Loading