You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that when adding a delegate to a ScriptObject, it ignores the default arguments from the delegate definition and checks againts the arguments of the anonymous function/method used to create the delegate.
As a workaround I've found, wrapping the delegate on itself makes the delegate.Method return the signature of the delegate, like this: this["scriban_function"] = new SomeDelegate(del); in the example above.
The text was updated successfully, but these errors were encountered:
Hello,
I've noticed that when adding a delegate to a ScriptObject, it ignores the default arguments from the delegate definition and checks againts the arguments of the anonymous function/method used to create the delegate.
For example:
In this case, it will ignore the default argument if I use something like
new SomeNewContext(text => text.ToUpper())
.I've been checking why it happens and it's because it uses the delegate.Method to check against the arguments, and those may differ from the delegate.Invoke() call.
(https://github.com/scriban/scriban/blob/master/src/Scriban/Runtime/DelegateCustomFunction.cs#L27)
As a workaround I've found, wrapping the delegate on itself makes the delegate.Method return the signature of the delegate, like this:
this["scriban_function"] = new SomeDelegate(del);
in the example above.The text was updated successfully, but these errors were encountered: