Skip to content

fix: handle duplicate type names across assemblies in InfrastructureGenerator#4664

Merged
thomhurst merged 1 commit intomainfrom
fix/duplicate-type-names-4663
Feb 4, 2026
Merged

fix: handle duplicate type names across assemblies in InfrastructureGenerator#4664
thomhurst merged 1 commit intomainfrom
fix/duplicate-type-names-4663

Conversation

@thomhurst
Copy link
Owner

Summary

Fixes #4663

  • When multiple assemblies define types with the same fully-qualified name (e.g., ServiceCollectionExtensions in both AWSSDK.Extensions.NETCore.Setup and Amazon.Lambda.AspNetCoreServer.Hosting), the generated typeof() call caused CS0433 compilation errors
  • The fix uses Roslyn's GetTypeByMetadataName() to detect ambiguous types and skip them, finding a unique type from each assembly instead
  • Added test that verifies the fix by creating a synthetic conflicting type

Test plan

  • New test DuplicateTypeNameAcrossAssembliesTests verifies the generator skips ambiguous types
  • All 456 existing source generator tests pass
  • Manual verification with the AWS packages mentioned in the issue

🤖 Generated with Claude Code

@claude
Copy link
Contributor

claude bot commented Feb 4, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

The fix correctly handles duplicate type names across assemblies by using Roslyn's GetTypeByMetadataName() to detect ambiguous types. The approach is sound:

  • Properly skips ambiguous types that would cause CS0433 compilation errors
  • Correctly implements the GetFullMetadataName() helper for nested types with + separator
  • Includes comprehensive snapshot tests across multiple .NET target frameworks
  • Follows CLAUDE.md guidelines including proper snapshot file management

…enerator

Fixes #4663

When multiple assemblies define types with the same fully-qualified name
(e.g., ServiceCollectionExtensions in both AWSSDK.Extensions.NETCore.Setup
and Amazon.Lambda.AspNetCoreServer.Hosting), the generated typeof() call
caused CS0433 compilation errors.

The fix uses Roslyn's GetTypeByMetadataName() to detect ambiguous types
and skip them, finding a unique type from each assembly instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@thomhurst thomhurst force-pushed the fix/duplicate-type-names-4663 branch from 3202968 to 57f661c Compare February 4, 2026 22:39
@thomhurst thomhurst enabled auto-merge (squash) February 4, 2026 22:48
@thomhurst thomhurst merged commit f363a5c into main Feb 4, 2026
12 of 13 checks passed
@thomhurst thomhurst deleted the fix/duplicate-type-names-4663 branch February 4, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TUnitInfrastructure can't handle duplicate types

1 participant