Self-host sample source code pages#16
Merged
Merged
Conversation
Embed Pages\**\*.razor[.cs] in Core.Sample.Shared and Pro.Sample.Shared
as managed resources, and resolve them via a new ISampleSourceProvider
keyed on the page Type's assembly. The /source-code/{name} page now
loads from the local assembly instead of fetching .razor.txt from
docs.geoblazor.com.
- Move SourceNav and SourceCode from Pro.Sample.Shared to
Core.Sample.Shared so both Core and Pro hosts get the feature
- Default Core MainLayout.AdditionalLinksType to typeof(SourceNav)
- Register ISampleSourceProvider in all 8 hosts (Core/Pro x
Wasm/WebApp Server/WebApp Client/Maui)
- Retire DocsUrl plumbing: drop the -d/--docs-url flag and JSON
emission from BuildAppSettings.cs, and remove the dev override
from Pro WebApp appsettings.Development.json
Self-hosting eliminates the runtime dependency on the docs site and
makes Source Code work offline (relevant for the MAUI hosts).
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.
Summary
.razor/.razor.csfrom embedded resources inCore.Sample.SharedandPro.Sample.Sharedinstead of fetching.razor.txtfromdocs.geoblazor.comat runtime.DocsUrlplumbing (build script flag, JSON emission, dev appsettings override) is retired.Why
The runtime fetch coupled the samples to an external host that has to be online, CORS-friendly, and kept in lockstep with whatever ships in this repo. It also broke offline scenarios — most notably the MAUI hosts. Embedding the source in the assembly that compiles it eliminates the network hop and the drift risk.
Implementation notes
Pages\**\*.razor[.cs]are added asEmbeddedResourceitems in both Shared.csprojfiles with stableSampleSource/{File}LogicalNames. Razor SDK still compiles.razorfiles normally —EmbeddedResourceis additive.ISampleSourceProvider(Shared/SampleSourceProvider.csin Core.Sample.Shared) reads frompageType.Assembly.GetManifestResourceStream(...), so a Pro app rendering a Core page resolves source from Core, not Pro.SourceNav+SourceCodemoved into Core.Sample.Shared; Pro inherits via existingProjectReference.MainLayout.AdditionalLinksTypenow defaults totypeof(SourceNav)so Core hosts pick it up automatically; Pro's existing override is unchanged.SourceCode.razor.csresolves the pageTypeby scanning loaded*Sample.Sharedassemblies for routable components by name (lazy-cached). Preserves the existing/source-code/{Name}URL contract, the@code-block split, and the## Filenameheadings.Test plan
dotnet buildCore WebApp host — passes (verified locally)dotnet buildPro WebApp host — passes (verified locally)dotnet buildCore Wasm host — passes (verified locally)dotnet buildPro Wasm host — passes (verified locally)docs.geoblazor.comin DevTools Network.razor.cscode-behind (e.g.CustomPopupContents,StyledGeoJSONLayers,UniqueValueRenderers) and verify both## Foo.razorand## Foo.razor.cssections render/p:UseProjectReferences=trueto confirmRazorCopy.dlland the new embedded resources coexist