Skip to content

[Blazor] Clear caches on HotReload #62880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 25, 2025

Conversation

maraf
Copy link
Member

@maraf maraf commented Jul 23, 2025

Clear more caches when HotReload deltas are applied.

  • ComponentProperties (affected by Update metadata when entities are deleted by an EnC edit runtime#75154)
  • DefaultComponentActivator (cleared from renderer, but not sufficient for RazorComponentResult)
  • ComponentFactory (cleared from renderer, but not sufficient for RazorComponentResult)
  • BindConverter.FormatterDelegateCache
  • BindConverter.ParserDelegateCache
  • AttributeAuthorizeDataCache
  • PersistentStateValueProvider
  • EventArgsTypeCache
  • RouteTable
  • EndpointComponentState

Fixes #43780

@maraf maraf added this to the 10.0-rc1 milestone Jul 23, 2025
@maraf maraf self-assigned this Jul 23, 2025
@maraf maraf added the area-blazor Includes: Blazor, Razor Components label Jul 23, 2025
@maraf maraf changed the title [Blazor] Clear ComponentProperties cache on HotReload [Blazor] Clear caches on HotReload Jul 24, 2025
@maraf maraf marked this pull request as ready for review July 24, 2025 11:41
@Copilot Copilot AI review requested due to automatic review settings July 24, 2025 11:41
@maraf maraf requested a review from a team as a code owner July 24, 2025 11:41
Copy link
Contributor

@Copilot 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 implements comprehensive cache clearing functionality for Blazor's Hot Reload feature to ensure that cached data is properly invalidated when code changes are applied during development. The changes address issue #43780 where various caches were not being cleared, leading to stale data during Hot Reload scenarios.

  • Adds static constructors with Hot Reload event handlers to clear caches across multiple Blazor components
  • Registers cache clearing callbacks for component properties, activators, binding converters, and routing tables
  • Includes project file updates to ensure HotReloadManager.cs is available in required assemblies

Reviewed Changes

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

Show a summary per file
File Description
ExpressionFormatter.cs Adds Hot Reload cache clearing for expression formatting
FieldIdentifier.cs Adds Hot Reload cache clearing for field accessors
EndpointComponentState.cs Adds Hot Reload cache clearing for streaming rendering attributes
RouteTable.cs Adds Hot Reload cache clearing for route entry cache
EventArgsTypeCache.cs Adds Hot Reload cache clearing for event args type cache
ComponentProperties.cs Adds Hot Reload cache clearing for component properties
PersistentStateValueProvider.cs Adds Hot Reload cache clearing for property getters and serializers
PersistentServicesRegistry.cs Adds Hot Reload cache clearing for properties accessor cache
DefaultComponentActivator.cs Adds Hot Reload cache clearing for component type info
ComponentFactory.cs Adds Hot Reload cache clearing for component type info cache
BindConverter.cs Adds Hot Reload cache clearing for formatter and parser delegate caches
AttributeAuthorizeDataCache.cs Adds Hot Reload cache clearing for authorize data cache
Microsoft.AspNetCore.Components.Endpoints.csproj Includes HotReloadManager.cs in compilation
Microsoft.AspNetCore.Components.Authorization.csproj Includes HotReloadManager.cs in compilation

@maraf
Copy link
Member Author

maraf commented Jul 25, 2025

/ba-g Failure is #62672

@maraf maraf merged commit b83721c into dotnet:main Jul 25, 2025
29 of 30 checks passed
@maraf
Copy link
Member Author

maraf commented Jul 25, 2025

/backport to release/10.0-preview7

@maraf maraf deleted the BlazorHotReloadComponentPropertiesCache branch July 25, 2025 08:50
Copy link
Contributor

Started backporting to release/10.0-preview7: https://github.com/dotnet/aspnetcore/actions/runs/16517930105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider invalidating ComponentProperties cache when Hot Reload triggers metadata update
2 participants