Skip to content

Fix typed global options DI binding#24

Merged
carldebilly merged 1 commit intomainfrom
dev/cdb/issue-23-global-options-di
May 2, 2026
Merged

Fix typed global options DI binding#24
carldebilly merged 1 commit intomainfrom
dev/cdb/issue-23-global-options-di

Conversation

@carldebilly
Copy link
Copy Markdown
Member

@carldebilly carldebilly commented May 2, 2026

Summary

Closes #23.

Fixes UseGlobalOptions<T>() handler binding when the handler parameter type is the registered global-options type and the parameter name matches a global option name.

The registered typed global-options class is now treated as an implicit DI parameter during command schema generation and runtime binding, instead of being interpreted as a command option or positional argument.

Changes

  • Track implicit service-bound parameter types through a shared internal registry.
  • Skip typed global-options parameters and framework services, including IGlobalOptionsAccessor, when building command option schemas and documentation.
  • Resolve typed global-options parameters from DI during handler binding, including implemented interface/base-class handler parameter types.
  • Reject [ReplOption] and [ReplArgument] on typed global-options handler parameters with a clear registration-time error.
  • Improve diagnostics for missing typed global-options DI registrations and duplicate typed global-options property names.
  • Remove the nullable capturedParsing! path and cache typed global-options property reflection metadata.
  • Preserve the existing validation for real global/command option collisions, such as string tenant alongside a global --tenant.

TDD

Added regression coverage for:

  • the original ambiguous --tenant failure;
  • typed global-options parameters whose handler type is an implemented interface;
  • [ReplOption] / [ReplArgument] misuse on typed global-options parameters;
  • missing typed global-options DI registration diagnostics;
  • duplicate typed global-options property-name diagnostics;
  • IGlobalOptionsAccessor not leaking as a --globals command option in help or docs.

Each new behavioral case was run red first, then green after the fix.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@carldebilly carldebilly force-pushed the dev/cdb/issue-23-global-options-di branch from fb08789 to f3ebc45 Compare May 2, 2026 02:11
@carldebilly carldebilly merged commit 2cca95c into main May 2, 2026
12 checks passed
@carldebilly carldebilly deleted the dev/cdb/issue-23-global-options-di branch May 2, 2026 02:22
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.

UseGlobalOptions<T>: handler with parameter of type T fails with "Ambiguous option" instead of injecting from DI as documented

1 participant