Remove redundant .NET and language version settings in tests - #1367
Merged
Merged
Conversation
The tests that expect the code fixer to generate a partial method now use a CreatePartialMethodTest helper that pins .NET 7 and C# 11, instead of repeating the language version in every test. CreateTest uses the default target framework, so the partial property tests no longer need to override the reference assemblies.
This was referenced Aug 31, 2026
Closed
Closed
Closed
Closed
Bump Meziantou.Analyzer from 3.0.139 to 3.0.200
Analogy-LogViewer/Analogy.LogViewer.NLog.Targets#560
Closed
This was referenced Sep 25, 2026
Open
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.
What
Removes the explicit target framework, ASP.NET Core and C# language version settings in the tests when the defaults of the testing harness are enough.
test.ReferenceAssemblies = ReferenceAssemblies.Net.NetXX;assignments removed, plus the equivalent object initializers (new CodeFixTest { ReferenceAssemblies = ... }).ReferenceAssemblies.Net.Net80.AddAspNetCore("8.0.0")becomestest.ReferenceAssemblies.AddAspNetCore(), and...Net80.AddPackages([...])becomestest.ReferenceAssemblies.AddPackages([...]).test.LanguageVersion = ...assignments removed, plus 13 more inUseStringComparerAnalyzerTeststhat only existed to lift the C# 9 class default back up to C# 12.UseRegexSourceGeneratorAnalyzerTestsgets aCreatePartialMethodTesthelper (.NET 7 + C# 11) instead of repeating the language version in 23 tests, which also lets the partial property tests drop theirNet90overrides.using Microsoft.CodeAnalysis.Testing;andusing Microsoft.CodeAnalysis.CSharp;directives are removed.Why
Most tests were pinning a framework or a language version that predates the default of the harness, which hides which tests actually depend on a specific version.
What is kept
Every setting that is load bearing was verified by removing it and observing the failures:
ProcessWaitForExit_NET5,Net5_NoDiagnostic,RefStruct_CSharp12,CannotBeReadOnly_CSharp7,InjectProperty_AspNetCore8_NoDiagnostic, ...).LanguageVersion.Previewfor union types,closedtypes andSystem.Threading.Lock:Latestis below those features on the older Roslyn versions.netstandardandnet48targets, and the DI based tests whose types are not in the .NET 11 ASP.NET Core reference pack.Testing
dotnet test --max-parallel-test-modules 2: 19013 passed, 0 failed, on Roslyn 4.8, 4.14, 5.0, 5.6 and 5.9.Note for the reviewer
Names such as
Dictionary_String_CollectionExpression_DefaultOnCSharp12_ShouldNotReportDiagnosticnow run with the default language version instead of exactly C# 12. The behavior is identical, but tell me if you prefer to keep the explicit pin so the names keep matching.