|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules |
5 | 5 | { |
| 6 | + using System.Threading; |
| 7 | + using System.Threading.Tasks; |
| 8 | + using Microsoft.CodeAnalysis.Testing; |
6 | 9 | using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; |
| 10 | + using StyleCop.Analyzers.Test.Helpers; |
| 11 | + using Xunit; |
| 12 | + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< |
| 13 | + StyleCop.Analyzers.MaintainabilityRules.SA1400AccessModifierMustBeDeclared, |
| 14 | + StyleCop.Analyzers.MaintainabilityRules.SA1400CodeFixProvider>; |
7 | 15 |
|
8 | 16 | public partial class SA1400CSharp8UnitTests : SA1400CSharp7UnitTests |
9 | 17 | { |
| 18 | + [Fact] |
| 19 | + [WorkItem(3002, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3002")] |
| 20 | + public async Task TestDefaultInterfaceImplementationWithoutAccessModifierAsync() |
| 21 | + { |
| 22 | + var testCode = @" |
| 23 | +public interface ITest |
| 24 | +{ |
| 25 | + void M() |
| 26 | + { |
| 27 | + } |
| 28 | +
|
| 29 | + int P |
| 30 | + { |
| 31 | + get |
| 32 | + { |
| 33 | + return 0; |
| 34 | + } |
| 35 | + } |
| 36 | +} |
| 37 | +"; |
| 38 | + |
| 39 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 40 | + } |
| 41 | + |
| 42 | + [Fact] |
| 43 | + [WorkItem(3002, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3002")] |
| 44 | + public async Task TestStaticInterfaceMemberWithoutAccessModifierAsync() |
| 45 | + { |
| 46 | + var testCode = @" |
| 47 | +public interface ITest |
| 48 | +{ |
| 49 | + static void M() |
| 50 | + { |
| 51 | + } |
| 52 | +} |
| 53 | +"; |
| 54 | + |
| 55 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 56 | + } |
| 57 | + |
| 58 | + [Fact] |
| 59 | + [WorkItem(3002, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3002")] |
| 60 | + public async Task TestDelegateDeclarationInsideInterfaceAsync() |
| 61 | + { |
| 62 | + var testCode = @" |
| 63 | +public interface ITest |
| 64 | +{ |
| 65 | + delegate void Handler(); |
| 66 | +} |
| 67 | +"; |
| 68 | + |
| 69 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 70 | + } |
| 71 | + |
| 72 | + [Fact] |
| 73 | + [WorkItem(3002, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3002")] |
| 74 | + public async Task TestStaticFieldInsideInterfaceAsync() |
| 75 | + { |
| 76 | + var testCode = @" |
| 77 | +public interface ITest |
| 78 | +{ |
| 79 | + static int Value = 0; |
| 80 | +} |
| 81 | +"; |
| 82 | + |
| 83 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 84 | + } |
| 85 | + |
| 86 | + [Theory] |
| 87 | + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] |
| 88 | + [WorkItem(3002, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3002")] |
| 89 | + public async Task TestTypeDeclarationInsideInterfaceAsync(string typeKind) |
| 90 | + { |
| 91 | + var testCode = $@" |
| 92 | +public interface ITest |
| 93 | +{{ |
| 94 | + {typeKind} NestedType |
| 95 | + {{ |
| 96 | + }} |
| 97 | +}} |
| 98 | +"; |
| 99 | + |
| 100 | + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
| 101 | + } |
10 | 102 | } |
11 | 103 | } |
0 commit comments