From 0a966bf32a7fe6bf9cbadcee12cc98b50d217b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hellander?= Date: Fri, 21 Aug 2026 22:09:01 +0200 Subject: [PATCH 1/4] WIP --- StyleCop.Analyzers/Directory.Build.props | 2 +- .../SA1609CSharp15UnitTests.cs | 8 ++---- .../SA1610CSharp15UnitTests.cs | 8 ++---- .../SA1611CSharp15UnitTests.cs | 4 +-- .../SA1612CSharp15UnitTests.cs | 7 +---- .../SA1613CSharp15UnitTests.cs | 8 ++---- .../SA1614CSharp15UnitTests.cs | 8 ++---- .../SA1615CSharp15UnitTests.cs | 8 +++--- .../SA1616CSharp15UnitTests.cs | 10 +++---- .../SA1617CSharp15UnitTests.cs | 8 +++--- .../SA1625CSharp15UnitTests.cs | 10 +++---- .../SA1642CSharp15UnitTests.cs | 27 +++++++------------ .../LayoutRules/SA1501CSharp15UnitTests.cs | 8 +++--- .../LayoutRules/SA1503CSharp15UnitTests.cs | 8 +++--- .../LayoutRules/SA1504CSharp15UnitTests.cs | 8 +++--- .../LayoutRules/SA1510CSharp15UnitTests.cs | 8 +----- .../LayoutRules/SA1511CSharp15UnitTests.cs | 8 +++--- .../LayoutRules/SA1519CSharp15UnitTests.cs | 9 +++---- .../LayoutRules/SA1520CSharp15UnitTests.cs | 7 ++--- .../SA1119CSharp15UnitTests.cs | 8 +----- .../SA1404CSharp15UnitTests.cs | 7 ++--- .../SA1405CSharp15UnitTests.cs | 5 ++-- .../SA1406CSharp15UnitTests.cs | 5 ++-- .../SA1407CSharp15UnitTests.cs | 8 +++--- .../SA1408CSharp15UnitTests.cs | 8 +++--- .../SA1410CSharp15UnitTests.cs | 8 +++--- .../SA1411CSharp15UnitTests.cs | 8 +++--- .../SA1413CSharp15UnitTests.cs | 7 ++--- .../SA1414CSharp15UnitTests.cs | 7 ++--- .../NamingRules/SA1304CSharp15UnitTests.cs | 8 +++--- .../NamingRules/SA1305CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1306CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1307CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1308CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1309CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1310CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1311CSharp15UnitTests.cs | 8 +++--- .../NamingRules/SA1312CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1313CSharp15UnitTests.cs | 8 +----- .../NamingRules/SA1314CSharp15UnitTests.cs | 8 +++--- .../NamingRules/SA1316CSharp15UnitTests.cs | 8 +++--- .../NamingRules/SX1309SCSharp15UnitTests.cs | 8 +----- .../OrderingRules/SA1212CSharp15UnitTests.cs | 8 +++--- .../OrderingRules/SA1213CSharp15UnitTests.cs | 8 +++--- .../SA1100CSharp15UnitTests.cs | 8 +++--- .../SA1101CSharp15UnitTests.cs | 7 ++--- .../SA1107CSharp15UnitTests.cs | 7 ++--- .../SA1108CSharp15UnitTests.cs | 7 ++--- .../SA1112CSharp15UnitTests.cs | 8 +++--- .../SA1113CSharp15UnitTests.cs | 7 ++--- .../SA1114CSharp15UnitTests.cs | 7 ++--- .../SA1115CSharp15UnitTests.cs | 7 ++--- .../SA1116CSharp15UnitTests.cs | 7 ++--- .../SA1117CSharp15UnitTests.cs | 7 ++--- .../SA1118CSharp15UnitTests.cs | 9 +++---- .../SA1121CSharp15UnitTests.cs | 8 +++--- .../SA1122CSharp15UnitTests.cs | 8 +++--- .../SA1123CSharp15UnitTests.cs | 7 ++--- .../SA1124CSharp15UnitTests.cs | 7 ++--- .../SA1125CSharp15UnitTests.cs | 7 ++--- .../SA1128CSharp15UnitTests.cs | 8 +++--- .../SA1130CSharp15UnitTests.cs | 8 +++--- .../SA1131CSharp15UnitTests.cs | 8 +++--- .../SA1132CSharp15UnitTests.cs | 8 +++--- .../SA1133CSharp15UnitTests.cs | 7 ++--- .../SA1134CSharp15UnitTests.cs | 8 +++--- .../SA1139CSharp15UnitTests.cs | 8 +++--- .../SA1141CSharp15UnitTests.cs | 8 +++--- .../SX1101CSharp15UnitTests.cs | 8 +++--- .../SpacingRules/SA1003CSharp15UnitTests.cs | 4 +-- .../SpacingRules/SA1018CSharp15UnitTests.cs | 3 +-- .../SpacingRules/SA1026CSharp15UnitTests.cs | 4 +-- .../StyleCop.Analyzers.Test.CSharp15.csproj | 2 +- 73 files changed, 167 insertions(+), 390 deletions(-) diff --git a/StyleCop.Analyzers/Directory.Build.props b/StyleCop.Analyzers/Directory.Build.props index c61ed0e8e..0ec1bd370 100644 --- a/StyleCop.Analyzers/Directory.Build.props +++ b/StyleCop.Analyzers/Directory.Build.props @@ -50,7 +50,7 @@ - + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1609CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1609CSharp15UnitTests.cs index 7b0ff697f..a17ea1a61 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1609CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1609CSharp15UnitTests.cs @@ -22,7 +22,7 @@ public union TestUnion(string, int) /// /// A summary. /// - public static int {|#0:TestProperty|} + public static int [|TestProperty|] { get { return 42; } } @@ -45,11 +45,7 @@ public static int TestProperty } "; - // TODO: Report bug - The compiler calls the registered property declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0); - DiagnosticResult[] expected = { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1610CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1610CSharp15UnitTests.cs index 07005327a..89a13077a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1610CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1610CSharp15UnitTests.cs @@ -21,18 +21,14 @@ public union TestUnion(string, int) /// /// /// - public static int {|#0:TestProperty|} + public static int [|TestProperty|] { get { return 42; } } } "; - // TODO: Report bug - The compiler calls the registered property declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0); - DiagnosticResult[] expected = { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1611CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1611CSharp15UnitTests.cs index 1fa1e8e0a..99029ed7e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1611CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1611CSharp15UnitTests.cs @@ -27,9 +27,7 @@ public static void TestMethod(int {|#0:value|}) } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0).WithArguments("value"); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; + var expected = new[] { Diagnostic().WithLocation(0).WithArguments("value") }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1612CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1612CSharp15UnitTests.cs index 5262f2d81..242fb91da 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1612CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1612CSharp15UnitTests.cs @@ -29,14 +29,9 @@ public static void TestMethod(int first, int second) } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times var expectedDiagnostic1 = Diagnostic().WithMessageFormat("The parameter documentation for '{0}' should be at position {1}").WithLocation(0).WithArguments("second", "2"); var expectedDiagnostic2 = Diagnostic().WithMessageFormat("The parameter documentation for '{0}' should be at position {1}").WithLocation(1).WithArguments("first", "1"); - var expected = new[] - { - expectedDiagnostic1, expectedDiagnostic1, expectedDiagnostic1, - expectedDiagnostic2, expectedDiagnostic2, expectedDiagnostic2, - }; + var expected = new[] { expectedDiagnostic1, expectedDiagnostic2 }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1613CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1613CSharp15UnitTests.cs index 6a0ef6710..48b8c8a8c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1613CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1613CSharp15UnitTests.cs @@ -21,18 +21,14 @@ public union TestUnion(string, int) /// /// A summary. /// - /// {|#0:A value.|} + /// [|A value.|] public static void TestMethod(int value) { } } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1614CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1614CSharp15UnitTests.cs index 0ec115cc8..37c8e852c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1614CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1614CSharp15UnitTests.cs @@ -21,18 +21,14 @@ public union TestUnion(string, int) /// /// A summary. /// - /// {|#0:|} + /// [||] public static void TestMethod(int value) { } } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1615CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1615CSharp15UnitTests.cs index e0bcf24e8..a0b5bd842 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1615CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1615CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.DocumentationRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.DocumentationRules.SA1615ElementReturnValueMustBeDocumented, @@ -21,7 +22,7 @@ public union TestUnion(string, int) /// /// A summary. /// - public static {|#0:int|} TestMethod() + public static [|int|] TestMethod() { return 0; } @@ -42,10 +43,7 @@ public static int TestMethod() } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1616CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1616CSharp15UnitTests.cs index 34337437b..f7f21019c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1616CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1616CSharp15UnitTests.cs @@ -21,9 +21,9 @@ public union TestUnion(string, int) /// /// A summary. /// - /// {|#0: + /// [| /// - /// |} + /// |] public static int TestMethod() { return 0; @@ -31,11 +31,7 @@ public static int TestMethod() } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1617CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1617CSharp15UnitTests.cs index e4fdc2e14..91f077d94 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1617CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1617CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.DocumentationRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.DocumentationRules.SA1617VoidReturnValueMustNotBeDocumented, @@ -21,7 +22,7 @@ public union TestUnion(string, int) /// /// A summary. /// - /// {|#0:A value.|} + /// [|A value.|] public static void TestMethod() { } @@ -40,10 +41,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1625CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1625CSharp15UnitTests.cs index a35f1784d..f96dc5b1e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1625CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1625CSharp15UnitTests.cs @@ -21,20 +21,16 @@ public union TestUnion(string, int) /// /// Some documentation. /// - /// {|#0: + /// [| /// Some documentation. - /// |} + /// |] public static void TestMethod() { } } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expectedDiagnostic = Diagnostic().WithLocation(0); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1642CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1642CSharp15UnitTests.cs index 8ea184d58..bca18e321 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1642CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/DocumentationRules/SA1642CSharp15UnitTests.cs @@ -34,13 +34,12 @@ static TestUnion() [Fact] public async Task TestUnionStaticConstructorWithClassWordingAsync() { - // TODO: Report bug - The compiler calls the registered constructor action three times var testCode = @" public union TestUnion(string, int) { - /// {|#0: + /// [| /// Initializes static members of the class. - /// |} + /// |] static TestUnion() { } @@ -60,9 +59,7 @@ static TestUnion() } "; - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } [Fact] @@ -87,13 +84,12 @@ public TestUnion() [Fact] public async Task TestUnionInstanceConstructorWithClassWordingAsync() { - // TODO: Report bug - The compiler calls the registered constructor action three times var testCode = @" public union TestUnion(string, int) { - /// {|#0: + /// [| /// Initializes a new instance of the class. - /// |} + /// |] public TestUnion() : this(string.Empty) { @@ -115,21 +111,18 @@ public TestUnion() } "; - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } [Fact] public async Task TestGenericUnionStaticConstructorWithClassWordingAsync() { - // TODO: Report bug - The compiler calls the registered constructor action three times var testCode = @" public union TestUnion(T, int) { - /// {|#0: + /// [| /// Initializes static members of the class. - /// |} + /// |] static TestUnion() { } @@ -149,9 +142,7 @@ static TestUnion() } "; - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1501CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1501CSharp15UnitTests.cs index 22c805163..23eeb4522 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1501CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1501CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1501StatementMustNotBeOnASingleLine, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - lock (new object()) {|#0:{|} System.Diagnostics.Debug.Assert(true); } + lock (new object()) [|{|] System.Diagnostics.Debug.Assert(true); } } } "; @@ -38,10 +39,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered block action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1503CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1503CSharp15UnitTests.cs index 5ece9b10b..ea520dd82 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1503CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1503CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1503BracesMustNotBeOmitted, @@ -21,7 +22,7 @@ public union TestUnion(string, int) public static void TestMethod() { if (true) - {|#0:System.Diagnostics.Debug.Assert(true);|} + [|System.Diagnostics.Debug.Assert(true);|] } } "; @@ -39,10 +40,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered if statement action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1504CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1504CSharp15UnitTests.cs index 428b24ea3..32aeacdb9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1504CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1504CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1504AllAccessorsMustBeSingleLineOrMultiLine, @@ -22,7 +23,7 @@ public union TestUnion(string, int) public static int TestProperty { - {|#0:get|} { return backingField; } + [|get|] { return backingField; } set { @@ -45,10 +46,7 @@ public static int TestProperty } "; - // TODO: Report bug - The compiler calls the registered property declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1510CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1510CSharp15UnitTests.cs index 14d3fb4d5..eaf7a0413 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1510CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1510CSharp15UnitTests.cs @@ -46,13 +46,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered else clause action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("else"), - Diagnostic().WithLocation(0).WithArguments("else"), - Diagnostic().WithLocation(0).WithArguments("else"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("else"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1511CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1511CSharp15UnitTests.cs index 4be31720a..c0659e9c8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1511CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1511CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1511WhileDoFooterMustNotBePrecededByBlankLine, @@ -24,7 +25,7 @@ public static void TestMethod() { } - {|#0:while|} (true); + [|while|] (true); } } "; @@ -42,10 +43,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered do statement action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1519CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1519CSharp15UnitTests.cs index 2917ce1ab..f53dcebcf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1519CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1519CSharp15UnitTests.cs @@ -21,16 +21,13 @@ public union TestUnion(string, int) public static void TestMethod() { if (true) - {|#0:System.Diagnostics.Debug.Assert( - true);|} + [|System.Diagnostics.Debug.Assert( + true);|] } } "; - // TODO: Report bug - The compiler calls the registered if statement action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1520CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1520CSharp15UnitTests.cs index 11f4ce6a0..9f88a4710 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1520CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/LayoutRules/SA1520CSharp15UnitTests.cs @@ -25,15 +25,12 @@ public static void TestMethod() System.Diagnostics.Debug.Assert(false); } else - {|#0:System.Diagnostics.Debug.Assert(false);|} + [|System.Diagnostics.Debug.Assert(false);|] } } "; - // TODO: Report bug - The compiler calls the registered if statement action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1119CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1119CSharp15UnitTests.cs index 8dcbe1f83..507fe774a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1119CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1119CSharp15UnitTests.cs @@ -37,16 +37,10 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered parenthesized expression action three times DiagnosticResult mainDiagnostic = Diagnostic(SA1119StatementMustNotUseUnnecessaryParenthesis.DiagnosticId).WithSpan(6, 17, 6, 24); DiagnosticResult openParenDiagnostic = Diagnostic(SA1119StatementMustNotUseUnnecessaryParenthesis.ParenthesesDiagnosticId).WithLocation(6, 17); DiagnosticResult closeParenDiagnostic = Diagnostic(SA1119StatementMustNotUseUnnecessaryParenthesis.ParenthesesDiagnosticId).WithLocation(6, 23); - var expected = new[] - { - mainDiagnostic, openParenDiagnostic, closeParenDiagnostic, - mainDiagnostic, openParenDiagnostic, closeParenDiagnostic, - mainDiagnostic, openParenDiagnostic, closeParenDiagnostic, - }; + var expected = new[] { mainDiagnostic, openParenDiagnostic, closeParenDiagnostic }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1404CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1404CSharp15UnitTests.cs index 7246035b5..877860932 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1404CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1404CSharp15UnitTests.cs @@ -18,17 +18,14 @@ public async Task TestUnionMethodWithSuppressionMissingJustificationAsync() var testCode = @" public union TestUnion(string, int) { - [{|#0:System.Diagnostics.CodeAnalysis.SuppressMessage(null, null)|}] + [[|System.Diagnostics.CodeAnalysis.SuppressMessage(null, null)|]] public static void TestMethod() { } } "; - // TODO: Report bug - The compiler calls the registered attribute action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1405CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1405CSharp15UnitTests.cs index 637048daf..7c0868c94 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1405CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1405CSharp15UnitTests.cs @@ -19,13 +19,12 @@ public union TestUnion(string, int) { public static void TestMethod() { - {|#0:Debug.Assert(true)|}; + [|Debug.Assert(true)|]; } } "; - // TODO: Report bug - The compiler calls the registered invocation expression action three times - var expected = new[] { this.Diagnostic().WithLocation(0), this.Diagnostic().WithLocation(0), this.Diagnostic().WithLocation(0) }; + var expected = DiagnosticResult.EmptyDiagnosticResults; await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1406CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1406CSharp15UnitTests.cs index 6e1da57df..0e9451062 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1406CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1406CSharp15UnitTests.cs @@ -19,13 +19,12 @@ public union TestUnion(string, int) { public static void TestMethod() { - {|#0:Debug.Fail("""")|}; + [|Debug.Fail("""")|]; } } "; - // TODO: Report bug - The compiler calls the registered invocation expression action three times - var expected = new[] { this.Diagnostic().WithLocation(0), this.Diagnostic().WithLocation(0), this.Diagnostic().WithLocation(0) }; + var expected = DiagnosticResult.EmptyDiagnosticResults; await this.VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1407CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1407CSharp15UnitTests.cs index 70a0eab97..90403aafb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1407CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1407CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1407ArithmeticExpressionsMustDeclarePrecedence, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - int x = 1 + {|#0:1 * 1|}; + int x = 1 + [|1 * 1|]; } } "; @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered binary expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1408CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1408CSharp15UnitTests.cs index bc8c60a15..16e785dcb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1408CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1408CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1408ConditionalExpressionsMustDeclarePrecedence, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - bool x = true || {|#0:false && true|}; + bool x = true || [|false && true|]; } } "; @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered binary expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1410CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1410CSharp15UnitTests.cs index a379fafbe..b4fc04c3c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1410CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1410CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1410RemoveDelegateParenthesisWhenPossible, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - System.Func getNumber = delegate{|#0:()|} { return 3; }; + System.Func getNumber = delegate[|()|] { return 3; }; } } "; @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered anonymous method expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1411CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1411CSharp15UnitTests.cs index a955ab20e..0e57ce325 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1411CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1411CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis, @@ -18,7 +19,7 @@ public async Task TestUnionMethodAttributeWithUnnecessaryParenthesisAsync() var testCode = @" public union TestUnion(string, int) { - [System.Obsolete{|#0:()|}] + [System.Obsolete[|()|]] public static void TestMethod() { } @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered attribute argument list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1413CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1413CSharp15UnitTests.cs index efdce988d..e5291d980 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1413CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1413CSharp15UnitTests.cs @@ -82,7 +82,7 @@ public union TestUnion(string, int) public static int[] TestField = new int[] { 1, - {|#0:2|} + [|2|] }; } "; @@ -98,10 +98,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered object initializer action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1414CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1414CSharp15UnitTests.cs index 3f6e53555..3488004f4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1414CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/MaintainabilityRules/SA1414CSharp15UnitTests.cs @@ -18,14 +18,11 @@ public async Task TestUnionMethodTupleReturnTypeMissingElementNameAsync() var testCode = @" public union TestUnion(string, int) { - public static (int First, {|#0:int|}) TestMethod() => (1, 2); + public static (int First, [|int|]) TestMethod() => (1, 2); } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1304CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1304CSharp15UnitTests.cs index e76f24b8e..d393ff923 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1304CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1304CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.NamingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter, @@ -18,7 +19,7 @@ public async Task TestUnionNonPrivateReadonlyFieldStartingWithLowerCaseLetterAsy var testCode = @" public union TestUnion(string, int) { - internal static readonly int {|#0:myField|} = 1; + internal static readonly int [|myField|] = 1; } "; @@ -29,10 +30,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1305CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1305CSharp15UnitTests.cs index 66dbf5b42..2004c8166 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1305CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1305CSharp15UnitTests.cs @@ -22,13 +22,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered variable declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("field", "nCount"), - Diagnostic().WithLocation(0).WithArguments("field", "nCount"), - Diagnostic().WithLocation(0).WithArguments("field", "nCount"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("field", "nCount"); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1306CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1306CSharp15UnitTests.cs index fd3f58468..cde9dbcc2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1306CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1306CSharp15UnitTests.cs @@ -29,13 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("MyField"), - Diagnostic().WithLocation(0).WithArguments("MyField"), - Diagnostic().WithLocation(0).WithArguments("MyField"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("MyField"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1307CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1307CSharp15UnitTests.cs index f5c140507..e5215a6da 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1307CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1307CSharp15UnitTests.cs @@ -29,13 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("myField"), - Diagnostic().WithLocation(0).WithArguments("myField"), - Diagnostic().WithLocation(0).WithArguments("myField"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("myField"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1308CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1308CSharp15UnitTests.cs index 9dd9c9c29..59afd0619 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1308CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1308CSharp15UnitTests.cs @@ -29,13 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("s_myField", "s_"), - Diagnostic().WithLocation(0).WithArguments("s_myField", "s_"), - Diagnostic().WithLocation(0).WithArguments("s_myField", "s_"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("s_myField", "s_"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1309CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1309CSharp15UnitTests.cs index d5432a500..5fc2cebc6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1309CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1309CSharp15UnitTests.cs @@ -29,13 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("_myField"), - Diagnostic().WithLocation(0).WithArguments("_myField"), - Diagnostic().WithLocation(0).WithArguments("_myField"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("_myField"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1310CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1310CSharp15UnitTests.cs index bec262b16..58f146d3e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1310CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1310CSharp15UnitTests.cs @@ -29,13 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("my_Field"), - Diagnostic().WithLocation(0).WithArguments("my_Field"), - Diagnostic().WithLocation(0).WithArguments("my_Field"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("my_Field"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1311CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1311CSharp15UnitTests.cs index 51c9b268a..1553ad104 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1311CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1311CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.NamingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter, @@ -18,7 +19,7 @@ public async Task TestUnionStaticReadonlyFieldStartingWithLowerCaseLetterAsync() var testCode = @" public union TestUnion(string, int) { - private static readonly int {|#0:myField|} = 1; + private static readonly int [|myField|] = 1; } "; @@ -29,10 +30,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1312CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1312CSharp15UnitTests.cs index 295d07a6b..371aeaf76 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1312CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1312CSharp15UnitTests.cs @@ -35,13 +35,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered variable declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("MyVariable"), - Diagnostic().WithLocation(0).WithArguments("MyVariable"), - Diagnostic().WithLocation(0).WithArguments("MyVariable"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("MyVariable"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1313CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1313CSharp15UnitTests.cs index 79faa19a5..7fbdc4275 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1313CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1313CSharp15UnitTests.cs @@ -33,13 +33,7 @@ public static void TestMethod(int myParameter) } "; - // TODO: Report bug - The compiler calls the registered parameter action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("MyParameter"), - Diagnostic().WithLocation(0).WithArguments("MyParameter"), - Diagnostic().WithLocation(0).WithArguments("MyParameter"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("MyParameter"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1314CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1314CSharp15UnitTests.cs index 4847b1b70..3d3331b98 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1314CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1314CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.NamingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1314TypeParameterNamesMustBeginWithT, @@ -18,7 +19,7 @@ public async Task TestUnionMethodTypeParameterNotStartingWithTAsync() var testCode = @" public union TestUnion(string, int) { - public static void TestMethod<{|#0:X|}>() + public static void TestMethod<[|X|]>() { } } @@ -33,10 +34,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered type parameter action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1316CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1316CSharp15UnitTests.cs index f8a975970..b05a5ccca 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1316CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SA1316CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.NamingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1316TupleElementNamesShouldUseCorrectCasing, @@ -18,7 +19,7 @@ public async Task TestUnionTupleElementNameStartingWithLowerCaseLetterAsync() var testCode = @" public union TestUnion(string, int) { - public static (int {|#0:value|}, int Other) TestMethod() => (1, 2); + public static (int [|value|], int Other) TestMethod() => (1, 2); } "; @@ -29,10 +30,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered tuple type action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SX1309SCSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SX1309SCSharp15UnitTests.cs index b03d7804c..b7e5a67e9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SX1309SCSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/NamingRules/SX1309SCSharp15UnitTests.cs @@ -29,13 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] - { - Diagnostic().WithLocation(0).WithArguments("myField"), - Diagnostic().WithLocation(0).WithArguments("myField"), - Diagnostic().WithLocation(0).WithArguments("myField"), - }; + var expected = Diagnostic().WithLocation(0).WithArguments("myField"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1212CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1212CSharp15UnitTests.cs index 5e48e8906..76d9d5d42 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1212CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1212CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.OrderingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1212PropertyAccessorsMustFollowOrder, @@ -22,7 +23,7 @@ public union TestUnion(string, int) public static int MyValue { - {|#0:set { backingValue = value; }|} + [|set { backingValue = value; }|] get { return backingValue; } } } @@ -41,10 +42,7 @@ public static int MyValue } "; - // TODO: Report bug - The compiler calls the registered property declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1213CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1213CSharp15UnitTests.cs index 04cd1ae72..5dd4c03be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1213CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/OrderingRules/SA1213CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.OrderingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1213EventAccessorsMustFollowOrder, @@ -22,7 +23,7 @@ public union TestUnion(string, int) public static event System.EventHandler MyEvent { - {|#0:remove|} { backingEvent -= value; } + [|remove|] { backingEvent -= value; } add { backingEvent += value; } } } @@ -41,10 +42,7 @@ public static event System.EventHandler MyEvent } "; - // TODO: Report bug - The compiler calls the registered event declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1100CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1100CSharp15UnitTests.cs index e31e35c7f..2dc41c7bf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1100CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1100CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public string TestMethod() { - return {|#0:base|}.ToString(); + return [|base|].ToString(); } } "; @@ -35,10 +36,7 @@ public string TestMethod() } "; - // TODO: Report bug - The compiler calls the registered base expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1101CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1101CSharp15UnitTests.cs index 098a48fd5..86e883cbd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1101CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1101CSharp15UnitTests.cs @@ -60,7 +60,6 @@ public void TestMethod() [InlineData("MyInstanceFunc", "()")] public async Task TestUnionReferencingOwnMemberWithDiagnosticAsync(string name, string suffix = "") { - // TODO: Report bug - The compiler calls the registered member access action three times var testCode = $@" public union TestUnion(string, int) {{ @@ -69,7 +68,7 @@ public union TestUnion(string, int) public void TestMethod() {{ - _ = {{|#0:{name}|}}{suffix}; + _ = [|{name}|]{suffix}; }} }} "; @@ -87,9 +86,7 @@ public void TestMethod() }} "; - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } [Theory] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1107CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1107CSharp15UnitTests.cs index a671e7c2e..3d58341a4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1107CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1107CSharp15UnitTests.cs @@ -20,15 +20,12 @@ public union TestUnion(string, int) { public static void TestMethod() { - int a = 1; {|#0:int b = 2;|} + int a = 1; [|int b = 2;|] } } "; - // TODO: Report bug - The compiler calls the registered block action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1108CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1108CSharp15UnitTests.cs index 20f5d0b9c..350ad61e6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1108CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1108CSharp15UnitTests.cs @@ -21,17 +21,14 @@ public union TestUnion(string, int) public static void TestMethod() { if (true) - {|#0:// comment|} + [|// comment|] { } } } "; - // TODO: Report bug - The compiler calls the registered block action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1112CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1112CSharp15UnitTests.cs index e9490c237..df08dc114 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1112CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1112CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis, @@ -19,7 +20,7 @@ public async Task TestUnionMethodClosingParenthesisNotOnLineOfOpeningParenthesis public union TestUnion(string, int) { public static void TestMethod( -{|#0:)|} +[|)|] { } } @@ -34,10 +35,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1113CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1113CSharp15UnitTests.cs index 1e9579ac4..418bc21ce 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1113CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1113CSharp15UnitTests.cs @@ -52,7 +52,7 @@ public async Task TestUnionMethodCommaNotOnSameLineAsPreviousParameterAsync() public union TestUnion(string, int) { public static void TestMethod(string s - {|#0:,|} int i) + [|,|] int i) { } } @@ -68,10 +68,7 @@ public static void TestMethod(string s, } "; - // TODO: Report bug - The compiler calls the registered token action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1114CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1114CSharp15UnitTests.cs index 3a5af2c22..4e61b534c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1114CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1114CSharp15UnitTests.cs @@ -57,16 +57,13 @@ public union TestUnion(string, int) { public static void TestMethod( -{|#0:string s|}) +[|string s|]) { } } "; - // TODO: Report bug - The compiler calls the registered method declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1115CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1115CSharp15UnitTests.cs index 4df035277..d3719b608 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1115CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1115CSharp15UnitTests.cs @@ -61,7 +61,7 @@ public static void TestMethod() { Fun(10, - {|#0:20|}); + [|20|]); } private static void Fun(int a, int b) @@ -70,10 +70,7 @@ private static void Fun(int a, int b) } "; - // TODO: Report bug - The compiler calls the registered argument list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1116CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1116CSharp15UnitTests.cs index ba10c7eba..fc08a3ce0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1116CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1116CSharp15UnitTests.cs @@ -54,7 +54,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - Fun({|#0:10|}, + Fun([|10|], 20); } @@ -80,10 +80,7 @@ private static void Fun(int a, int b) } "; - // TODO: Report bug - The compiler calls the registered argument list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1117CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1117CSharp15UnitTests.cs index 5d799ba04..a01515fd1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1117CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1117CSharp15UnitTests.cs @@ -61,7 +61,7 @@ public union TestUnion(string, int) public static void TestMethod() { Fun(1, 10, - {|#0:20|}); + [|20|]); } private static void Fun(int a, int b, int c) @@ -70,10 +70,7 @@ private static void Fun(int a, int b, int c) } "; - // TODO: Report bug - The compiler calls the registered argument list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1118CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1118CSharp15UnitTests.cs index 3fded35e6..6b89c8ee2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1118CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1118CSharp15UnitTests.cs @@ -60,8 +60,8 @@ public union TestUnion(string, int) public static void TestMethod() { Fun(10, - {|#0:""a"" + - ""b""|}); + [|""a"" + + ""b""|]); } private static void Fun(int a, string b) @@ -70,10 +70,7 @@ private static void Fun(int a, string b) } "; - // TODO: Report bug - The compiler calls the registered argument list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1121CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1121CSharp15UnitTests.cs index 53d3c45a0..3c419dfd9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1121CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1121CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1121UseBuiltInTypeAlias, @@ -18,7 +19,7 @@ public async Task TestUnionFieldWithNonAliasTypeAsync() var testCode = @" public union TestUnion(string, int) { - private static {|#0:System.Int32|} field; + private static [|System.Int32|] field; } "; @@ -29,10 +30,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered predefined/identifier name action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1122CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1122CSharp15UnitTests.cs index 4b03414cb..8a8a856d4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1122CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1122CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1122UseStringEmptyForEmptyStrings, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - string test = {|#0:""""|}; + string test = [|""""|]; } } "; @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered literal expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1123CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1123CSharp15UnitTests.cs index 5e906c53e..a77362c7e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1123CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1123CSharp15UnitTests.cs @@ -20,17 +20,14 @@ public union TestUnion(string, int) { public static void TestMethod() { -{|#0:#region Foo|} +[|#region Foo|] string test = """"; #endregion } } "; - // TODO: Report bug - The compiler calls the registered region directive action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1124CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1124CSharp15UnitTests.cs index 43de3a93a..eb2755a24 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1124CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1124CSharp15UnitTests.cs @@ -18,7 +18,7 @@ public async Task TestUnionWithRegionAsync() var testCode = @" public union TestUnion(string, int) { -{|#0:#region Foo|} +[|#region Foo|] public static void TestMethod() { } @@ -26,10 +26,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered region directive action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1125CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1125CSharp15UnitTests.cs index 3bf0d8d7d..c47400ef4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1125CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1125CSharp15UnitTests.cs @@ -18,14 +18,11 @@ public async Task TestUnionFieldWithLongFormNullableTypeAsync() var testCode = @" public union TestUnion(string, int) { - private static {|#0:System.Nullable|} field; + private static [|System.Nullable|] field; } "; - // TODO: Report bug - The compiler calls the registered generic name action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1128CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1128CSharp15UnitTests.cs index 40b381a37..7bdfcfbc7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1128CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1128CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1128ConstructorInitializerMustBeOnOwnLine, @@ -18,7 +19,7 @@ public async Task TestUnionConstructorInitializerNotOnOwnLineAsync() var testCode = @" public union TestUnion(string, int) { - public TestUnion() {|#0:: this(string.Empty)|} + public TestUnion() [|: this(string.Empty)|] { } } @@ -34,10 +35,7 @@ public TestUnion() } "; - // TODO: Report bug - The compiler calls the registered constructor declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1130CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1130CSharp15UnitTests.cs index 9023710c1..78fc66c39 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1130CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1130CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1130UseLambdaSyntax, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - System.Action action = {|#0:delegate|} { }; + System.Action action = [|delegate|] { }; } } "; @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered anonymous method expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1131CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1131CSharp15UnitTests.cs index 1011feb10..9eb0cb798 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1131CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1131CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1131UseReadableConditions, @@ -21,7 +22,7 @@ public union TestUnion(string, int) public static void TestMethod() { int i = 5; - if ({|#0:5 == i|}) + if ([|5 == i|]) { } } @@ -41,10 +42,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered binary expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1132CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1132CSharp15UnitTests.cs index 5e41db30c..7e1bbef28 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1132CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1132CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1132DoNotCombineFields, @@ -18,7 +19,7 @@ public async Task TestUnionCombinedFieldsAsync() var testCode = @" public union TestUnion(string, int) { - {|#0:private static int a, b;|} + [|private static int a, b;|] } "; @@ -30,10 +31,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered field declaration action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1133CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1133CSharp15UnitTests.cs index 03bf135d4..dc23dad0d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1133CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1133CSharp15UnitTests.cs @@ -18,17 +18,14 @@ public async Task TestUnionMethodCombinedAttributesAsync() var testCode = @" public union TestUnion(string, int) { - [System.Obsolete, {|#0:System.CLSCompliant|}(true)] + [System.Obsolete, [|System.CLSCompliant|](true)] public static void TestMethod() { } } "; - // TODO: Report bug - The compiler calls the registered attribute list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(true); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1134CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1134CSharp15UnitTests.cs index aba47b0e6..7aab797ae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1134CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1134CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1134AttributesMustNotShareLine, @@ -18,7 +19,7 @@ public async Task TestUnionMethodAttributesShareLineAsync() var testCode = @" public union TestUnion(string, int) { - [System.Obsolete] {|#0:[|}System.CLSCompliant(true)] + [System.Obsolete] [|[|]System.CLSCompliant(true)] public static void TestMethod() { } @@ -36,10 +37,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered attribute list action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1139CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1139CSharp15UnitTests.cs index c80d8263a..99c54ddd4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1139CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1139CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1139UseLiteralSuffixNotationInsteadOfCasting, @@ -20,7 +21,7 @@ public union TestUnion(string, int) { public static void TestMethod() { - var x = {|#0:(long)5|}; + var x = [|(long)5|]; } } "; @@ -35,10 +36,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered cast expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1141CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1141CSharp15UnitTests.cs index 575613372..405c0fb87 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1141CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SA1141CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1141UseTupleSyntax, @@ -20,7 +21,7 @@ public async Task TestUnionMethodValueTupleTypeAsync() public union TestUnion(string, int) { - public static {|#0:ValueTuple|} TestMethod() + public static [|ValueTuple|] TestMethod() { return default; } @@ -39,10 +40,7 @@ public static (int, int) TestMethod() } "; - // TODO: Report bug - The compiler calls the registered generic name action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SX1101CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SX1101CSharp15UnitTests.cs index 208271817..840379bc9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SX1101CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/ReadabilityRules/SX1101CSharp15UnitTests.cs @@ -5,6 +5,7 @@ namespace StyleCop.Analyzers.Test.CSharp15.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.CSharp6.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SX1101DoNotPrefixLocalMembersWithThis, @@ -22,7 +23,7 @@ public union TestUnion(string, int) public int TestMethod() { - return {|#0:this|}.MyProperty; + return [|this|].MyProperty; } } "; @@ -39,10 +40,7 @@ public int TestMethod() } "; - // TODO: Report bug - The compiler calls the registered this expression action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; - - await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(true); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1003CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1003CSharp15UnitTests.cs index d3d288144..ed094ffe6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1003CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1003CSharp15UnitTests.cs @@ -35,9 +35,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered binary expression action three times - var expectedDiagnostic = Diagnostic().WithMessageFormat("Operator '{0}' should be followed by whitespace.").WithLocation(0).WithArguments("&&"); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; + var expected = Diagnostic().WithMessageFormat("Operator '{0}' should be followed by whitespace.").WithLocation(0).WithArguments("&&"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1018CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1018CSharp15UnitTests.cs index bc41d375f..3235a6aa1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1018CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1018CSharp15UnitTests.cs @@ -29,8 +29,7 @@ public union TestUnion(string, int) } "; - // TODO: Report bug - The compiler calls the registered nullable type action three times - var expected = new[] { Diagnostic().WithLocation(0), Diagnostic().WithLocation(0), Diagnostic().WithLocation(0) }; + var expected = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1026CSharp15UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1026CSharp15UnitTests.cs index a817d1a95..7ae492097 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1026CSharp15UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/SpacingRules/SA1026CSharp15UnitTests.cs @@ -35,9 +35,7 @@ public static void TestMethod() } "; - // TODO: Report bug - The compiler calls the registered implicit array creation expression action three times - var expectedDiagnostic = Diagnostic().WithArguments("new").WithLocation(0); - var expected = new[] { expectedDiagnostic, expectedDiagnostic, expectedDiagnostic }; + var expected = Diagnostic().WithArguments("new").WithLocation(0); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(true); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj index 007a1dc7e..ce6e56ed7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj @@ -14,7 +14,7 @@ - + From 550b62b9376e19e882c0ef6bcdb3f9cecd79e916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hellander?= Date: Sat, 22 Aug 2026 10:56:18 +0200 Subject: [PATCH 2/4] WIP2 --- .../StyleCop.Analyzers/AnalyzerExtensions.cs | 16 ++++++---------- .../ElementDocumentationBase.cs | 5 +---- .../ElementDocumentationSummaryBase.cs | 5 +---- .../GenericTypeParameterDocumentationAnalyzer.cs | 5 +---- .../PartialElementDocumentationSummaryBase.cs | 5 +---- .../SA1600ElementsMustBeDocumented.cs | 5 +---- .../SA1601PartialElementsMustBeDocumented.cs | 5 +---- ...A1618GenericTypeParametersMustBeDocumented.cs | 5 +---- ...TypeParametersMustBeDocumentedPartialClass.cs | 4 +--- ...648InheritDocMustBeUsedWithInheritingClass.cs | 5 +---- ...acesForMultiLineStatementsMustNotShareLine.cs | 5 +---- .../SA1502ElementMustNotBeOnASingleLine.cs | 5 +---- ...5OpeningBracesMustNotBeFollowedByBlankLine.cs | 5 +---- ...ntationHeadersMustNotBeFollowedByBlankLine.cs | 4 +--- ...8ClosingBracesMustNotBePrecededByBlankLine.cs | 5 +---- ...cumentationHeaderMustBePrecededByBlankLine.cs | 4 +--- .../SA1516ElementsMustBeSeparatedByBlankLine.cs | 5 +---- .../SA1400AccessModifierMustBeDeclared.cs | 5 +---- .../SA1300ElementMustBeginWithUpperCaseLetter.cs | 5 +---- .../SA1201ElementsMustAppearInTheCorrectOrder.cs | 4 +--- .../SA1202ElementsMustBeOrderedByAccess.cs | 4 +--- .../SA1203ConstantsMustAppearBeforeFields.cs | 4 +--- ...icElementsMustAppearBeforeInstanceElements.cs | 4 +--- .../SA1205PartialElementsMustDeclareAccess.cs | 4 +--- .../SA1206DeclarationKeywordsMustFollowOrder.cs | 4 +--- .../SA1207ProtectedMustComeBeforeInternal.cs | 4 +--- ...lementsMustAppearBeforeNonReadonlyElements.cs | 4 +--- .../SA1106CodeMustNotContainEmptyStatements.cs | 5 +---- ...0OpeningParenthesisMustBeOnDeclarationLine.cs | 5 +---- ...singParenthesisMustBeOnLineOfLastParameter.cs | 5 +---- ...SA1137ElementsShouldHaveTheSameIndentation.cs | 5 +---- 31 files changed, 36 insertions(+), 119 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs index f1fe2781c..1de3db931 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs @@ -85,18 +85,15 @@ StrongBox GetOrCreateSettingsStorage(SyntaxTree tree) /// /// Register an action to be executed at completion of semantic analysis of a with /// the given , guarding against the analyzer driver invoking the action more - /// than once for the same node. This is a workaround for a Roslyn quirk currently observed for very new - /// experimental values (e.g. - /// ), where the analyzer driver - /// dispatches the identical node twice within a single analysis pass. + /// than once for the same node. /// /// The analysis context. /// Action to be executed at completion of semantic analysis of a /// . - /// The (experimental) kind of syntax that should be analyzed. + /// The kind of syntax that should be analyzed. /// Enum type giving the syntax node kinds of the source language for which /// the action applies. - // TODO: Remove these methods when it's no longer needed (c# 15 officially supported) + [Obsolete("This should only be used temporarily when Roslyn is buggy and calls an action multiple times for the same node")] public static void RegisterSyntaxNodeActionWithDuplicateNodeGuard(this CompilationStartAnalysisContext context, Action action, TLanguageKindEnum syntaxKind) where TLanguageKindEnum : struct { @@ -115,16 +112,15 @@ public static void RegisterSyntaxNodeActionWithDuplicateNodeGuard /// Register an action to be executed at completion of semantic analysis of a with /// the given , guarding against the analyzer driver invoking the action more - /// than once for the same node. See - /// - /// for details on why this guard is needed. + /// than once for the same node. /// /// The analysis context. /// Action to be executed at completion of semantic analysis of a /// . - /// The (experimental) kind of syntax that should be analyzed. + /// The kind of syntax that should be analyzed. /// Enum type giving the syntax node kinds of the source language for which /// the action applies. + [Obsolete("This should only be used temporarily when Roslyn is buggy and calls an action multiple times for the same node")] public static void RegisterSyntaxNodeActionWithDuplicateNodeGuard(this CompilationStartAnalysisContext context, Action action, TLanguageKindEnum syntaxKind) where TLanguageKindEnum : struct { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs index e69777b22..f6a00b9d5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs @@ -61,10 +61,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(this.operatorDeclarationAction, SyntaxKind.OperatorDeclaration); context.RegisterSyntaxNodeAction(this.conversionOperatorDeclarationAction, SyntaxKind.ConversionOperatorDeclaration); context.RegisterSyntaxNodeAction(this.baseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(this.baseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(this.baseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(this.fieldDeclarationAction, SyntaxKind.FieldDeclaration); context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); context.RegisterSyntaxNodeAction(this.enumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs index fb92d21a0..7b158ab6d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs @@ -46,10 +46,7 @@ protected ElementDocumentationSummaryBase() protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(this.typeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(this.constructorDeclarationAction, SyntaxKind.ConstructorDeclaration); context.RegisterSyntaxNodeAction(this.destructorDeclarationAction, SyntaxKind.DestructorDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs index b649ea9c0..9f28ef07f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs @@ -76,10 +76,7 @@ internal class GenericTypeParameterDocumentationAnalyzer : DiagnosticAnalyzerBas protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs index ae7cecc52..2f68b2f19 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs @@ -38,10 +38,7 @@ protected PartialElementDocumentationSummaryBase() protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(this.typeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); context.RegisterSyntaxNodeAction(this.indexerDeclarationAction, SyntaxKind.IndexerDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs index 2f099df2b..058fd7008 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs @@ -105,10 +105,7 @@ public static bool NeedsComment(DocumentationSettings documentationSettings, Syn protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(ConstructorDeclarationAction, SyntaxKind.ConstructorDeclaration); context.RegisterSyntaxNodeAction(DestructorDeclarationAction, SyntaxKind.DestructorDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs index a521a15a5..6f056c32c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs @@ -94,10 +94,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c { // TODO: The action name relates to BaseTypeDeclaration, but the registered syntax kinds are TypeDeclaration context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs index d486c39b8..a3f45fdf3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs @@ -51,10 +51,7 @@ internal class SA1618GenericTypeParametersMustBeDocumented : DiagnosticAnalyzerB protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs index 8f60ac8ed..9307bccd0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs @@ -100,9 +100,7 @@ internal class SA1619GenericTypeParametersMustBeDocumentedPartialClass : Diagnos protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs index ee31cc101..b47f39741 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs @@ -67,10 +67,7 @@ internal class SA1648InheritDocMustBeUsedWithInheritingClass : DiagnosticAnalyze protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(BaseTypeLikeDeclarationAction, HandledTypeLikeDeclarationKinds); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeLikeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeLikeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(MemberDeclarationAction, MemberDeclarationKinds); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs index 6ab64cca2..88b1ee6c4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs @@ -87,10 +87,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(AccessorListAction, SyntaxKind.AccessorList); context.RegisterSyntaxNodeAction(BlockAction, SyntaxKind.Block); context.RegisterSyntaxNodeAction(SwitchStatementAction, SyntaxKind.SwitchStatement); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs index 01a2e22e4..82a978aa5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs @@ -66,10 +66,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c { context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(BasePropertyDeclarationAction, SyntaxKinds.BasePropertyDeclaration); context.RegisterSyntaxNodeAction(BaseMethodDeclarationAction, SyntaxKinds.BaseMethodDeclaration); context.RegisterSyntaxNodeAction(LocalFunctionStatementAction, SyntaxKindEx.LocalFunctionStatement); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs index 0d56eb280..d3f8ebf6d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs @@ -74,10 +74,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(AccessorListAction, SyntaxKind.AccessorList); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs index 3f300e1a3..cebae6254 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs @@ -81,9 +81,7 @@ internal class SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine : D protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(DeclarationAction, HandledSyntaxKinds); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(DeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(DeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleDeclaration(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs index e68f697ed..2cec4bef7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs @@ -74,10 +74,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(AccessorListAction, SyntaxKind.AccessorList); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs index b1d60b131..a065821ca 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs @@ -105,9 +105,7 @@ internal class SA1514ElementDocumentationHeaderMustBePrecededByBlankLine : Diagn protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(DeclarationAction, HandledSyntaxKinds); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(DeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(DeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleDeclaration(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs index a122025d8..65dd2ad5c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs @@ -121,10 +121,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); context.RegisterSyntaxNodeAction(FileScopedNamespaceDeclarationAction, SyntaxKindEx.FileScopedNamespaceDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs index 0ecabfb0b..2f3063212 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs @@ -54,10 +54,7 @@ internal class SA1400AccessModifierMustBeDeclared : DiagnosticAnalyzerBase protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); context.RegisterSyntaxNodeAction(EventDeclarationAction, SyntaxKind.EventDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs index bdf1eef95..07760ed8a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs @@ -79,10 +79,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(EnumDeclarationAction, SyntaxKind.EnumDeclaration); context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); context.RegisterSyntaxNodeAction(StructDeclarationAction, SyntaxKind.StructDeclaration); - - // Register UnionDeclaration with a duplicate-node guard, see the helper for why it is needed. - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(UnionDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(UnionDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); context.RegisterSyntaxNodeAction(EventDeclarationAction, SyntaxKind.EventDeclaration); context.RegisterSyntaxNodeAction(EventFieldDeclarationAction, SyntaxKind.EventFieldDeclaration); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs index 54113310b..3c6d62380 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs @@ -188,9 +188,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed) - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs index 2f786f72e..7a8e45723 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs @@ -82,9 +82,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed) - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs index 5ff4aa8ef..0551ea07d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs @@ -45,9 +45,7 @@ internal class SA1203ConstantsMustAppearBeforeFields : DiagnosticAnalyzerBase protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs index 80d656c11..b49f9b86e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs @@ -51,9 +51,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs index 84bdef46f..8c3dfb92a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs @@ -44,9 +44,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c { // TODO: Should this handle methods etc as well? context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs index adf748b53..758667360 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs @@ -75,9 +75,7 @@ internal class SA1206DeclarationKeywordsMustFollowOrder : DiagnosticAnalyzerBase protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(DeclarationAction, HandledSyntaxKinds); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(DeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(DeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleDeclaration(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs index 83c8d60ff..042719d8b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs @@ -64,9 +64,7 @@ internal class SA1207ProtectedMustComeBeforeInternal : DiagnosticAnalyzerBase protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(DeclarationAction, HandledSyntaxKinds); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(DeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(DeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleDeclaration(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs index 2ab2dfb56..3071ee967 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs @@ -41,9 +41,7 @@ internal class SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements : Diagn protected override void HandleCompilationStart(CompilationStartAnalysisContext context) { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs index 80347939f..edb1d11e5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs @@ -47,10 +47,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(EmptyStatementAction, SyntaxKind.EmptyStatement); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs index 60e48f0a8..e68196fe7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs @@ -75,10 +75,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(PrimaryConstructorBaseTypeAction, SyntaxKindEx.PrimaryConstructorBaseType); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(LocalFunctionStatementAction, SyntaxKindEx.LocalFunctionStatement); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs index 2d3ff9d5e..134b56ebd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs @@ -80,10 +80,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c { context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(PrimaryConstructorBaseTypeAction, SyntaxKindEx.PrimaryConstructorBaseType); context.RegisterSyntaxNodeAction(BaseMethodDeclarationAction, HandledMethodSyntaxKinds); context.RegisterSyntaxNodeAction(LocalFunctionStatementAction, SyntaxKindEx.LocalFunctionStatement); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs index 4cb30a678..f28548a3a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs @@ -61,10 +61,7 @@ protected override void HandleCompilationStart(CompilationStartAnalysisContext c context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.ExtensionBlockDeclaration); - - // Register UnionDeclaration separately (with a duplicate-node guard, see the helper for why it is needed). - context.RegisterSyntaxNodeActionWithDuplicateNodeGuard(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); - + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKindEx.UnionDeclaration); context.RegisterSyntaxNodeAction(EnumDeclarationAction, SyntaxKind.EnumDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); context.RegisterSyntaxNodeAction(AccessorListAction, SyntaxKind.AccessorList); From 65699414a3beb7c0d6c354981bb91f3830fbc065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hellander?= Date: Sat, 22 Aug 2026 11:13:12 +0200 Subject: [PATCH 3/4] WIP3 --- .../MaintainabilityRules/SA1400CodeFixProvider.cs | 2 +- .../OrderingRules/SA1205CodeFixProvider.cs | 2 +- .../StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs index 384f8288b..69c904f16 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs @@ -88,7 +88,7 @@ private static Task GetTransformedDocumentAsync(Document document, Syn updatedDeclarationNode = HandleRecordDeclaration((RecordDeclarationSyntaxWrapper)declarationNode); break; - case SyntaxKindEx.UnionDeclaration when declarationNode is not StructDeclarationSyntax: // TODO: Update when integrating the official c# 15 nuget + case SyntaxKindEx.UnionDeclaration: updatedDeclarationNode = HandleUnionDeclaration((UnionDeclarationSyntaxWrapper)declarationNode); break; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs index 56d7a39ed..f74d4e726 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs @@ -115,7 +115,7 @@ private static TypeDeclarationSyntax ReplaceModifiers(TypeDeclarationSyntax node case SyntaxKindEx.RecordDeclaration: case SyntaxKindEx.RecordStructDeclaration: return ((RecordDeclarationSyntaxWrapper)node).WithModifiers(modifiers); - case SyntaxKindEx.UnionDeclaration when node is not StructDeclarationSyntax: // TODO: Update when integrating official c# 15 nuget + case SyntaxKindEx.UnionDeclaration: return ((UnionDeclarationSyntaxWrapper)node).WithModifiers(modifiers); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs index dcf01acb4..a9497d6ac 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs @@ -167,7 +167,7 @@ internal static SyntaxNode WithModifiers(this SyntaxNode node, SyntaxTokenList m case SyntaxKindEx.RecordStructDeclaration: return ((RecordDeclarationSyntaxWrapper)node).WithModifiers(modifiers); - case SyntaxKindEx.UnionDeclaration when node is not StructDeclarationSyntax: // TODO: Update when integrating official c# 15 nuget + case SyntaxKindEx.UnionDeclaration: return ((UnionDeclarationSyntaxWrapper)node).WithModifiers(modifiers); case SyntaxKind.DelegateDeclaration: From 9ea9879edfcbe9db3e435a71c692ccef4197dac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Hellander?= Date: Tue, 8 Sep 2026 06:42:01 +0200 Subject: [PATCH 4/4] WIP4 --- .../StyleCop.Analyzers.Test.CSharp15.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj index ce6e56ed7..84e8f79b3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp15/StyleCop.Analyzers.Test.CSharp15.csproj @@ -14,7 +14,7 @@ - +