Skip to content

Commit

Permalink
Fixed ArgumentException on compiling when the model has ToString() me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
unarist authored and Romanx committed May 19, 2016
1 parent 00761ae commit 5b9281f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Nustache.Compilation.Tests/Compiled_Templates_Support.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class SubObject
public override string ToString()
{
return "SubObject";
}
}
}

public class TestObjectWithToString
Expand Down Expand Up @@ -304,7 +304,7 @@ public void Model_With_ToString()
var result = compiled(new TestObjectWithToString { TestString = "Hello"});
Assert.AreEqual("A template with Hello", result);
}


private Func<T, string> Compiled<T>(string text) where T : class
{
return Template(text).Compile<T>(null);
Expand Down
2 changes: 1 addition & 1 deletion Nustache.Compilation/CompilePartVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void Visit(VariableReference variable)
{
var getter = context.CompiledGetter(variable.Path);
var returnIfNotNull = Expression.Call(getter, getter.Type.GetMethod("ToString", new Type[0]));
getter = CompoundExpression.NullCheck(getter, "", returnIfNotNull);
getter = CompoundExpression.NullCheck(getter, "", returnIfNotNull);

if (variable.Escaped)
{
Expand Down

0 comments on commit 5b9281f

Please sign in to comment.