Skip to content

Fix source generator type ambiguity and generic type test discovery#182

Merged
jas88 merged 2 commits into
mainfrom
fix/dependabot-ci-failures
Apr 9, 2026
Merged

Fix source generator type ambiguity and generic type test discovery#182
jas88 merged 2 commits into
mainfrom
fix/dependabot-ci-failures

Conversation

@jas88
Copy link
Copy Markdown
Owner

@jas88 jas88 commented Apr 8, 2026

Summary

  • Skip Spectre.Console.Ansi assembly in the source generator to prevent CS0433 ambiguity when Spectre.Console 0.55+ exposes duplicate StringExtensions across assemblies
  • Deduplicate types by fully-qualified name in the source generator as a general safety net against future cross-assembly type collisions
  • Filter open generic type definitions from TestCommandsAreSupported since CommandInvoker cannot resolve unbound type parameters like T, T1

Context

Dependabot PRs #180 (NPOI 2.8.0) and #181 (Spectre.Console 0.55.0) are both failing CI. Once this merges, rebasing those PRs on main should fix both.

Test plan

High-level PR Summary

This PR fixes two build and test failures introduced by dependency updates: it prevents compiler ambiguity errors (CS0433) by excluding the Spectre.Console.Ansi assembly from source generation and deduplicating types by fully-qualified name, and it filters out open generic type definitions from test discovery to prevent TestCommandsAreSupported failures when encountering unbound type parameters.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 Rdmp.Core.Generators/TypeRegistryGenerator.cs
2 Rdmp.Core.Tests/CommandExecution/TestCommandsAreSupported.cs

Need help? Join our Discord


Summary by cubic

Fixes CS0433 type ambiguity in the source generator and stabilizes generic command test discovery with Spectre.Console 0.55+. Normalizes registry keys to improve lookups, so Dependabot PRs #181 and #180 should pass after a rebase.

  • Bug Fixes
    • Skip Spectre.Console.Ansi during type collection to avoid duplicate StringExtensions across Spectre.Console assemblies.
    • Deduplicate and normalize types by fully qualified name (strip global::), and materialize grouped results to prevent collisions and repeated enumeration while speeding up dictionary lookups.
    • Exclude open generic type definitions from command support tests to avoid unbound type parameter resolution in CommandInvoker.

Written for commit 3c34d89. Summary will update on new commits.

Skip Spectre.Console.Ansi in source generator to prevent CS0433 when
Spectre.Console 0.55+ exposes duplicate StringExtensions across
assemblies. Also deduplicate types by fully-qualified name as a general
safety net.

Filter open generic type definitions from TestCommandsAreSupported since
CommandInvoker cannot resolve unbound type parameters.
Copilot AI review requested due to automatic review settings April 8, 2026 23:15
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 04fd2ef..9fb585d

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (2)

Rdmp.Core.Generators/TypeRegistryGenerator.cs
Rdmp.Core.Tests/CommandExecution/TestCommandsAreSupported.cs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the compile-time type registry source generator and command test discovery to avoid failures caused by cross-assembly type name collisions (notably with Spectre.Console 0.55+) and by open generic command types being discovered in tests.

Changes:

  • Exclude Spectre.Console.Ansi from type collection to prevent CS0433 ambiguity when duplicate types exist across Spectre assemblies.
  • Deduplicate collected generator types by fully-qualified name before emitting the registry.
  • Filter open generic type definitions out of TestCommandsAreSupported test case discovery.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Rdmp.Core.Tests/CommandExecution/TestCommandsAreSupported.cs Excludes open generic command types from discovered test cases so CommandInvoker isn’t asked to validate unbound generic definitions.
Rdmp.Core.Generators/TypeRegistryGenerator.cs Avoids known problematic assemblies and deduplicates types to reduce risk of collisions when generating the compiled type registry.
Comments suppressed due to low confidence (1)

Rdmp.Core.Generators/TypeRegistryGenerator.cs:188

  • group.Count() is computed for every IGrouping and then the group is enumerated again via First()/foreach, which results in repeated enumeration of each group. Since this generator can process many types, consider materializing each group once (or use a lookup that exposes Count cheaply) to keep generation time predictable.
        // Group types by short name to handle duplicates
        var grouped = deduped.GroupBy(t => t.ShortName);

        foreach (var group in grouped)
        {
            if (group.Count() == 1)
            {
                var type = group.First();
                sb.AppendLine($"        // {type.FullName}");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Rdmp.Core.Generators/TypeRegistryGenerator.cs
Strip global:: from dictionary keys so Type.FullName lookups hit the
fast path. Materialize GroupBy results to avoid re-enumerating each
group. Normalize dedup key to match the dictionary key space.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (04fd2ef) to head (3c34d89).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #182   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files       1118    1118           
  Lines      66302   66302           
  Branches    8767    8767           
=====================================
  Misses     66302   66302           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jas88 jas88 merged commit 97227bf into main Apr 9, 2026
8 checks passed
@jas88 jas88 deleted the fix/dependabot-ci-failures branch April 9, 2026 00:17
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.

2 participants