-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the jint options to support System.text.json #15449
Conversation
Your test case here seems to pass. If the issue related to your code? |
The problem recurred. My previous tests were broken, I updated them, and now the problem recurred. var findUser = new GlobalMethod
{
Name = "getUserByName",
Method = sp => (string userName) =>
{
var userManager = sp.GetRequiredService<UserManager<IUser>>();
var userInfo = userManager.FindByNameAsync(userName).GetAwaiter().GetResult();
var jobjUser = JObject.FromObject(userInfo, JOptions.CamelCase);
jobjUser.Remove("securityStamp");
jobjUser.Remove("passwordHash");
jobjUser.Remove("resetToken");
jobjUser.Remove("userTokens");
return jobjUser;
}
};
var scriptingEngine = scope.ServiceProvider.GetRequiredService<IScriptingEngine>();
var scriptingScope = scriptingEngine.CreateScope([findUser], scope.ServiceProvider, null, null);
var result = (bool)scriptingEngine.Evaluate(scriptingScope, "var user = getUserByName('admin'); return user.userName == 'admin'");
Assert.True(result); |
Hi @MikeAlhayek , this PR is ready to merge |
src/OrchardCore/OrchardCore.Scripting.JavaScript/JavaScriptEngine.cs
Outdated
Show resolved
Hide resolved
@MikeAlhayek Done. |
Name = "tryAccessJsonObject", | ||
Method = sp => () => | ||
{ | ||
return new JsonObject |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try adding other STJ types in the test, like arrays, bool, numbers, to be sure it works fine too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the jint project contains the full test, do I need to copy it to oc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that false value in JsonObject
does not work as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relate sebastienros/jint#1801
…ardCore into add_usertestfunction
try to reproduce
System.InvalidOperationException:“The node must be of type 'JsonObject'.”