|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules |
5 | 5 | { |
| 6 | + using System.Threading; |
| 7 | + using System.Threading.Tasks; |
| 8 | + using Microsoft.CodeAnalysis.Testing; |
6 | 9 | using StyleCop.Analyzers.Test.CSharp8.OrderingRules; |
| 10 | + using Xunit; |
| 11 | + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< |
| 12 | + StyleCop.Analyzers.OrderingRules.SA1202ElementsMustBeOrderedByAccess, |
| 13 | + StyleCop.Analyzers.OrderingRules.ElementOrderCodeFixProvider>; |
7 | 14 |
|
8 | 15 | public partial class SA1202CSharp9UnitTests : SA1202CSharp8UnitTests |
9 | 16 | { |
| 17 | + [Fact] |
| 18 | + [WorkItem(3971, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3971")] |
| 19 | + public async Task TestPartialMethodExplicitAccessibilityDeclarationOrderingAsync() |
| 20 | + { |
| 21 | + var testCode = @" |
| 22 | +public partial class TestClass |
| 23 | +{ |
| 24 | + private void Helper() { } |
| 25 | +
|
| 26 | + public partial void {|#0:TestMethod|}(); |
| 27 | +} |
| 28 | +
|
| 29 | +public partial class TestClass |
| 30 | +{ |
| 31 | + public partial void TestMethod() |
| 32 | + { |
| 33 | + } |
| 34 | +} |
| 35 | +"; |
| 36 | + |
| 37 | + var expected = Diagnostic().WithLocation(0).WithArguments("public", "private"); |
| 38 | + |
| 39 | + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + [WorkItem(3971, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3971")] |
| 44 | + public async Task TestPartialMethodExplicitAccessibilityImplementationOrderingAsync() |
| 45 | + { |
| 46 | + var testCode = @" |
| 47 | +public partial class TestClass |
| 48 | +{ |
| 49 | + public partial void TestMethod(); |
| 50 | +} |
| 51 | +
|
| 52 | +public partial class TestClass |
| 53 | +{ |
| 54 | + private void Helper() { } |
| 55 | +
|
| 56 | + public partial void {|#0:TestMethod|}() |
| 57 | + { |
| 58 | + } |
| 59 | +} |
| 60 | +"; |
| 61 | + |
| 62 | + var expected = Diagnostic().WithLocation(0).WithArguments("public", "private"); |
| 63 | + |
| 64 | + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); |
| 65 | + } |
10 | 66 | } |
11 | 67 | } |
0 commit comments