Skip to content

Is there a way to setup the 'ToStringTag' for c# class? #1649

Answered by lahma
fantasydr asked this question in Q&A
Discussion options

You must be logged in to vote

Jint seems to have some trouble understanding the reading of property from wrapped object's type reference. You can work around it by having a custom object wrapper logic at least.

var engine = new Engine(options => options.SetWrapObjectHandler((e, target, t) =>
{
    var wrapper = new ObjectWrapper(e, target, t);
    wrapper.FastSetProperty(GlobalSymbolRegistry.ToStringTag, new PropertyDescriptor(target.GetType().Name, false, false, true));
    return wrapper;
}));

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@fantasydr
Comment options

@lahma
Comment options

lahma Oct 22, 2023
Collaborator

@fantasydr
Comment options

@lahma
Comment options

lahma Oct 27, 2023
Collaborator

@lahma
Comment options

lahma Oct 28, 2023
Collaborator

Answer selected by fantasydr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants