Skip to content

Commit 44faf35

Browse files
authored
Merge pull request #632 from Handlebars-Net/worktree-agent-a88db3c552c4be375
fix: remove byref delegate parameters incompatible with Mono/Xamarin (issue #458)
2 parents 1c49da8 + 06cd348 commit 44faf35

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Xunit;
2+
3+
namespace HandlebarsDotNet.Test
4+
{
5+
public class Issue458Tests
6+
{
7+
[Fact]
8+
public void Issue458_BasicCompileAndRender_NoByRefDelegate()
9+
{
10+
// Validates the scenario that fails on Mono when byref delegates are used
11+
var h = Handlebars.Create();
12+
var render = h.Compile("{{input}}");
13+
var result = render(new { input = 42 });
14+
Assert.Equal("42", result);
15+
}
16+
17+
[Fact]
18+
public void Issue458_BlockHelper_NoByRefDelegate()
19+
{
20+
// Block helpers also exercise TemplateDelegate compilation
21+
var h = Handlebars.Create();
22+
h.RegisterHelper("loud", (writer, options, context, arguments) =>
23+
{
24+
options.Template(writer, context);
25+
});
26+
var render = h.Compile("{{#loud}}hello{{/loud}}");
27+
var result = render(new { });
28+
Assert.Equal("hello", result);
29+
}
30+
31+
[Fact]
32+
public void Issue458_NestedTemplates_NoByRefDelegate()
33+
{
34+
// Nested template compilation exercises the expression tree lambda paths
35+
var h = Handlebars.Create();
36+
var render = h.Compile("{{#each items}}{{this}},{{/each}}");
37+
var result = render(new { items = new[] { "a", "b", "c" } });
38+
Assert.Equal("a,b,c,", result);
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)