s&box/field-guide
tag

#razor

14 items (14 fixes)

fixes
26.07
"@ref on a bare private field silently never assigns"

@ref on a private field compiles with only a CS0649 warning — the ref stays null at runtime. Bind to a property instead.

26.07
"Assembly.cs global usings as project bootstrap"

global using Sandbox + your razor namespace in Assembly.cs — without it, panels and game types don't resolve across the assembly.

26.07
"Building a draggable slider with click-to-jump and drag-to-scrub"

No native drag helper exists for PanelComponent sliders — use the engine's SliderControl pattern: MousePanelEvent.LocalPosition over track width, with pointer-events routing.

26.07
"Building an s&box HUD"

One ScreenPanel host, static UIState for modals, self-closing panels, toast stack — BuildHash every flag the markup reads.

26.07
"Editing .razor safely (shell/emoji mojibake)"

Razor HUD emoji and dashes die under Get-Content/Set-Content — edit with byte-safe UTF-8 APIs or a real editor.

26.07
"Headless dotnet build misses Razor compile errors"

dotnet build reports 0 errors on .razor files the in-editor compiler rejects — the headless build doesn't surface the Razor errors the live editor's Roslyn compiler flags.

26.07
"My s&box UI won't update / is frozen"

BuildHash() is the only re-render trigger — hash everything the markup reads, including collection contents and flags.

26.07
"New .razor.scss files are not applied until the editor restarts"

A newly created .razor.scss file is not picked up by a running editor session — the panel component works but is unstyled until the next restart.

26.07
"PanelComponent uses OnTreeBuilt, not OnAfterTreeRender"

OnAfterTreeRender(bool) is a Panel hook — on a PanelComponent it fails with CS0115; use parameterless OnTreeBuilt() or OnTreeFirstBuilt().

26.07
"Runtime textures for UI panels must be assigned from C#"

SCSS background-image only resolves asset paths — runtime Texture objects must be assigned via Panel.Style.BackgroundImage in OnTreeBuilt.

26.07
"TextEntry is the house control, not HTML input"

Use TextEntry with onsubmit and OnTextEdited — standard Blazor input bindings compile but are not how the engine UI works.

26.07
"TextEntry.OnTextEdited needs an explicit-type block lambda"

An untyped or expression-bodied lambda on TextEntry.OnTextEdited fails with CS8917 or CS0029 — use an explicit param type plus a block body.

26.07
"The Razor @namespace trap"

Razor classes get a RootNamespace/folder-derived namespace — declare @namespace and global using or C# can't find your panels.

26.07
"Whitespace next to a Razor tag or expression boundary collapses to nothing"

Literal spaces adjacent to a tag or @-expression boundary vanish in Razor markup — use a single interpolated string or CSS margin instead.