Skip to content

Allow IOptions for ConsoleAppOptions for configuration#49

Merged
LittleLittleCloud merged 11 commits intoRazorConsole:mainfrom
DericHuynh:ioptions
Oct 23, 2025
Merged

Allow IOptions for ConsoleAppOptions for configuration#49
LittleLittleCloud merged 11 commits intoRazorConsole:mainfrom
DericHuynh:ioptions

Conversation

@DericHuynh
Copy link
Contributor

@DericHuynh DericHuynh commented Oct 23, 2025

Closes #46

Enables use of IOption pattern configuration while still avoiding IOptions<> dependency through POCO class registration.

Added test for IOption resolution since it depends on the generic host itself injecting the IOptions dependencies.

@DericHuynh DericHuynh marked this pull request as ready for review October 23, 2025 00:46
@DericHuynh DericHuynh marked this pull request as draft October 23, 2025 00:49
@DericHuynh DericHuynh marked this pull request as ready for review October 23, 2025 00:49
Copy link
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 enables the ConsoleAppOptions class to be configured using the standard IOptions<T> pattern while maintaining backward compatibility by avoiding direct IOptions<> dependencies in consuming components. The change allows developers to use services.Configure<ConsoleAppOptions>() instead of manually registering singleton instances.

Key changes:

  • Modified ConsoleAppOptions registration to resolve from IOptions<ConsoleAppOptions> internally while exposing a plain POCO to consumers
  • Updated test to use Configure<ConsoleAppOptions>() instead of AddSingleton<ConsoleAppOptions>()
  • Added new test verifying default options resolution through the DI container

Reviewed Changes

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

File Description
src/RazorConsole.Tests/ConsoleAppTests.cs Refactored existing test to use Configure<ConsoleAppOptions>() and added new test for default options resolution
src/RazorConsole.Core/AppHost.cs Changed registration to resolve ConsoleAppOptions from IOptions<ConsoleAppOptions> using a factory
examples/LLMAgentTUI/Program.cs Updated example to use Configure<ConsoleAppOptions>() pattern instead of manual singleton registration

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
@LittleLittleCloud LittleLittleCloud enabled auto-merge (squash) October 23, 2025 02:45
@LittleLittleCloud LittleLittleCloud merged commit 5044536 into RazorConsole:main Oct 23, 2025
4 checks passed
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.

Use IOptions pattern to bind ConsoleOptions rather than AddSingleton

3 participants