Closed Thrasha closed 2 months ago
Can you add a test case showing the original problem?
I will try to reproduce it wia unit test, however, I'm not positive with that. The script, generated by state machine is huge and complex, and I couldn't determine which part of script has context null when I was debugging jint part. Give me a day, I'll try to find something
Hi @lahma. Unfortunately, it is impossible to write a unit test due to protection level of _activeEvaluationContext. What else can I do to make this fix merged?
Jint.Tests projects should be able to see internals?
It does see, however, we have to change private method TryGetComputedPropertyKey to internal. If yes, this following test throws JS error after my fix and 'Object reference not set to an instance of an object' before my fix
getting weird error when execute ts script in jint: Method CalculateLoanConditions has thrown an exception. System.NullReferenceException: Object reference not set to an instance of an object. at Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue(EvaluationContext context) at Jint.EsprimaExtensions.TryGetKey[T](T expression, Engine engine, Boolean resolveComputed) at Jint.Runtime.Interpreter.Expressions.JintObjectExpression.BuildObjectNormal(EvaluationContext context) at Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue(EvaluationContext context) at Jint.Runtime.Interpreter.Expressions.JintCallExpression.ArgumentListEvaluation(EvaluationContext context) at Jint.Runtime.Interpreter.Expressions.JintCallExpression.EvaluateInternal(EvaluationContext context) at Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue(EvaluationContext context) at Jint.Runtime.Interpreter.Statements.JintReturnStatement.ExecuteInternal(EvaluationContext context) at Jint.Native.Function.ScriptFunction.Call(JsValue thisObject, JsValue[] arguments) at Jint.Runtime.Interpreter.Expressions.JintCallExpression.EvaluateInternal(EvaluationContext context) at Jint.Runtime.Interpreter.Expressions.JintExpression.GetValue(EvaluationContext context) at Jint.Runtime.Interpreter.Statements.JintReturnStatement.ExecuteInternal(EvaluationContext context) at Jint.Native.Function.ScriptFunction.Call(JsValue thisObject, JsValue[] arguments)
https://stackoverflow.com/questions/78326684/error-object-reference-not-set-to-an-instance-of-an-object-after-upgrade-jint
after debugging jint, I've found out that for my scripts context is null. I substitute null to new EvaluationContext() and it started to work well