|
3 | 3 |
|
4 | 4 | namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules |
5 | 5 | { |
6 | | - using System; |
7 | | - using System.Collections.Generic; |
8 | 6 | using System.Threading; |
9 | 7 | using System.Threading.Tasks; |
10 | 8 |
|
11 | | - using Microsoft.CodeAnalysis; |
12 | | - using Microsoft.CodeAnalysis.CodeFixes; |
13 | 9 | using Microsoft.CodeAnalysis.CSharp; |
14 | | - using Microsoft.CodeAnalysis.Diagnostics; |
15 | 10 | using Microsoft.CodeAnalysis.Testing; |
16 | | - using Microsoft.CodeAnalysis.Testing.Verifiers; |
17 | 11 |
|
18 | 12 | using StyleCop.Analyzers.Test.CSharp7.SpacingRules; |
19 | 13 |
|
@@ -83,45 +77,21 @@ public void TestMethod(object value) |
83 | 77 | [WorkItem(3172, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3172")] |
84 | 78 | public async Task TestCloseBraceWithNullForgivingOperatorAsync() |
85 | 79 | { |
86 | | - const string testCode = @" |
| 80 | + const string testCode = @"#nullable enable |
87 | 81 | public class Foo |
88 | 82 | { |
89 | 83 | public void TestMethod() |
90 | 84 | { |
91 | 85 | var test = new[] |
92 | 86 | { |
93 | | - new { Value = default(string) }, |
94 | 87 | new { Value = ""a"" }!, |
95 | 88 | new { Value = ""b"" } !, |
96 | 89 | }; |
97 | 90 | } |
98 | 91 | } |
99 | 92 | "; |
100 | 93 |
|
101 | | - var test = new NullableCSharpAnalyzerTest |
102 | | - { |
103 | | - TestCode = testCode, |
104 | | - }; |
105 | | - |
106 | | - await test.RunAsync(CancellationToken.None).ConfigureAwait(false); |
107 | | - } |
108 | | - |
109 | | - private class NullableCSharpAnalyzerTest : AnalyzerTest<XUnitVerifier> |
110 | | - { |
111 | | - public override string Language => LanguageNames.CSharp; |
112 | | - |
113 | | - protected override string DefaultFileExt => "cs"; |
114 | | - |
115 | | - protected override CompilationOptions CreateCompilationOptions() |
116 | | - => new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true, nullableContextOptions: NullableContextOptions.Enable); |
117 | | - |
118 | | - protected override ParseOptions CreateParseOptions() |
119 | | - => new CSharpParseOptions(LanguageVersion.CSharp8); |
120 | | - |
121 | | - protected override IEnumerable<DiagnosticAnalyzer> GetDiagnosticAnalyzers() |
122 | | - { |
123 | | - yield return new StyleCop.Analyzers.SpacingRules.SA1013ClosingBracesMustBeSpacedCorrectly(); |
124 | | - } |
| 94 | + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp8, testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); |
125 | 95 | } |
126 | 96 | } |
127 | 97 | } |
0 commit comments