|
1 | 1 | // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. |
2 | 2 | // Licensed under the MIT License. See LICENSE in the project root for license information. |
3 | 3 |
|
4 | | -#nullable disable |
5 | | - |
6 | 4 | namespace StyleCop.Analyzers.Test.DocumentationRules |
7 | 5 | { |
8 | 6 | using System.Collections.Generic; |
@@ -562,35 +560,13 @@ public class ClassName |
562 | 560 | await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
563 | 561 | } |
564 | 562 |
|
565 | | - private static DiagnosticResult[] GetExpectedDiagnostics(DiagnosticResult normallyExpected, string declaration) |
566 | | - { |
567 | | - return GetExpectedDiagnostics(new[] { normallyExpected }, declaration); |
568 | | - } |
569 | | - |
570 | | - // Syntax node actions for type declarations with a primary constructor were called twice |
571 | | - // before support for c# 11 was added. |
572 | | - private static DiagnosticResult[] GetExpectedDiagnostics(DiagnosticResult[] normallyExpected, string declaration) |
573 | | - { |
574 | | - var isPrimaryConstructor = declaration.Contains("record") || declaration.Contains("class") || declaration.Contains("struct"); |
575 | | - |
576 | | - if (isPrimaryConstructor && !LightupHelpers.SupportsCSharp11) |
577 | | - { |
578 | | - // Diagnostic issued twice because of https://github.com/dotnet/roslyn/issues/53136 and https://github.com/dotnet/roslyn/issues/70488 |
579 | | - return normallyExpected.Concat(normallyExpected).ToArray(); |
580 | | - } |
581 | | - else |
582 | | - { |
583 | | - return normallyExpected; |
584 | | - } |
585 | | - } |
586 | | - |
587 | | - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) |
| 563 | + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) |
588 | 564 | => VerifyCSharpDiagnosticAsync(source, testSettings: null, expected, ignoreCompilerDiagnostics: false, cancellationToken); |
589 | 565 |
|
590 | | - private static Task VerifyCSharpDiagnosticAsync(string source, string testSettings, DiagnosticResult[] expected, CancellationToken cancellationToken) |
| 566 | + protected static Task VerifyCSharpDiagnosticAsync(string source, string? testSettings, DiagnosticResult[] expected, CancellationToken cancellationToken) |
591 | 567 | => VerifyCSharpDiagnosticAsync(source, testSettings, expected, ignoreCompilerDiagnostics: false, cancellationToken); |
592 | 568 |
|
593 | | - private static Task VerifyCSharpDiagnosticAsync(string source, string testSettings, DiagnosticResult[] expected, bool ignoreCompilerDiagnostics, CancellationToken cancellationToken) |
| 569 | + protected static Task VerifyCSharpDiagnosticAsync(string source, string? testSettings, DiagnosticResult[] expected, bool ignoreCompilerDiagnostics, CancellationToken cancellationToken) |
594 | 570 | { |
595 | 571 | string contentWithoutParamDocumentation = @"<?xml version=""1.0"" encoding=""utf-8"" ?> |
596 | 572 | <ClassName> |
@@ -696,5 +672,27 @@ private static Task VerifyCSharpDiagnosticAsync(string source, string testSettin |
696 | 672 | test.ExpectedDiagnostics.AddRange(expected); |
697 | 673 | return test.RunAsync(cancellationToken); |
698 | 674 | } |
| 675 | + |
| 676 | + private static DiagnosticResult[] GetExpectedDiagnostics(DiagnosticResult normallyExpected, string declaration) |
| 677 | + { |
| 678 | + return GetExpectedDiagnostics(new[] { normallyExpected }, declaration); |
| 679 | + } |
| 680 | + |
| 681 | + // Syntax node actions for type declarations with a primary constructor were called twice |
| 682 | + // before support for c# 11 was added. |
| 683 | + private static DiagnosticResult[] GetExpectedDiagnostics(DiagnosticResult[] normallyExpected, string declaration) |
| 684 | + { |
| 685 | + var isPrimaryConstructor = declaration.Contains("record") || declaration.Contains("class") || declaration.Contains("struct"); |
| 686 | + |
| 687 | + if (isPrimaryConstructor && !LightupHelpers.SupportsCSharp11) |
| 688 | + { |
| 689 | + // Diagnostic issued twice because of https://github.com/dotnet/roslyn/issues/53136 and https://github.com/dotnet/roslyn/issues/70488 |
| 690 | + return normallyExpected.Concat(normallyExpected).ToArray(); |
| 691 | + } |
| 692 | + else |
| 693 | + { |
| 694 | + return normallyExpected; |
| 695 | + } |
| 696 | + } |
699 | 697 | } |
700 | 698 | } |
0 commit comments