Skip to content

C#: Default test framework to Net90 reference assemblies#7071

Merged
knutwannheden merged 2 commits intomainfrom
default-reference-assemblies-for-c-test-parser
Mar 20, 2026
Merged

C#: Default test framework to Net90 reference assemblies#7071
knutwannheden merged 2 commits intomainfrom
default-reference-assemblies-for-c-test-parser

Conversation

@knutwannheden
Copy link
Contributor

Summary

  • Default RecipeSpec.ReferenceAssemblies to Assemblies.Net90 so C# tests get type attribution without requiring every test to explicitly call SetReferenceAssemblies()
  • Allow opting out via SetReferenceAssemblies(null) for tests that specifically want no type info
  • Fix WhitespaceReconciler to skip JavaType properties at the reflection level in GetReconcilableProperties, rather than with a runtime is JavaType check that missed the case where the original had types but the re-parsed formatted tree did not (causing the reconciler to bail on "structural mismatch" and silently skip auto-formatting)

Context

Discovered in recipes-csharp where UseGuidCreateVersion7 silently failed on 989 customer instances because MethodType was null. The recipe was fixed to use CSharpPattern, but the test gap (no default assemblies) masked the issue during development.

Test plan

  • All 1529 C# tests pass, including AutoFormatsTemplateResultIndentation which previously failed when type attribution was added (due to the reconciler bug)

…ribution

RecipeSpec now defaults ReferenceAssemblies to Assemblies.Net90 so tests
get type attribution without requiring every test to explicitly call
SetReferenceAssemblies(). Tests can opt out via SetReferenceAssemblies(null).

Also fix WhitespaceReconciler to skip JavaType properties at the reflection
level rather than at runtime. The reconciler previously bailed on structural
mismatch when the original tree had type info but the re-parsed formatted
tree did not. Since JavaType is metadata, not AST structure, these properties
should not be visited at all.
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Mar 20, 2026
@knutwannheden knutwannheden changed the title C#: Default test framework to Net90 reference assemblies C#: Default test framework to Net90 reference assemblies Mar 20, 2026
ResolveAsync is expensive (~5-10s) and returns the same result for
the same ReferenceAssemblies instance. Cache it in a static
ConcurrentDictionary so it's only resolved once per assembly set.
@knutwannheden knutwannheden merged commit 5a902aa into main Mar 20, 2026
1 check passed
@knutwannheden knutwannheden deleted the default-reference-assemblies-for-c-test-parser branch March 20, 2026 09:14
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenRewrite Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant