Skip to content

Commit 5b6d5be

Browse files
authored
Merge pull request #3287 from sharwell/update-testing
Update Microsoft.CodeAnalysis.Testing to 1.0.1-beta1.20623.3
2 parents f262c13 + ec32196 commit 5b6d5be

File tree

7 files changed

+32
-64
lines changed

7 files changed

+32
-64
lines changed

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516CSharp9UnitTests.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,20 @@ public async Task TestStatementSpacingInTopLevelProgramAsync()
3737
await new CSharpTest(LanguageVersion.CSharp9)
3838
{
3939
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
40-
TestCode = testCode,
41-
ExpectedDiagnostics =
40+
TestState =
4241
{
43-
// /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line
44-
Diagnostic().WithLocation(0),
45-
46-
// /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line
47-
Diagnostic().WithLocation(0),
48-
},
49-
FixedCode = fixedCode,
50-
SolutionTransforms =
51-
{
52-
(solution, projectId) =>
42+
OutputKind = OutputKind.ConsoleApplication,
43+
Sources = { testCode },
44+
ExpectedDiagnostics =
5345
{
54-
var project = solution.GetProject(projectId);
55-
var options = project.CompilationOptions;
56-
return solution.WithProjectCompilationOptions(projectId, options.WithOutputKind(OutputKind.ConsoleApplication));
46+
// /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line
47+
Diagnostic().WithLocation(0),
48+
49+
// /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line
50+
Diagnostic().WithLocation(0),
5751
},
5852
},
53+
FixedCode = fixedCode,
5954
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
6055
}
6156
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200CSharp9OutsideNamespaceUnitTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,12 @@ public async Task TestValidUsingStatementsInTopLevelProgramAsync()
3434
await new CSharpTest(LanguageVersion.CSharp9)
3535
{
3636
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
37-
TestCode = testCode,
38-
Settings = TestSettings,
39-
SolutionTransforms =
37+
TestState =
4038
{
41-
(solution, projectId) =>
42-
{
43-
var project = solution.GetProject(projectId);
44-
var options = project.CompilationOptions;
45-
return solution.WithProjectCompilationOptions(projectId, options.WithOutputKind(OutputKind.ConsoleApplication));
46-
},
39+
OutputKind = OutputKind.ConsoleApplication,
40+
Sources = { testCode },
4741
},
42+
Settings = TestSettings,
4843
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
4944
}
5045
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200CSharp9PreserveUnitTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,12 @@ public async Task TestValidUsingStatementsInTopLevelProgramAsync()
3434
await new CSharpTest(LanguageVersion.CSharp9)
3535
{
3636
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
37-
TestCode = testCode,
38-
Settings = TestSettings,
39-
SolutionTransforms =
37+
TestState =
4038
{
41-
(solution, projectId) =>
42-
{
43-
var project = solution.GetProject(projectId);
44-
var options = project.CompilationOptions;
45-
return solution.WithProjectCompilationOptions(projectId, options.WithOutputKind(OutputKind.ConsoleApplication));
46-
},
39+
OutputKind = OutputKind.ConsoleApplication,
40+
Sources = { testCode },
4741
},
42+
Settings = TestSettings,
4843
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
4944
}
5045
}

StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200CSharp9UnitTests.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@ public async Task TestValidUsingStatementsInTopLevelProgramAsync()
3434
await new CSharpTest(LanguageVersion.CSharp9)
3535
{
3636
ReferenceAssemblies = ReferenceAssemblies.Net.Net50,
37-
TestCode = testCode,
38-
SolutionTransforms =
37+
TestState =
3938
{
40-
(solution, projectId) =>
41-
{
42-
var project = solution.GetProject(projectId);
43-
var options = project.CompilationOptions;
44-
return solution.WithProjectCompilationOptions(projectId, options.WithOutputKind(OutputKind.ConsoleApplication));
45-
},
39+
OutputKind = OutputKind.ConsoleApplication,
40+
Sources = { testCode },
4641
},
4742
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
4843
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1005UnitTests.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,10 @@ public class Bar
271271
// Verify that this works if the project was configured to treat documentation comments as regular comments
272272
await new CSharpTest
273273
{
274-
TestCode = testCode,
275-
SolutionTransforms =
274+
TestState =
276275
{
277-
(solution, projectId) =>
278-
{
279-
var project = solution.GetProject(projectId);
280-
return solution.WithProjectParseOptions(projectId, project.ParseOptions.WithDocumentationMode(DocumentationMode.None));
281-
},
276+
DocumentationMode = DocumentationMode.None,
277+
Sources = { testCode },
282278
},
283279
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
284280
}

StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0001UnitTests.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ public async Task TestEnabledDocumentationModesAsync(DocumentationMode documenta
2828

2929
await new CSharpTest
3030
{
31-
TestCode = testCode,
32-
SolutionTransforms =
31+
TestState =
3332
{
34-
(solution, projectId) =>
35-
{
36-
var project = solution.GetProject(projectId);
37-
return solution.WithProjectParseOptions(projectId, project.ParseOptions.WithDocumentationMode(documentationMode));
38-
},
33+
DocumentationMode = documentationMode,
34+
Sources = { testCode },
3935
},
4036
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
4137
}
@@ -54,15 +50,11 @@ public async Task TestDisabledDocumentationModesAsync(DocumentationMode document
5450

5551
await new CSharpTest
5652
{
57-
TestCode = testCode,
58-
ExpectedDiagnostics = { expected },
59-
SolutionTransforms =
53+
TestState =
6054
{
61-
(solution, projectId) =>
62-
{
63-
var project = solution.GetProject(projectId);
64-
return solution.WithProjectParseOptions(projectId, project.ParseOptions.WithDocumentationMode(documentationMode));
65-
},
55+
DocumentationMode = documentationMode,
56+
Sources = { testCode },
57+
ExpectedDiagnostics = { expected },
6658
},
6759
}.RunAsync(CancellationToken.None).ConfigureAwait(false);
6860
}

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

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

1919
<ItemGroup>
2020
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.3.2" />
21-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.0.1-beta1.20559.1" />
21+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.0.1-beta1.20623.3" />
2222
<PackageReference Include="Microsoft.VisualStudio.Composition" Version="16.1.8" />
2323
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
2424
<PackageReference Include="xunit" Version="2.4.1" />

0 commit comments

Comments
 (0)