Skip to content

Use IHostApplicationBuilder interface and improve code style#1

Merged
DericHuynh merged 10 commits intomainfrom
use-ihostapplicationbuilder
Oct 22, 2025
Merged

Use IHostApplicationBuilder interface and improve code style#1
DericHuynh merged 10 commits intomainfrom
use-ihostapplicationbuilder

Conversation

@DericHuynh
Copy link
Owner

This PR makes the following changes:

  • Change HostApplicationBuilder to IHostApplicationBuilder for more flexibility and to support any implementation
  • Separate CreateApplicationBuilder from UseRazorConsole for cleaner code style
  • Update tests to follow non-fluent pattern

This addresses issue RazorConsole#41 by moving the extension method to work with the interface instead of the concrete implementation, allowing users to use other implementations such as WebApplicationBuilder.

Changes:

  • Updated AppHost.cs to use IHostApplicationBuilder
  • Modified ConsoleAppTests.cs to avoid fluent API chaining
  • Verified all examples follow clean code style

DericHuynh and others added 10 commits October 16, 2025 07:56
* Implemented custom IComponentActivator to allow for constructor injection.

* Added Tests for ComponentActivator

* Remove changes made by my Code Cleanup profile.

* Fixed accesibility modifiers of test classes.
Co-authored-by: LittleCloud <littlecloud@LittleClouds-MacBook-Pro.local>
…or custom translators (RazorConsole#36)

* Initial plan

* Expose IVdomElementTranslator and replace MEF with Service Provider

- Made IVdomElementTranslator and TranslationContext public
- Made VdomSpectreTranslator public with public constructor
- Exposed utility methods as public static methods
- Made IAnimatedConsoleRenderable public
- Removed MEF (System.Composition) dependency entirely
- Created VdomTranslatorServiceCollectionExtensions for registering translators with priority
- Updated AppHost to register default translators via DI
- Updated ConsoleRenderer to accept VdomSpectreTranslator from DI
- Updated all translator files to remove [Export] attributes
- Updated all Razor components to remove System.Composition using
- Created TestHelpers for test renderer creation
- Added CustomTranslatorTests to validate custom translator registration
- All 63 tests pass successfully

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>

* Restructure VDOM translators based on review feedback

- Moved IVdomElementTranslator to its own file with Priority property
- Moved TranslationContext to its own file (no longer nested)
- Converted all translator classes from nested to standalone classes
- Each translator now implements Priority property directly
- Removed PrioritizedTranslator wrapper class
- Removed IPrioritizedTranslator interface
- Updated registration to use Priority property from interface
- Updated all tests and helper methods
- All 63 tests pass successfully

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>

* Add comprehensive design doc for custom VDOM translators

- Created custom-translators.md with detailed guide
- Covers architecture, built-in translators, and extensibility
- Includes examples for creating custom translators
- Documents utility methods and best practices
- Provides troubleshooting and testing guidance

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>

* Refactor Vdom translator registration to use CreateDefaultTranslators method for improved maintainability and ordering

* Update README with custom translators section

- Added comprehensive Custom Translators section after Built-in Components
- Includes example of creating a custom translator (OverflowElementTranslator)
- Shows registration pattern using AddVdomTranslator
- Demonstrates usage in Razor components
- Links to detailed design doc for advanced scenarios

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>

* Change VdomSpectreTranslator to order translators by ascending priority

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Co-authored-by: LittleLittleCloud <g2260578356@gmail.com>
* Initial plan

* Add Discord badge and server link to README

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>

* Move Discord badge to separate line

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
…onsole#23)

* Implement using background service and HostApplicationBuilder. Facilitates using other hosted BackgroundService(s) to update the UI

* Fix style

* Some tidy up, dont bury exceptions from a faulted service

* Bump the package minor version

* Update src/RazorConsole.Core/AppHost.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>

---------

Signed-off-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
Co-authored-by: Xiaoyun Zhang <bigmiao.zhang@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Change HostApplicationBuilder to IHostApplicationBuilder for more flexibility
- Separate CreateApplicationBuilder from UseRazorConsole for cleaner code style
- Update tests to follow non-fluent pattern
@DericHuynh DericHuynh merged commit 4887ac9 into main Oct 22, 2025
3 checks passed
@DericHuynh DericHuynh deleted the use-ihostapplicationbuilder branch October 23, 2025 00:38
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.

4 participants