Repository navigation
Retarget C# 6/7 tests to net472 and update Microsoft.CodeAnalysis.Testing to 1.1.4 - #4190
Merged
Merged
Conversation
…ting to 1.1.4 - StyleCop.Analyzers.Test: net452 -> net472; StyleCop.Analyzers.Test.CSharp7: net46 -> net472 - Replace Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit 1.1.2-beta1.23509.1 with Microsoft.CodeAnalysis.CSharp.CodeFix.Testing 1.1.4 (the .XUnit packages were discontinued after 1.1.2) - Add a local port of XUnitVerifier so failures keep xUnit exception types and messages - Use the built-in ReferenceAssemblies.Net.Net90/Net100 instead of hand-built ones - Update CI test matrix frameworks and test-bin artifact paths
The testing library 1.1.4 brings NuGet.Frameworks 7.0.3 on net472, so the pin now causes an NU1605 downgrade error.
…r NuGet's dependencies Microsoft.CodeAnalysis.Analyzer.Testing 1.1.4 references NuGet.* without compile assets, so RAR never saw System.Text.Json 8.0.5's reference to Microsoft.Bcl.AsyncInterfaces 8.0.0.0. In the C# 14/15 test projects Roslyn 5.x deploys a newer Microsoft.Bcl.AsyncInterfaces with no redirect, so downloading Microsoft.NETCore.App.Ref failed with FileLoadException and the xunit run hung.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4190 +/- ##
==========================================
- Coverage 97.51% 97.51% -0.01%
==========================================
Files 1239 1239
Lines 132797 132787 -10
Branches 4288 4288
==========================================
- Hits 129502 129492 -10
Misses 2154 2154
Partials 1141 1141 🚀 New features to boost your workflow:
|
AArnott
marked this pull request as ready for review
October 9, 2026 04:27
Remove the local port of XUnitVerifier and its exception types; the Microsoft.CodeAnalysis.Testing.Verifiers.XUnit package was discontinued and the framework-neutral DefaultVerifier is the supported replacement. Version 1.1.4 still requires the TVerifier type argument on CSharpCodeFixTest/CSharpCodeFixVerifier/ CodeFixTest, so it is now DefaultVerifier everywhere. DiagnosticVerifierTests now expects InvalidOperationException (the exact type DefaultVerifier throws) instead of any XunitException, and the full-message check for an unexpected location on a project diagnostic no longer includes xUnit's trailing 'Assert.Equal() Failure' location dump.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #4189.
Changes
Retarget the .NET Framework test assemblies to net472
StyleCop.Analyzers.Test(C# 6, Roslyn 1.3.2):net452→net472StyleCop.Analyzers.Test.CSharp7:net46→net472net452ItemGroup (Microsoft.VisualStudio.Composition, System.ValueTuple, NuGet.Frameworks 5.9.3) is removed: net472 has System.ValueTuple in the box, and the testing library now brings Microsoft.VisualStudio.Composition and NuGet 7.0.3 on its own..github/workflows/build.yml, the matrixframeworkvalues and the test-bin artifact paths for C# 6 and C# 7 now usenet472. No other scripts or docs referencednet452ornet46.Update Microsoft.CodeAnalysis.Testing to 1.1.4, the latest version and the first stable one with
ReferenceAssemblies.Net.Net90(9.0.0) andNet100(10.0.1).Microsoft.CodeAnalysis.CSharp.Workspaces>= 1.0.1.Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnitandMicrosoft.CodeAnalysis.Testing.Verifiers.XUnitwere discontinued after 1.1.2, andVerifiers.XUnit1.1.2 pinsAnalyzer.Testingto exactly[1.1.2]. The project now referencesMicrosoft.CodeAnalysis.CSharp.CodeFix.Testing1.1.4 instead.DefaultVerifiereverywhereXUnitVerifierwas used:StyleCopCodeFixVerifier,StyleCopDiagnosticVerifier,CustomDiagnosticVerifier,AnalyzerConfigurationUnitTestsandDiagnosticVerifierTests. Version 1.1.4 has no overloads without a verifier type argument (CSharpCodeFixTest<TAnalyzer, TCodeFix, TVerifier>,CSharpCodeFixVerifier<…, TVerifier>,CodeFixTest<TVerifier>), so the argument stays and is set toDefaultVerifier.DiagnosticVerifierTests: the same failure conditions and key message content are still checked; only the xUnit-specific parts changed.Assert.ThrowsAsync<InvalidOperationException>, the exact typeDefaultVerifierthrows, instead ofAssert.ThrowsAnyAsync<XunitException>. EveryStartsWith/Containscheck on the message is unchanged.TestUnexpectedLocationForProjectDiagnosticAsyncstill compares the full message exactly: the context, "Expected a project diagnostic with no location", and the expected and actual diagnostic, including the actual span(7,33). Only xUnit's trailingAssert.Equal() Failure / Expected: None / Actual: SourceFile(...)dump is gone, because the default verifier doesn't produce it. A side effect is that this test now also passes on Linux; before, the hard-coded character offsets depended on line endings.Use the built-in reference assemblies:
GenericAnalyzerTestnow usesReferenceAssemblies.Net.Net90/Net100in place of the hand-built ones from Match C# 13+ test reference assemblies to the language version #4189, and theCreateNetReferenceAssemblieshelper is removed.allows ref struct, SA1116paramscollections, and SA1003fieldkeyword.NetFramework.Net452/Net46) are unchanged. They set which framework the test source compiles against, not where the test assembly runs.Two dependency fixes found in CI:
NuGet.Frameworks6.3.4 pin fromStyleCop.Analyzers.Test.CSharp8. It was there to raise the version above the old net452 5.9.3. Now the testing library brings 7.0.3 on net472, so the pin caused an NU1605 downgrade error.StyleCop.Analyzers.Testnow referencesNuGet.Resolver7.0.3 directly fornet472. Analyzer.Testing 1.1.4 references NuGet.* without compile assets, so binding-redirect generation never saw System.Text.Json 8.0.5's reference toMicrosoft.Bcl.AsyncInterfaces8.0.0.0. In the C# 14/15 projects, Roslyn 5.x deploys AsyncInterfaces 9.0/10.0, so downloadingMicrosoft.NETCore.App.Ref10.0.1 failed with a FileLoadException and the xunit run hung until the job timed out. With the direct reference, the redirects are generated: 9.0.0.0 for C# 14 and 10.0.0.1 for C# 15.StyleCopTesterstill targetsnet46. It is a developer tool, not a test project, so this PR leaves it alone.Validation
On Linux (net6.0), the C# 14 suite has exactly the same failures as
master(the known CRLF/Linux baseline of 296). C# 6 has the same failures minus one:TestUnexpectedLocationForProjectDiagnosticAsyncnow passes, giving 318 instead of 319. There are no new failures. C# 14 inherits the C# 13 tests, so it covers both Net90 and Net100.On Linux,
net472builds of every test project (via-p:OS=Windows_NT) succeed.CI on 015e102 is fully green: 25 of 25 checks, including all 10 Windows test jobs, which run the net472 binaries, and Merge code coverage. Test totals in the Debug jobs match
master, all with 0 failed and 0 skipped: