Skip to content

Conversation

oroztocil
Copy link
Member

Changes

  • Adds DI registration for LazyAssemblyLoader in AddInteractiveWebAssemblyComponents.
  • Moves LazyAssemblyLoader to Microsoft.JSInterop`.
  • Adds type forwarding for the moved type in Microsoft.AspNetCore.Components.WebAssembly.

Reasoning

We want to register LazyAssemblyLoader in AddInteractiveWebAssemblyComponents in order to prevent the confusing situation where a component that injects LazyAssemblyLoader works in the WebAssembly client but crashes during prerendering. (Note that it works when the wasm client takes over because WebAssemblyHostBuilder.CreateDefault registers LazyAssemblyLoader.)

However, this could not be done as is without adding a problematic reference between projects. To avoid this, the PR moves LazyAssemblyLoader to the Microsoft.JSInterop project which is the only project that is already references by all other relevant projects and already has unsafe code enabled. This means no change in project configuration is needed. To ensure backwards compatibility, the moved type needs to be type forwarded in Microsoft.AspNetCore.Components.WebAssembly using the TypeForwardedTo assembly attribute.

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Apr 25, 2025
@oroztocil oroztocil closed this May 7, 2025
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview5 milestone May 7, 2025
@oroztocil oroztocil deleted the oroztocil/51966-lazy-loading-DI branch June 17, 2025 14:12
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.

1 participant