Skip to content

fix: remove byref delegate parameters incompatible with Mono/Xamarin (issue #458)#632

Merged
rexm merged 4 commits into
masterfrom
worktree-agent-a88db3c552c4be375
Jun 20, 2026
Merged

fix: remove byref delegate parameters incompatible with Mono/Xamarin (issue #458)#632
rexm merged 4 commits into
masterfrom
worktree-agent-a88db3c552c4be375

Conversation

@rexm

@rexm rexm commented Jun 20, 2026

Copy link
Copy Markdown
Member

Fixes #458

Summary

  • TemplateDelegate and DecoratorDelegate used in EncodedTextWriter parameters, which at the IL level are ref readonly (byref) types
  • On Mono/Xamarin.iOS, Expression.Lambda compilation of delegates with byref parameters throws System.NotImplementedException: byref delegate
  • Removed in from both delegate declarations so the parameter is passed by value
  • Removed MakeByRefType() from CompilationContext so expression tree parameters match the updated delegate signatures
  • Updated lambda expressions in tests (DecoratorTests.cs, ClosureBuilderTests.cs) to match the new signatures

EncodedTextWriter is a small readonly struct (a few reference fields), so passing by value is functionally equivalent and has negligible performance impact.

Test plan

  • New regression tests in source/Handlebars.Test/Issues/Issue458Tests.cs
  • All 1749 existing tests continue to pass
  • Covers basic compile+render, block helpers, and each/iterator paths

🤖 Generated with Claude Code

rexm and others added 2 commits June 20, 2026 08:26
…(issue #458)

TemplateDelegate and DecoratorDelegate previously used `in EncodedTextWriter`
(ref readonly) parameters, which caused System.NotImplementedException on
Xamarin.iOS and other Mono-based runtimes when compiled via expression trees.
Remove the `in` modifier to pass EncodedTextWriter by value; also remove
MakeByRefType() in CompilationContext so expression lambdas use plain parameters.
Adds regression tests in Issue458Tests.cs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rexm rexm enabled auto-merge June 20, 2026 12:45
@sonarqubecloud

Copy link
Copy Markdown

@rexm rexm merged commit 44faf35 into master Jun 20, 2026
7 checks passed
@rexm rexm deleted the worktree-agent-a88db3c552c4be375 branch June 20, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trying to compile a template in Xamarin.iOS results in a System.NotImplementedException

1 participant