Skip to content

Commit 6482471

Browse files
committed
Update after review
1 parent 8a3a031 commit 6482471

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1013CSharp8UnitTests.cs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@
33

44
namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules
55
{
6-
using System;
7-
using System.Collections.Generic;
86
using System.Threading;
97
using System.Threading.Tasks;
108

11-
using Microsoft.CodeAnalysis;
12-
using Microsoft.CodeAnalysis.CodeFixes;
139
using Microsoft.CodeAnalysis.CSharp;
14-
using Microsoft.CodeAnalysis.Diagnostics;
1510
using Microsoft.CodeAnalysis.Testing;
16-
using Microsoft.CodeAnalysis.Testing.Verifiers;
1711

1812
using StyleCop.Analyzers.Test.CSharp7.SpacingRules;
1913

@@ -83,45 +77,21 @@ public void TestMethod(object value)
8377
[WorkItem(3172, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3172")]
8478
public async Task TestCloseBraceWithNullForgivingOperatorAsync()
8579
{
86-
const string testCode = @"
80+
const string testCode = @"#nullable enable
8781
public class Foo
8882
{
8983
public void TestMethod()
9084
{
9185
var test = new[]
9286
{
93-
new { Value = default(string) },
9487
new { Value = ""a"" }!,
9588
new { Value = ""b"" } !,
9689
};
9790
}
9891
}
9992
";
10093

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);
12595
}
12696
}
12797
}

0 commit comments

Comments
 (0)