Closed
Description
openedon Dec 22, 2022
If I try to enumerate an array when DefaultAccess = ScriptAccess.None
. I get the error:
Error: The object is not enumerable
Sample:
using Microsoft.ClearScript;
using Microsoft.ClearScript.V8;
namespace TestArray;
internal class Program
{
static void Main(string[] args)
{
using (var engine = new V8ScriptEngine())
{
engine.DefaultAccess = ScriptAccess.None;
engine.AddHostObject("house", new House());
engine.Execute("for (const vi of house.ValuesInt) { house.WriteLine(vi); }");
}
}
}
[DefaultScriptUsage(ScriptAccess.Full)]
public class House
{
public House() {
ValuesInt = new List<int> { 1, 2 };
}
public List<int> ValuesInt { get; set; }
public void WriteLine(string value)
{
Console.WriteLine(value);
}
}
I found a workaround with a CustomAttributeLoader
which add the ScriptAccess.None attribute on every resources excepted for the resource ClearScript.Core.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment