Repository navigation
Rewrite the Blazor integration page - #209
Merged
Merged
Conversation
Fixes #117. The page was written against .NET 5 and said so: "This example for WebAssembly works as of March 30, 2021 with .NET 5." It also framed Blazor as two hosting models, which predates the Blazor Web App and its render modes, and left a dangling "Example:" where a sentence had been split. It also carried a broken link. "`ASP.NET Core 3 <aspnetcore>`_" is external-link syntax with a relative target, so docutils treated "aspnetcore" as a URI and emitted href="aspnetcore" - an extensionless relative link that 404s. Sphinx cannot warn about this, because the markup is valid; it is only visible in the output. It is now a :doc: reference and resolves to aspnetcore.html. A scan of every page found no other instance. The page is now organized by where the code runs rather than by hosting model, which is what actually decides the wiring: server-side Blazor and the server project of a Blazor Web App are ordinary ASP.NET Core hosting and just point at that page, while WebAssembly needs WebAssemblyHostBuilder.ConfigureContainer because there is no Host property to attach a factory to. Adds two things a reader can act on. A Blazor Web App with WebAssembly interactivity has two projects and therefore two containers, so anything both sides resolve has to be registered twice - registrations on the server are not visible to components rendered on the client. And WebAssembly publishes with trimming on, which is a problem for a container that finds constructors by reflection, so the page points at the trimming guidance. Both AutofacServiceProviderFactory constructors were checked against the source; the existing sample's use of the configuration-action overload was correct and is kept.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #117.
Why
The page was written against .NET 5 and said so out loud: "This example for WebAssembly works as of March 30, 2021 with .NET 5." It framed Blazor as "two hosting models," which predates the Blazor Web App and render modes, and left a dangling
Example:where a sentence had been split.A broken link that
-Wcannot catchThat's external-link syntax with a relative target, so docutils treats
aspnetcoreas a URI and emits:An extensionless relative link that 404s. The markup is perfectly valid RST, so Sphinx has nothing to warn about — it's only visible in the output. Now a
:doc:reference, resolving toaspnetcore.html.This is the second defect class I've hit that a clean build can't detect, after the nested inline markup on #204. As with that one, I scanned every page for it rather than fixing the single instance:
`text <target>`_where the target has no URI scheme. One instance existed, this one. Both scans now run before I push.Reorganized by what decides the answer
The page is now structured by where the code runs, because that's what determines the wiring — not by hosting model:
WebAssemblyHostBuilder.ConfigureContainer, because there is noHostproperty to attach a service provider factory to. That's the actual reason the two differ, and it wasn't stated.Two things added that a reader can act on
A Blazor Web App with WebAssembly interactivity has two projects, so two containers. Registrations made in the server project are not visible to components rendered on the client, so anything both sides resolve has to be registered in both. That's the kind of thing you otherwise discover through a confusing runtime failure.
WebAssembly publishes with trimming enabled, which is a problem for a container that locates constructors by reflection. Points at the trimming page rather than duplicating it.
Verification
Both
AutofacServiceProviderFactoryconstructors were checked against source — the existing sample's use of the configuration-action overload was correct, so it's kept rather than churned. There's no Blazor project in the Examples repo (checked), so no example link to add.sphinx -b html -W --keep-going,doc8,pre-commitclean. Nested-markup and bad-link scans clean across all pages. Rendered HTML checked, including confirming the repaired reference now emitsaspnetcore.html.