Skip to content

Use interface instead of implementation in UseRazorConsole extension method.#45

Merged
LittleLittleCloud merged 6 commits intoRazorConsole:mainfrom
DericHuynh:main
Oct 22, 2025
Merged

Use interface instead of implementation in UseRazorConsole extension method.#45
LittleLittleCloud merged 6 commits intoRazorConsole:mainfrom
DericHuynh:main

Conversation

@DericHuynh
Copy link
Contributor

@DericHuynh DericHuynh commented Oct 22, 2025

Closes #44

This PR makes the following changes:

  • Change HostApplicationBuilder to IHostApplicationBuilder for more flexibility and to support any implementation
  • Separate CreateApplicationBuilder from UseRazorConsole in console tests due to errors (var automatically binds to interface if you chain fluent style which doesnt allow Build() method to be called).

This references #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 6 commits October 15, 2025 16:02
- Change HostApplicationBuilder to IHostApplicationBuilder for more flexibility
- Separate CreateApplicationBuilder from UseRazorConsole for cleaner code style
- Update tests to follow non-fluent pattern
Use IHostApplicationBuilder interface and improve code style
@DericHuynh DericHuynh marked this pull request as ready for review October 22, 2025 21:58
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 updates the UseRazorConsole extension method to accept IHostApplicationBuilder instead of the concrete HostApplicationBuilder type, enabling support for alternative implementations like WebApplicationBuilder. The change improves flexibility by following the dependency inversion principle.

Key changes:

  • Modified the extension method signature to use the interface type
  • Updated XML documentation to reflect the interface usage
  • Refactored test code to avoid fluent chaining issues caused by interface return types

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/RazorConsole.Core/AppHost.cs Changed method parameter and return type from HostApplicationBuilder to IHostApplicationBuilder with updated documentation
src/RazorConsole.Tests/ConsoleAppTests.cs Split fluent method chain into separate statements to work around type inference limitations with interface returns

Copy link
Member

@LittleLittleCloud LittleLittleCloud left a comment

Choose a reason for hiding this comment

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

thanks!

@LittleLittleCloud LittleLittleCloud merged commit 7043ca5 into RazorConsole:main Oct 22, 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 IHostApplicationBuilder instead of HostApplicationBuilder in hosting extension method

3 participants