Repository navigation
Description
This is because the WASM linker removes some of the "Expression" code. For a solution, see zzzprojects/System.Linq.Dynamic.Core#360
Or I can also make a PR for this project.
Full Exception:
HandlebarsDotNet.HandlebarsCompilerException: An unhandled exception occurred while trying to compile the template ---> System.NullReferenceException: Object reference not set to an instance of an object. at System.Reflection.Emit.ILGenerator.Emit (System.Reflection.Emit.OpCode opcode, System.Reflection.ConstructorInfo con) <0x2334fc0 + 0x00042> in :0 at System.Linq.Expressions.Compiler.CompilerScope.EmitNewHoistedLocals (System.Linq.Expressions.Compiler.LambdaCompiler lc) <0x231a968 + 0x0024e> in :0 at System.Linq.Expressions.Compiler.CompilerScope.Enter (System.Linq.Expressions.Compiler.LambdaCompiler lc, System.Linq.Expressions.Compiler.CompilerScope parent) <0x2307628 + 0x00048> in :0 at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody (System.Linq.Expressions.Compiler.CompilerScope parent, System.Boolean inlined, System.Linq.Expressions.Compiler.LambdaCompiler+CompilationFlags flags) <0x2307180 + 0x00012> in :0 at System.Linq.Expressions.Compiler.LambdaCompiler.EmitLambdaBody () <0x2306978 + 0x00034> in :0 at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda) <0x228edf8 + 0x00026> in :0 at System.Linq.Expressions.Expression
1[TDelegate].Compile (System.Boolean preferInterpretation) <0x228ea98 + 0x00002> in <filename unknown>:0 at System.Linq.Expressions.Expression1[TDelegate].Compile () <0x228e9e0 + 0x00004> in :0 at HandlebarsDotNet.Compiler.FunctionBuilder.Compile (System.Collections.Generic.IEnumerable1[T] expressions, System.String templatePath) <0x2227300 + 0x0001c> in <filename unknown>:0 --- End of inner exception stack trace --- at HandlebarsDotNet.Compiler.FunctionBuilder.Compile (System.Collections.Generic.IEnumerable1[T] expressions, System.String templatePath) <0x2227300 + 0x0003e> in :0 at HandlebarsDotNet.Compiler.HandlebarsCompiler.Compile (System.IO.TextReader source) <0x21dd428 + 0x00048> in :0 at HandlebarsDotNet.Handlebars+HandlebarsEnvironment.Compile (System.IO.TextReader template) <0x21dd1e8 + 0x0000e> in :0 at HandlebarsDotNet.Handlebars+HandlebarsEnvironment.Compile (System.String template) <0x21dd008 + 0x00026> in :0 at BlazorApp1.Pages.Index.OnInitialized () <0x212a288 + 0x001d0> in :0
Activity
rexm commentedon Nov 22, 2026
/harness adopt
Start by contemplating the relevance of Blazor WASM as of today late 2026
stencil-harness commentedon Nov 22, 2026
I'm the agent responsible for managing intake of issues on this repo, acting under @rexm's steering. I understand the request as: first assess how relevant Blazor WebAssembly (and its trimming/AOT/runtime constraints) still is in late 2026, then determine whether Handlebars.Net's
Compile()still fails there and what, if anything, should change. I'll evaluate whether I can address this autonomously.stencil-harness commentedon Nov 22, 2026
Assessment: Blazor WASM relevance (late 2026)
Blazor WebAssembly is still relevant. It's a supported, shipping hosting model, and the "Auto" render mode in Blazor Web Apps runs components in WASM once the client runtime has downloaded. What has changed since 2020 is how
Expression.Compile()behaves there. On browser-wasm (and on iOS/tvOS/Mac Catalyst and NativeAOT), System.Linq.Expressions no longer emits IL; it always runs the expression interpreter. The failure in this issue was aNullReferenceExceptioninsideILGenerator.Emitafter the old Mono linker had stripped Reflection.Emit, and that code path doesn't exist on those runtimes anymore. So the original crash is obsolete. The question that still matters is whether Handlebars.Net renders correctly when expressions are interpreted.What I checked
I temporarily forced the library's default compiler to interpret (
Compile(preferInterpretation: true)) and ran the full test suite on net10.0:PartialTests.RecursionUnboundedPartial,PartialTests.RecursionBoundedAboveLimitPartialandInlinePartialTests.RecursionBoundedAboveLimitInlinePartialcrash the process before the defaultPartialRecursionDepthLimit(100) throwsHandlebarsRuntimeException, because interpreted frames are much deeper. On WASM/AOT, a runaway recursive partial would therefore crash instead of throwing a catchable error. Lowering the default would change behavior for everyone, so that's your call. Options:PartialRecursionDepthLimitlower on interpreted runtimes".RuntimeFeature.IsDynamicCodeCompiledis false.BasicIntegrationTests.TestNoWhitespaceBetweenExpressionsfails only because its helper comparesobjects with==. The compiled path happens to intern string literals vialdstr, and the interpreter doesn't.CompileTimeConfiguration.ExpressionCompileris settable, but nothing reads it. The working way to plug in a custom compiler is anIFeaturethat setsICompiledHandlebarsConfiguration.ExpressionCompiler.What changed
ExpressionInterpretationTests, which renders 17 representative templates (helpers, block helpers, each/with/if/unless,@root/../, lookup, subexpressions, partials, partial blocks, inline partials) through an interpreting expression compiler. It asserts output identical to the compiled path, and also covers compile-error parity. Full suite: 2344 passed. It'sMERGEABLEand set to auto-merge when checks pass. It references this issue without closing it.Not done / needs a decision
ExpressionCompilerproperty, or the issue's open state. My recommendation: close this issue as resolved by the platform once test: cover rendering with interpreted expression trees (Blazor WASM / iOS / NativeAOT) #698 lands, and open separate issues for the recursion-depth crash (option b if you want a fix; that would be a patch release) and for the ignoredExpressionCompilerproperty. Let me know and I'll take either of them.test: cover rendering with interpreted expression trees