The page compiler
uk.osric.asp.Runtime
AccessibleTableRenderer
style attribute and
writes header cells without a scope. The site's CSP is style-src 'self' with no
'unsafe-inline', and its accessibility rules require a scope on every header cell, so
both profiles use this renderer instead: alignment is ignored and every header cell is a column
header.
CompileResult
MethodCompileResult(byte[] Image, byte[] Symbols, IReadOnlyList<PageDiagnostic> Diagnostics)
Parameters
Image- The emitted assembly, or
nullwhen compilation failed. Symbols- The emitted portable PDB, or
nullwhen compilation failed. Diagnostics- The author-facing diagnostics, errors and warnings, in template space. Empty when the page compiled cleanly. Compilation.PageDiagnostic values rather than Roslyn types keep Roslyn out of the shell.
PropertyImage
null when compilation failed.PropertySymbols
null when compilation failed.PropertyDiagnostics
PropertyIsSuccess
PropertyLibraries
PropertyKind
null when it
refined nothing. Generation can tell a template has only declarations; whether those
declarations are a Worker is a question only the compiled types answer.
DiffRenderer
ToHtml is the page capability and the editor's view. It escapes every source line, so the result is safe for any string, and writes no inline style: the table, the hunk row, the change markers and the sideways scroll container are all classes the site's sheets style.
ToUnifiedDiff is the assistant's form, beside the table the way ToRestrictedHtml sits beside the page profile. It is not on the Sdk capability, because a page does not need text; a page that does can render the changes itself.
The renderer is stateless. The diff itself is pure and bounded by Diff.LineDiff.
MethodToHtml(string, string)
Inherited from IDiffRenderer.ToHtml.
Parameters
before- The earlier document.
after- The later document.
Returns
<%== %>.Exceptions
ArgumentNullException- Either document is
null.
MethodCompare(string before, string after)
Parameters
before- The earlier document.
after- The later document.
Returns
Exceptions
ArgumentNullException- Either document is
null.
MethodToUnifiedDiff(string before, string after)
Parameters
before- The earlier document.
after- The later document.
Returns
Exceptions
ArgumentNullException- Either document is
null.
IPageCompiler
PropertyRuntimeId
MethodCompile(GeneratedSource source, IReadOnlyList<LibrarySource> libraries, CancellationToken cancellationToken)
Parameters
source- The generated page source, not the page template.
libraries-
Every library the page could name, or an empty list when it names none. The compiler keeps the
ones the page's
usingdirectives reach, and their own, and compiles them into the page's assembly. cancellationToken- Bounds the compile. Roslyn observes it between operations rather than inside one, so it is a coarse bound on a pathological template, not a hard one.
Returns
Exceptions
InvalidOperationException- The generated source itself is broken. A fault is not a page diagnostic and must reach the shell as an exception.
MethodCompileWorker(GeneratedSource source, IReadOnlyList<LibrarySource> libraries, CancellationToken cancellationToken)
Parameters
source- The declarations the template contributes, generated by GenerateLibrary rather than as a page.
libraries- Every library the source could name, or an empty list when it names none.
cancellationToken- Bounds the analysis. Roslyn observes it between operations rather than inside one.
Returns
Exceptions
InvalidOperationException- The generated source itself is broken. A fault is not an author diagnostic and must reach the shell as an exception.
MethodLoad(byte[] image, byte[] symbols)
Parameters
image- The bytes an earlier Compile emitted.
symbols- The portable PDB bytes emitted with the image, if present.
Returns
MethodLoadWorker(byte[] image, byte[] symbols)
Parameters
image- The bytes an earlier CompileWorker emitted.
symbols- The portable PDB bytes emitted with the image, if present.
Returns
Exceptions
InvalidOperationException- The image does not declare exactly one worker entry point, so there is nothing to run.
JavaScriptValidator
return is an error and a duplicated top-level declaration is a redeclaration.
MethodValidate(string script)
Parameters
script- The JavaScript to parse.
Returns
Exceptions
ArgumentNullExceptionscriptisnull.
LibrarySource
MethodLibrarySource(string Key, GeneratedSource Source)
Parameters
Key- The library's canonical key, which is how a diagnostic names it.
Source- The declarations the library contributes, generated by GenerateLibrary rather than as a page.
PropertyKey
PropertySource
LoadedPage
Nothing here suppresses inlining: MethodInfo.Invoke throws its wrapper whether or not the
caller was inlined, and ExceptionDispatchInfo restores the original stack. If
unloading a collectible context ever appears to hang, inlining is the knob to revisit.
MethodInvokeAsync(IContext context)
Parameters
context- The context the page writes to.
Returns
Exceptions
Exception- Whatever the page threw, unwrapped.
MethodDispose()
LoadedWorker
MethodLoadedWorker(byte[] image, byte[] symbols)
Parameters
image- The bytes an earlier CompileWorker emitted.
symbols- The portable PDB bytes emitted with the image, if present.
Exceptions
InvalidOperationException- The assembly does not declare exactly one worker entry point.
MethodCreate()
Returns
MethodDispose()
MarkdownRenderer
The page profile is CommonMark with heading anchors, pipe tables and auto-links, and raw HTML passes through: IMarkdownRenderer says what that means for a page author (`pages-markdown`). A page switches those three features per call with MarkdownOptions.
The restricted profile is for model output. Raw HTML is rendered as text, there are no autolinks
or images, links pass Markdown.LinkPolicy, and every heading is written as
h3 so a model-chosen level cannot skip one in the transcript. Both profiles use the
site's table renderer, which writes scope="col" and no inline style (`pages-markdown`).
The parser pipelines are built once per option set and are safe to share. Markdig's
HtmlRenderer is stateful, so one is created for each call.
MethodToHtml(string)
Inherited from IMarkdownRenderer.ToHtml.
Parameters
markdown- The Markdown to render. Raw HTML in it is passed through.
Returns
<%== %>.Exceptions
ArgumentNullExceptionmarkdownisnull.
MethodToHtml(string, MarkdownOptions)
Inherited from IMarkdownRenderer.ToHtml.
Parameters
markdown- The Markdown to render. Raw HTML in it is passed through.
options- The features to switch on or off for this render.
Returns
<%== %>.Exceptions
ArgumentNullException-
markdownoroptionsisnull.
MethodToRestrictedHtml(string markdown)
Parameters
markdown- The Markdown to render.
Returns
Exceptions
ArgumentNullExceptionmarkdownisnull.
PageApiChecker
Core does not have to: the walk turns symbols into plain
Compilation.ApiReference values and the policy decides. The shape rule is separate from the API
list because it is about the generated source as a whole rather than any one symbol.
MethodCheck(SyntaxTree tree, SemanticModel model, IReadOnlyCollection<SyntaxTree> authored)
Parameters
tree- The parsed generated source.
model- The semantic model bound to
tree. authored-
Every tree the page may call as its own code — itself and the libraries it pulled in — or
nullwhen it named none. Each one is checked in its own right; this is only what stops a page's own declared types looking foreign.
Returns
Exceptions
InvalidOperationException- The generated source itself violates the policy. That is a compiler fault, not a page error.
MethodCheckLibrary(SyntaxTree tree, SemanticModel model, IReadOnlyCollection<SyntaxTree> authored)
Parameters
tree- The parsed generated library source.
model- The semantic model bound to
tree. authored- The trees whose own types the policy trusts; the library and its closure when omitted.
Returns
Exceptions
InvalidOperationException- The generated source itself violates the policy. That is a compiler fault, not an author's error.
PageCompiler
MethodPageCompiler()
Exceptions
InvalidOperationException- The runtime does not describe its platform assemblies, so no page could be compiled.
PropertyRuntimeId
MethodCompile(GeneratedSource source, IReadOnlyList<LibrarySource> libraries, CancellationToken cancellationToken)
Parameters
source- The generated C# source, not the page template.
libraries- The compiled sources the page named, in closure order.
cancellationToken- Bounds the compile between Roslyn operations.
Returns
Exceptions
InvalidOperationException- The generated source itself is broken. A diagnostic without a template position means the fault is in code the generator wrote, not in the page, so it must not be shown to the author.
MethodCompileWorker(GeneratedSource, IReadOnlyList<LibrarySource>, CancellationToken)
MethodLoad(byte[] image, byte[] symbols)
Parameters
image- The bytes an earlier Compile emitted.
symbols- The portable PDB emitted beside the image, when there was one.
Returns
MethodLoadWorker(byte[] image, byte[] symbols)
Parameters
image- The bytes an earlier CompileWorker emitted.
symbols- The portable PDB emitted beside the image, when there was one.
Returns
PageLoadContext
A page may use the SDK and the base class library, but not the site: naming one of the shell's
own assemblies resolves here, and this context refuses it instead of falling back to the default
one. Throwing rather than returning null is the point - null
means "ask the default context", which is how a page could otherwise reach
uk.osric.asp.Web by name.
uk.osric.asp.Sdk is deliberately not denied: it is the page contract, and the fallback to
the default context hands the page the same copy of IContext the
host is using, so the handler signature matches.
uk.osric.asp.Core is host support — the template pipeline, diagnostics and charts — and is
denied like the rest of the site. A page names the SDK and the base class library, nothing else.
This is isolation from the app's internals, not a sandbox. A page still runs with the site's identity and can use the base class library; only the shell and the web stack are out of reach.
MethodPageLoadContext()
A page may use the SDK and the base class library, but not the site: naming one of the shell's
own assemblies resolves here, and this context refuses it instead of falling back to the default
one. Throwing rather than returning null is the point - null
means "ask the default context", which is how a page could otherwise reach
uk.osric.asp.Web by name.
uk.osric.asp.Sdk is deliberately not denied: it is the page contract, and the fallback to
the default context hands the page the same copy of IContext the
host is using, so the handler signature matches.
uk.osric.asp.Core is host support — the template pipeline, diagnostics and charts — and is
denied like the rest of the site. A page names the SDK and the base class library, nothing else.
This is isolation from the app's internals, not a sandbox. A page still runs with the site's identity and can use the base class library; only the shell and the web stack are out of reach.
MethodLoad(AssemblyName)
Exceptions
NotSupportedException- The page tried to load an assembly it may not use.
PageReferenceSet
MethodForPages()
Returns
Exceptions
InvalidOperationException- The runtime did not describe its platform assemblies, or described none that pages can use.
MethodReferencedPaths(string trustedPlatformAssemblies)
Parameters
trustedPlatformAssemblies-
The runtime's
TRUSTED_PLATFORM_ASSEMBLIESvalue, as read from AppContext.GetData.
Returns
Exceptions
InvalidOperationException- The value is missing, empty, or names no assembly every page is built on.
RestrictedHeadingRenderer
h2 naming the speaker, and a model chooses its own heading
depth without seeing the document it lands in. Flattening to h3 means no heading can skip
a level, at the cost of the model's own hierarchy, which the text can say anyway.
RestrictedLinkRenderer
img: its alt text is written instead, so a Markdown image cannot
load a remote resource. A refused link keeps its text and loses its anchor, which makes a
hostile URL visible as the words the model wrote rather than a place to click.