Skip to content

Add asynchronous template file providers - #968

Merged
sebastienros merged 1 commit into
mainfrom
sebros/async-template-resolution
Jul 31, 2026
Merged

sebastienros merged 1 commit into
mainfrom
sebros/async-template-resolution

Conversation

@sebastienros

Copy link
Copy Markdown
Owner

Remote template stores such as S3, Azure Blob Storage, and databases expose asynchronous APIs, but Fluid previously resolved runtime templates through synchronous IFileProvider calls. This forced integrations to block during template lookup and content reads.

Summary

  • Introduces ITemplateFileProvider and TemplateSourceInfo for two-stage asynchronous metadata and content loading, including source versions and context-specific cache keys.
  • Adds adapters for existing IFileProvider implementations and delegate-based custom providers.
  • Routes include, render, from, views, partials, layouts, and _ViewStart files through the async provider contract.
  • Propagates TemplateContext.CancellationToken through loading, rendering checkpoints, enumeration, generated templates, and output writes. MVC and Minimal APIs use the request cancellation token.
  • Keeps MVC named-view discovery on a separate synchronous provider because ASP.NET Core's IViewEngine contract is synchronous.

Migration

This is an intentional Fluid 3.0 source-breaking change: TemplateOptions.FileProvider and the ViewEngine provider properties now accept ITemplateFileProvider. Existing providers can be wrapped with FileProviderTemplateFileProvider.

Tests

  • dotnet build --no-restore --nologo
  • dotnet test --no-build --no-restore
  • dotnet test --no-restore /p:Compiled=true

Fixes: #955

Replace synchronous runtime template resolution with cancellation-aware async providers across core tags, view engines, and Minimal APIs. Preserve existing IFileProvider integrations through an adapter and add contextual cache isolation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 377d3293-943b-436f-93ea-ffb6eecd0fb2
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.

Question: Async template resolution for remote storage (avoiding sync-over-async in IFileProvider)

1 participant