scriban
scriban copied to clipboard
Object properties do not respect MemberRenamerDelegate in ScriptObject
The PrepareMembers method in the constructor of TypedObjectAccessor is currently using the MemberRenamerDelegate from the TemplateContext, which has a default value.
This results in the custom MemberRenamerDelegate specified in the ScriptObject.Import method not being used. So In my case I have to set this information twice in the ScriptObject.Import and in the TemplateContext.
Is this the intended behavior, or is it a mistake? I couldn't find any information about it in the documentation.
Is this the intended behavior, or is it a mistake?
Yes, this is the correct behavior.
TypedObjectAccessor is created when a .NET objects is dynamically accessed through the scripting engine. In that case, it needs to fetch a member renamer from the TemplateContext.
ScriptObject.Import can be created outside of a TemplateContext, outside of an evaluation context, so it has to be specified there if necessary.
I couldn't find any information about it in the documentation.
This is explained here https://github.com/scriban/scriban/blob/master/doc/runtime.md#member-renamer