Skip to content

Commit cf39be8

Browse files
Replace Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit with Microsoft.CodeAnalysis.CSharp.CodeFix.Testing
1 parent 3f6f7db commit cf39be8

6 files changed

Lines changed: 26 additions & 36 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationUnitTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace StyleCop.Analyzers.Test
1515
using Microsoft.CodeAnalysis.CSharp;
1616
using Microsoft.CodeAnalysis.Diagnostics;
1717
using Microsoft.CodeAnalysis.Testing;
18-
using Microsoft.CodeAnalysis.Testing.Verifiers;
1918
using Xunit;
2019

2120
public class AnalyzerConfigurationUnitTests
@@ -62,7 +61,7 @@ public void TestHelpLink(Type analyzerType)
6261
}
6362
}
6463

65-
private class CSharpTest : CodeFixTest<XUnitVerifier>
64+
private class CSharpTest : CodeFixTest<DefaultVerifier>
6665
{
6766
private readonly Type analyzerType;
6867

StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.3.2" />
17-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.1.2-beta1.23509.1" />
17+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.3" />
1818
<PackageReference Include="Microsoft.VisualStudio.Composition" Version="16.1.8" />
1919
<PackageReference Include="Moq" Version="4.20.72" />
2020
<PackageReference Include="xunit" Version="2.4.1" />

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CustomDiagnosticVerifier`1.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ namespace StyleCop.Analyzers.Test.Verifiers
99
using Microsoft.CodeAnalysis.CSharp.Testing;
1010
using Microsoft.CodeAnalysis.Diagnostics;
1111
using Microsoft.CodeAnalysis.Testing;
12-
using Microsoft.CodeAnalysis.Testing.Verifiers;
1312

1413
internal static class CustomDiagnosticVerifier<TAnalyzer>
1514
where TAnalyzer : DiagnosticAnalyzer, new()
1615
{
1716
internal static DiagnosticResult Diagnostic()
18-
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, XUnitVerifier>.Diagnostic();
17+
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, DefaultVerifier>.Diagnostic();
1918

2019
internal static DiagnosticResult Diagnostic(string diagnosticId)
21-
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, XUnitVerifier>.Diagnostic(diagnosticId);
20+
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, DefaultVerifier>.Diagnostic(diagnosticId);
2221

2322
internal static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
2423
=> new DiagnosticResult(descriptor);

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifierTests.cs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ namespace StyleCop.Analyzers.Test.Verifiers
1313
using Microsoft.CodeAnalysis.CSharp.Testing;
1414
using Microsoft.CodeAnalysis.Diagnostics;
1515
using Microsoft.CodeAnalysis.Testing;
16-
using Microsoft.CodeAnalysis.Testing.Verifiers;
1716
using StyleCop.Analyzers.SpacingRules;
1817
using Xunit;
19-
using Xunit.Sdk;
2018
using static StyleCopDiagnosticVerifier<StyleCop.Analyzers.SpacingRules.SA1002SemicolonsMustBeSpacedCorrectly>;
2119

2220
/// <summary>
@@ -38,7 +36,7 @@ void MethodName()
3836
";
3937

4038
var expected = Diagnostic();
41-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
39+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
4240
async () =>
4341
{
4442
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -101,7 +99,7 @@ int PropertyName
10199
// By failing to include a location, the verified thinks we're only trying to verify a project diagnostic.
102100
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed");
103101

104-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
102+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
105103
async () =>
106104
{
107105
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -117,13 +115,9 @@ int PropertyName
117115
+ $"Actual diagnostic:{Environment.NewLine}"
118116
+ $" // /0/Test0.cs(7,33): warning SA1002: Semicolons should be followed by a space{Environment.NewLine}"
119117
+ $"VerifyCS.Diagnostic().WithSpan(7, 33, 7, 34).WithArguments(\"\", \"followed\"),{Environment.NewLine}"
120-
+ $"{Environment.NewLine}"
121-
+ $"{Environment.NewLine}"
122-
+ $"Assert.Equal() Failure{Environment.NewLine}"
123-
+ $"Expected: None{Environment.NewLine}"
124-
+ $"Actual: SourceFile(/0/Test0.cs[102..103))";
118+
+ $"{Environment.NewLine}";
125119

126-
new XUnitVerifier().EqualOrDiff(expectedMessage, ex.Message);
120+
new DefaultVerifier().EqualOrDiff(expectedMessage, ex.Message);
127121
}
128122

129123
[Fact]
@@ -140,7 +134,7 @@ int PropertyName
140134
}
141135
";
142136

143-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
137+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
144138
async () =>
145139
{
146140
await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false);
@@ -162,10 +156,10 @@ void MethodName()
162156
}
163157
";
164158

165-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
159+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
166160
async () =>
167161
{
168-
await CSharpCodeFixVerifier<ErrorThrowingAnalyzer, EmptyCodeFixProvider, XUnitVerifier>.VerifyAnalyzerAsync(testCode, DiagnosticResult.EmptyDiagnosticResults).ConfigureAwait(false);
162+
await CSharpCodeFixVerifier<ErrorThrowingAnalyzer, EmptyCodeFixProvider, DefaultVerifier>.VerifyAnalyzerAsync(testCode, DiagnosticResult.EmptyDiagnosticResults).ConfigureAwait(false);
169163
}).ConfigureAwait(false);
170164
Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"0\" actual \"1\"", ex.Message);
171165
Assert.Contains("error AD0001", ex.Message);
@@ -187,7 +181,7 @@ Int32 PropertyName
187181

188182
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 33);
189183

190-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
184+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
191185
async () =>
192186
{
193187
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -213,7 +207,7 @@ Int32 PropertyName
213207

214208
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(8, 33);
215209

216-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
210+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
217211
async () =>
218212
{
219213
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -239,7 +233,7 @@ int PropertyName
239233
var descriptor = new DiagnosticDescriptor("SA9999", "Title", "Message", "Category", DiagnosticSeverity.Warning, isEnabledByDefault: true);
240234
DiagnosticResult expected = Diagnostic(descriptor).WithLocation(7, 33);
241235

242-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
236+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
243237
async () =>
244238
{
245239
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -263,7 +257,7 @@ int PropertyName
263257

264258
DiagnosticResult expected = Diagnostic().WithLocation(7, 33).WithSeverity(DiagnosticSeverity.Error);
265259

266-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
260+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
267261
async () =>
268262
{
269263
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -287,7 +281,7 @@ int PropertyName
287281

288282
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(8, 33);
289283

290-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
284+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
291285
async () =>
292286
{
293287
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -316,7 +310,7 @@ int PropertyName
316310
Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 34),
317311
};
318312

319-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
313+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
320314
async () =>
321315
{
322316
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -340,7 +334,7 @@ int PropertyName
340334

341335
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 34);
342336

343-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
337+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
344338
async () =>
345339
{
346340
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -364,7 +358,7 @@ int PropertyName
364358

365359
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithSpan(7, 33, 7, 35);
366360

367-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
361+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
368362
async () =>
369363
{
370364
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -388,7 +382,7 @@ int PropertyName
388382

389383
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "bogus argument").WithLocation(7, 33);
390384

391-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
385+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
392386
async () =>
393387
{
394388
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);
@@ -412,7 +406,7 @@ int PropertyName
412406

413407
DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "bogus argument").WithLocation(7, 33).WithLocation(8, 34);
414408

415-
var ex = await Assert.ThrowsAnyAsync<XunitException>(
409+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
416410
async () =>
417411
{
418412
await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false);

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopCodeFixVerifier`2.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ namespace StyleCop.Analyzers.Test.Verifiers
2121
using Microsoft.CodeAnalysis.Diagnostics;
2222
using Microsoft.CodeAnalysis.Formatting;
2323
using Microsoft.CodeAnalysis.Testing;
24-
using Microsoft.CodeAnalysis.Testing.Verifiers;
2524
using Microsoft.CodeAnalysis.Text;
2625
using StyleCop.Analyzers.Lightup;
2726
using StyleCop.Analyzers.Settings.ObjectModel;
@@ -33,10 +32,10 @@ internal static class StyleCopCodeFixVerifier<TAnalyzer, TCodeFix>
3332
where TCodeFix : CodeFixProvider, new()
3433
{
3534
internal static DiagnosticResult Diagnostic()
36-
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, XUnitVerifier>.Diagnostic();
35+
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.Diagnostic();
3736

3837
internal static DiagnosticResult Diagnostic(string diagnosticId)
39-
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, XUnitVerifier>.Diagnostic(diagnosticId);
38+
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, DefaultVerifier>.Diagnostic(diagnosticId);
4039

4140
internal static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
4241
=> new DiagnosticResult(descriptor);
@@ -96,7 +95,7 @@ internal static Task VerifyCSharpFixAsync(LanguageVersion? languageVersion, stri
9695
return test.RunAsync(cancellationToken);
9796
}
9897

99-
internal class CSharpTest : CSharpCodeFixTest<TAnalyzer, TCodeFix, XUnitVerifier>
98+
internal class CSharpTest : CSharpCodeFixTest<TAnalyzer, TCodeFix, DefaultVerifier>
10099
{
101100
private const int DefaultIndentationSize = 4;
102101
private const int DefaultTabSize = 4;

StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopDiagnosticVerifier`1.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@ namespace StyleCop.Analyzers.Test.Verifiers
1212
using Microsoft.CodeAnalysis.CSharp.Testing;
1313
using Microsoft.CodeAnalysis.Diagnostics;
1414
using Microsoft.CodeAnalysis.Testing;
15-
using Microsoft.CodeAnalysis.Testing.Verifiers;
1615
using StyleCop.Analyzers.Lightup;
1716

1817
internal static class StyleCopDiagnosticVerifier<TAnalyzer>
1918
where TAnalyzer : DiagnosticAnalyzer, new()
2019
{
2120
internal static DiagnosticResult Diagnostic()
22-
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, XUnitVerifier>.Diagnostic();
21+
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, DefaultVerifier>.Diagnostic();
2322

2423
internal static DiagnosticResult Diagnostic(string diagnosticId)
25-
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, XUnitVerifier>.Diagnostic(diagnosticId);
24+
=> CSharpCodeFixVerifier<TAnalyzer, EmptyCodeFixProvider, DefaultVerifier>.Diagnostic(diagnosticId);
2625

2726
internal static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor)
2827
=> new DiagnosticResult(descriptor);

0 commit comments

Comments
 (0)