Skip to content

Engine: Split FHIR facade services from MVC#1262

Open
losolio wants to merge 1 commit into
FirelyTeam:masterfrom
losolio:refactor/split-fhir-facade-services
Open

Engine: Split FHIR facade services from MVC#1262
losolio wants to merge 1 commit into
FirelyTeam:masterfrom
losolio:refactor/split-fhir-facade-services

Conversation

@losolio
Copy link
Copy Markdown
Collaborator

@losolio losolio commented May 21, 2026

Introduce AddFhirFacadeServices for registering the FHIR facade service layer without calling AddControllers or registering MVC formatter services.

Add AddFhirFacadeMvc as the explicit replacement for the previous MVC-based facade setup, and mark AddFhirFacade obsolete so beta users get a clear migration path.

Move FHIR MVC formatter service registrations behind AddFhirMvcFormatterServices and add a contract test covering the MVC-free facade registration.

Copilot AI review requested due to automatic review settings May 21, 2026 21:26
Copy link
Copy Markdown

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 decouples the Spark Engine “FHIR facade” service-layer registrations from ASP.NET Core MVC, enabling consumers to register the facade without implicitly adding controllers/formatters, while preserving the prior behavior behind an explicit MVC-oriented extension method.

Changes:

  • Added AddFhirFacadeServices to register the FHIR facade service layer without calling AddControllers / MVC service registration.
  • Added AddFhirFacadeMvc as the explicit MVC-based facade setup and marked AddFhirFacade obsolete to guide migration.
  • Moved MVC formatter service registrations behind a dedicated helper and added a contract test ensuring MVC-free facade registration.

Reviewed changes

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

File Description
Tests/Spark.Engine.R4.Tests/Extensions/FhirFacadeServiceCollectionExtensionsTests.cs Adds a contract test verifying AddFhirFacadeServices does not register MVC/controller-related services while still registering required facade components.
Libraries/Spark.Engine/Extensions/IServiceCollectionExtensions.cs Introduces the new facade registration APIs, routes legacy AddFhirFacade to the MVC path, and isolates MVC formatter registrations behind a helper.
Comments suppressed due to low confidence (1)

Libraries/Spark.Engine/Extensions/IServiceCollectionExtensions.cs:104

  • AddFhirFacadeServicesInternal builds a temporary ServiceProvider to read configured SparkOptions, but it is never disposed. Wrap the BuildServiceProvider() result in a using/using var to avoid leaking the root provider (and any transient/singleton disposables created during resolution).
        services.Configure(options);

        var serviceProvider = services.BuildServiceProvider();
        var opts = serviceProvider.GetRequiredService<IOptions<SparkOptions>>()?.Value;
        var settings = opts.Settings;

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

}

private static void AddFhirMvcFormatterServices(this IServiceCollection services)
{
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — Iremoved AddFhirMvcFormatterServices entirely in a follow-up instead. Nothing in Applications/ or Libraries/ resolves these four formatters from DI; they're constructed manually inside AddFhirFormatters (with ArrayPool.Shared) and inserted into MvcOptions.InputFormatters/OutputFormatters. The TryAddTransient lines seems to be dead code — the bug only surfaced because the new test was the first thing that tried to resolve them?

Comment thread Libraries/Spark.Engine/Extensions/IServiceCollectionExtensions.cs
Introduce AddFhirFacadeServices for registering the FHIR facade service layer
without calling AddControllers or registering MVC formatter services.

Add AddFhirFacadeMvc as the explicit replacement for the previous MVC-based
facade setup, and mark AddFhirFacade obsolete so users get a clear
migration path.

Drop the TryAddTransient registrations for ResourceJson/XmlInput/OutputFormatter
from both the facade and AddFhirInternal — nothing resolved them from DI, and
the formatters are still constructed manually and inserted into
MvcOptions.InputFormatters/OutputFormatters by AddFhirFormatters when wiring up
the MVC pipeline.

Add a contract test covering the MVC-free facade registration.
@losolio losolio force-pushed the refactor/split-fhir-facade-services branch from 54b6427 to 8c25f91 Compare May 21, 2026 22:05
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