Quantcast
Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Showcase


Channel Catalog



Channel Description:

ClearScript is a library that makes it easy to add scripting to your .NET applications. It currently supports JavaScript (via V8 and JScript) and VBScript.

older | 1 | 2 | (Page 3) | 4 | 5 | .... | 115 | newer

    0 0

    5.3.3
    • Improved V8 error handling (Issue #12).
    • Lowered .NET Framework target to v4.0.
    • Added several tests.
    • Tested with V8 3.19.18.

    5.3.2
    • Updates for breaking V8 API changes.
    • V8Update now fetches a tested revision by default.
    • Tested with V8 3.19.9.

    5.3.1
    • Fixed JScriptEngine dynamic binding bug (Issue #9).

    5.3.0
    • Enhancements for V8 users:
      • V8ScriptEngine now supports script compilation and re-execution.
      • New V8Runtime class allows engines to share resources and compiled scripts.
      • New experimental APIs for restricting and querying V8 memory usage.
      • Improved V8 loading algorithm for simplified deployment.
      • V8Update can now fetch a V8 version that is known to work with ClearScript.
    • New method: ScriptEngine.CollectGarbage().
    • Host item caching improves performance and reduces memory usage.
    • Several new tests.

    0 0

    5.3.3
    • Improved V8 error handling (Issue #12).
    • Lowered .NET Framework target to v4.0.
    • Added several tests.
    • Tested with V8 3.19.18.

    5.3.2
    • Updates for breaking V8 API changes.
    • V8Update now fetches a tested revision by default.
    • Tested with V8 3.19.9.

    5.3.1
    • Fixed JScriptEngine dynamic binding bug (Issue #9).

    5.3.0
    • Enhancements for V8 users:
      • V8ScriptEngine now supports script compilation and re-execution.
      • New V8Runtime class allows engines to share resources and compiled scripts.
      • New experimental APIs for restricting and querying V8 memory usage.
      • Improved V8 loading algorithm for simplified deployment.
      • V8Update can now fetch a V8 version that is known to work with ClearScript.
    • New method: ScriptEngine.CollectGarbage().
    • Host item caching improves performance and reduces memory usage.
    • Several new tests.

    0 0

    Rated 5 Stars (out of 5) - Very professional project, in contrast to similar solutions. Enables us to integrate a powerful javascript engine with a C# application. Also allow people to easily support old microsoft VB and JS engines in recent C# applications.

    0 0

    The documentation states that This method can be called safely from any thread

    So I made this unit test. Unfortunately it crashes most of time with an access violation in function InternalFieldOK (v8\src\api.cc). The test conditions are ClearScript 5.3.2 or 5.3.3 with default V8 version. Release mode 32 bits.
            [Test]
            public virtual void TestScriptInterruptedCrash()
            {
                var ctx = new PropertyBag();
                using (var engine = new V8ScriptEngine("CrashScript"))
                {
                    engine.AddHostObject("context", ctx);
    
                    var startEvent = new ManualResetEventSlim(false);
                    ThreadStart main = () =>
                    {
                        ctx["startEvent"] = startEvent;
                        ctx["counter"] = 0;
                        try
                        {
                            System.DateTime dtRun = System.DateTime.UtcNow;
                            engine.Execute("dummyDocument.js", @"
    for (var i = 0; i < 3000000; i++ )
    {
        context.counter++;
        context.startEvent.Set();
    }
    
    ");
                            Assert.Inconclusive();
                        }
                        catch (Microsoft.ClearScript.ScriptInterruptedException si)
                        {
                            Assert.That(si.Message.Contains("interrupted"));
                        }
                    };
    
                    var t = new Thread(main);
                    t.Start();
                    Assert.That(startEvent.Wait(10000));
                    engine.Interrupt();
    
                    t.Join();
    
                    // The thread did some work but was interrupted in the middle
                    Assert.Greater(3000000, (Int32)ctx["counter"]);
                    Assert.Less(0, (Int32)ctx["counter"]);
                }
            }
    I can guess from call stack that it crashes when tring to access to the host object"startEvent"... but the v8 handles and objects are a bit cryptic to debug.

    Am-I doing something wrong ? or does the script interruption disposes some ressources at the wrong time ?

    0 0

    Hello julien_b! We have reproduced this issue and do not believe that you are doing anything wrong. We are investigating.

    0 0

    Hi julien_b. Could you please download the latest source code and try your test again? We've posted an update that includes a potential fix and a modified version of your test. If the fix works for you, we'll release it as a new version of ClearScript. Thanks for reporting this issue!

    0 0

    Hello, I applied the fix and recompiled : it works perfectly ! Thanks.

    0 0

    Version 5.3.4: Updated test code for V8ScriptEngine script interruption crash fix.

    0 0

    5.3.4
    • Fixed script interruption crash in V8ScriptEngine.
    • Added a test for the fix.

    5.3.3
    • Improved V8 error handling (Issue #12).
    • Lowered .NET Framework target to v4.0.
    • Added several tests.
    • Tested with V8 3.19.18.

    5.3.2
    • Updates for breaking V8 API changes.
    • V8Update now fetches a tested revision by default.
    • Tested with V8 3.19.9.

    5.3.1
    • Fixed JScriptEngine dynamic binding bug (Issue #9).

    5.3.0
    • Enhancements for V8 users:
      • V8ScriptEngine now supports script compilation and re-execution.
      • New V8Runtime class allows engines to share resources and compiled scripts.
      • New experimental APIs for restricting and querying V8 memory usage.
      • Improved V8 loading algorithm for simplified deployment.
      • V8Update can now fetch a V8 version that is known to work with ClearScript.
    • New method: ScriptEngine.CollectGarbage().
    • Host item caching improves performance and reduces memory usage.
    • Several new tests.

    0 0

    5.3.4
    • Fixed script interruption crash in V8ScriptEngine.
    • Added a test for the fix.

    5.3.3
    • Improved V8 error handling (Issue #12).
    • Lowered .NET Framework target to v4.0.
    • Added several tests.
    • Tested with V8 3.19.18.

    5.3.2
    • Updates for breaking V8 API changes.
    • V8Update now fetches a tested revision by default.
    • Tested with V8 3.19.9.

    5.3.1
    • Fixed JScriptEngine dynamic binding bug (Issue #9).

    5.3.0
    • Enhancements for V8 users:
      • V8ScriptEngine now supports script compilation and re-execution.
      • New V8Runtime class allows engines to share resources and compiled scripts.
      • New experimental APIs for restricting and querying V8 memory usage.
      • Improved V8 loading algorithm for simplified deployment.
      • V8Update can now fetch a V8 version that is known to work with ClearScript.
    • New method: ScriptEngine.CollectGarbage().
    • Host item caching improves performance and reduces memory usage.
    • Several new tests.

    0 0
  • 07/10/13--07:34: Updated Wiki: Announcements
  • 7/10/2013: Version 5.3.4 released.

    View the release notes and download the source code here.

    7/2/2013: Version 5.3.3 released.

    View the release notes and download the source code here.

    6/6/2013: Version 5.3.2 released.

    View the release notes and download the source code here. Due to issues with several recent V8 trunk releases (build failures, breaking API changes, etc.), and because more breaking changes are coming soon, this release modifies V8Update so that it fetches a tested, known-good V8 revision by default. See the ClearScript ReadMe for more information.

    5/31/2013: Version 5.3.1 released.

    View the release notes and download the source code here.

    5/21/2013: ClearScript 5.3 released.

    View the release notes and download the source code here.

    5/15/2013: Version 5.2.2 released.

    View the release notes and download the source code here. This release addresses the build issue reported yesterday and can be used with the latest V8 version. Here's how to update your copy of V8:
    C:\ClearScript> set V8REV=
    C:\ClearScript> V8Update
    

    5/14/2013: ClearScript build failure due to API deprecation in V8 3.19.1.

    We are aware of a ClearScript build issue with the latest version of V8. Until this issue is resolved we recommend that you explicitly use V8 3.19.0:
    C:\ClearScript> set V8REV=14604
    C:\ClearScript> V8Update
    

    5/2/2013: Version 5.2.1 released.

    View the release notes and download the source code here.

    4/18/2013: V8Update failure resolved by V8 3.18.1.

    The V8Update issue reported yesterday has been fixed by a new version of V8 released today. Here's how to update to the latest V8 version:
    C:\ClearScript> set V8REV=
    C:\ClearScript> V8Update
    

    4/17/2013: V8Update failure with V8 3.18.0.

    We are aware of a V8Update issue with the latest version of V8. Until this issue is resolved we recommend that you explicitly use V8 3.17.16:
    C:\ClearScript> set V8REV=14138
    C:\ClearScript> V8Update
    

    3/27/2013: ClearScript 5.2 released.

    View the release notes and download the source code here.

    3/8/2013: Version 5.1.3 released.

    View the release notes and download the source code here.

    3/4/2013: V8Update failure resolved by V8 3.17.7.

    The V8Update issue reported earlier has been fixed by a new version of V8 released today. Here's how to update to the latest V8 version:
    C:\ClearScript> set V8REV=
    C:\ClearScript> V8Update
    

    3/4/2013: V8Update failure with V8 3.17.6.

    We are aware of a V8Update issue with the latest version of V8. The issue affects the "Building 64-bit V8" step. The V8 team appears to have already submitted a fix, but the fix has not yet been merged into the trunk. In the meantime, we recommend that you explicitly use V8 3.17.5:
    C:\ClearScript> set V8REV=13745
    C:\ClearScript> V8Update
    

    0 0
  • 07/10/13--07:34: Updated Wiki: Home
  • InfoIcon.jpg7/10/2013: Version 5.3.4 released. More...

    Description

    ClearScript is a library that makes it easy to add scripting to your .NET applications. It currently supports JavaScript (via V8 and JScript) and VBScript.

    Features

    • Simple usage; create a script engine, add your objects and/or types, run scripts
    • Support for several script engines: Google's V8, Microsoft's JScript and VBScript
    • Exposed resources require no modification, decoration, or special coding of any kind
    • Scripts get simple access to most of the features of exposed objects and types:
      • Methods, properties, fields, events
      • (Objects) Indexers, extension methods, conversion operators, explicitly implemented interfaces
      • (Types) Constructors, nested types
    • Full support for generic types and methods, including C#-like type inference and explicit type arguments
    • Scripts can invoke methods with output parameters, optional parameters, and parameter arrays
    • Script delegates enable callbacks into script code
    • Support for exposing all the types defined in one or more assemblies in one step
    • Optional support for importing types and assemblies from script code
    • The host can invoke script functions and access script objects directly
    • Full support for script debugging

    Examples

    using System;
    using Microsoft.ClearScript;
    using Microsoft.ClearScript.V8;
    
    // create a script engineusing (var engine = new V8ScriptEngine())
    {
        // expose a host type
        engine.AddHostType("Console", typeof(Console));
        engine.Execute("Console.WriteLine('{0} is an interesting number.', Math.PI)");
    
        // expose a host object
        engine.AddHostObject("random", new Random());
        engine.Execute("Console.WriteLine(random.NextDouble())");
    
        // expose entire assemblies
        engine.AddHostObject("lib", new HostTypeCollection("mscorlib", "System.Core"));
        engine.Execute("Console.WriteLine(lib.System.DateTime.Now)");
    
        // create a host object from script
        engine.Execute(@"
            birthday = new lib.System.DateTime(2007, 5, 22);
            Console.WriteLine(birthday.ToLongDateString());
        ");
    
        // use a generic class from script
        engine.Execute(@"
            Dictionary = lib.System.Collections.Generic.Dictionary;
            dict = new (Dictionary(lib.System.String, lib.System.Int32))();
            dict.Add('foo', 123);
        ");
    
        // call a host method with an output parameter
        engine.AddHostObject("host", new HostFunctions());
        engine.Execute(@"
            intVar = host.newVar(lib.System.Int32);
            found = dict.TryGetValue('foo', intVar.out);
            Console.WriteLine('{0} {1}', found, intVar);
        ");
    
        // create and populate a host array
        engine.Execute(@"
            numbers = host.newArr(lib.System.Int32, 20);
            for (var i = 0; i < numbers.Length; i++) { numbers[i] = i; }
            Console.WriteLine(lib.System.String.Join(', ', numbers));
        ");
    
        // create a script delegate
        engine.Execute(@"
            Filter = lib.System.Func(lib.System.Int32, lib.System.Boolean);
            oddFilter = new Filter(function(value) {
                return (value & 1) ? true : false;
            });
        ");
    
        // use LINQ from script
        engine.Execute(@"
            oddNumbers = numbers.Where(oddFilter);
            Console.WriteLine(lib.System.String.Join(', ', oddNumbers));
        ");
    
        // call a script function
        engine.Execute("function print(x) { Console.WriteLine(x); }");
        engine.Script.print(DateTime.Now.DayOfWeek);
    
        // examine a script object
        engine.Execute("person = { name: 'Fred', age: 5 }");
        Console.WriteLine(engine.Script.person.name);
    }

    0 0

    Rated 5 Stars (out of 5) - This is exactly what I was looking for! I love the well designed API!

    0 0

    And if we just want to use the simple JScriptEngine from windows (it'll be enough for our purposes), how do you debug the script there? I tried adding debugger; attaching from another visualstudio process.

    I'm sure it's something easy, but there's all the talk about Eclipse and such. but that'll be a deal breaker as I evaluate adding dynamic code to my particular project.

    0 0

    Hi paulkth,

    JScriptEngine supports script debugging via Visual Studio. Once your application has created an instance of JScriptEngine with debugging enabled, you should be able to attach the Visual Studio script debugger. You'll then see the list of loaded script documents in Solution Explorer; you can view the script code, set breakpoints, etc. The one caveat is that you cannot attach the script debugger if another debugger (managed or native) is already attached.

    If on the other hand you need to implement a script debugger like Waqaar above, that's also possible, but it's a much bigger task, and it might be easier to create a debugger for V8 than for JScript/VBScript.

    Good luck!

    0 0

    Thanks, I got it. The trick was, as you said, "with debugging enabled"
    _scriptEngine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging);

    0 0
  • 07/18/13--15:26: Updated Wiki: Home
  • Description

    ClearScript is a library that makes it easy to add scripting to your .NET applications. It currently supports JavaScript (via V8 and JScript) and VBScript.

    Features

    • Simple usage; create a script engine, add your objects and/or types, run scripts
    • Support for several script engines: Google's V8, Microsoft's JScript and VBScript
    • Exposed resources require no modification, decoration, or special coding of any kind
    • Scripts get simple access to most of the features of exposed objects and types:
      • Methods, properties, fields, events
      • (Objects) Indexers, extension methods, conversion operators, explicitly implemented interfaces
      • (Types) Constructors, nested types
    • Full support for generic types and methods, including C#-like type inference and explicit type arguments
    • Scripts can invoke methods with output parameters, optional parameters, and parameter arrays
    • Script delegates enable callbacks into script code
    • Support for exposing all the types defined in one or more assemblies in one step
    • Optional support for importing types and assemblies from script code
    • The host can invoke script functions and access script objects directly
    • Full support for script debugging

    Examples

    using System;
    using Microsoft.ClearScript;
    using Microsoft.ClearScript.V8;
    
    // create a script engineusing (var engine = new V8ScriptEngine())
    {
        // expose a host type
        engine.AddHostType("Console", typeof(Console));
        engine.Execute("Console.WriteLine('{0} is an interesting number.', Math.PI)");
    
        // expose a host object
        engine.AddHostObject("random", new Random());
        engine.Execute("Console.WriteLine(random.NextDouble())");
    
        // expose entire assemblies
        engine.AddHostObject("lib", new HostTypeCollection("mscorlib", "System.Core"));
        engine.Execute("Console.WriteLine(lib.System.DateTime.Now)");
    
        // create a host object from script
        engine.Execute(@"
            birthday = new lib.System.DateTime(2007, 5, 22);
            Console.WriteLine(birthday.ToLongDateString());
        ");
    
        // use a generic class from script
        engine.Execute(@"
            Dictionary = lib.System.Collections.Generic.Dictionary;
            dict = new (Dictionary(lib.System.String, lib.System.Int32))();
            dict.Add('foo', 123);
        ");
    
        // call a host method with an output parameter
        engine.AddHostObject("host", new HostFunctions());
        engine.Execute(@"
            intVar = host.newVar(lib.System.Int32);
            found = dict.TryGetValue('foo', intVar.out);
            Console.WriteLine('{0} {1}', found, intVar);
        ");
    
        // create and populate a host array
        engine.Execute(@"
            numbers = host.newArr(lib.System.Int32, 20);
            for (var i = 0; i < numbers.Length; i++) { numbers[i] = i; }
            Console.WriteLine(lib.System.String.Join(', ', numbers));
        ");
    
        // create a script delegate
        engine.Execute(@"
            Filter = lib.System.Func(lib.System.Int32, lib.System.Boolean);
            oddFilter = new Filter(function(value) {
                return (value & 1) ? true : false;
            });
        ");
    
        // use LINQ from script
        engine.Execute(@"
            oddNumbers = numbers.Where(oddFilter);
            Console.WriteLine(lib.System.String.Join(', ', oddNumbers));
        ");
    
        // call a script function
        engine.Execute("function print(x) { Console.WriteLine(x); }");
        engine.Script.print(DateTime.Now.DayOfWeek);
    
        // examine a script object
        engine.Execute("person = { name: 'Fred', age: 5 }");
        Console.WriteLine(engine.Script.person.name);
    }

    0 0

    Hi.

    I'm having trouble building ClearScript with V8.
    I'm using VS 2012 and Windows 7 x64.
    Below is the error I got.

    C:\ClearScript-5.3.4>V8Update.cmd
    Build mode: Release
    V8 revision: Tested (15192, Version 3.19.18)
    Creating build directory ...
    Downloading V8 ...
    Patching V8 ...
    Downloading GYP ...
    Downloading Python ...
    Downloading Cygwin ...
    Building 32-bit V8 ...
    *** THE PREVIOUS STEP FAILED ***

    The build.log got so much error and warning, I delete the duplicated error and warning.

    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : error C2220: warning treated as error - no 'object' file generated (....\src\optimizing-compiler-thread.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss (....\src\optimizing-compiler-thread.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]
    .....
    .....
    .....
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : error C2220: warning treated as error - no 'object' file generated (....\src\extensions\gc-extension.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss (....\src\extensions\gc-extension.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]

    Done Building Project "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj" (default targets) -- FAILED.
    Done Building Project "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\js2c.vcxproj" (default targets).
    Done Building Project "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.vcxproj.metaproj" (default targets) -- FAILED.
    Done Building Project "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln" (v8 target(s)) -- FAILED.

    Build FAILED.

    "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln" (v8 target) (1) ->
    "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.vcxproj.metaproj" (default target) (2) ->
    "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj" (default target) (3) ->
    (ClCompile target) ->
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss (....\src\optimizing-compiler-thread.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]
    .....
    .....
    .....
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss (....\src\extensions\gc-extension.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]


    "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.sln" (v8 target) (1) ->
    "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8.vcxproj.metaproj" (default target) (2) ->
    "C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj" (default target) (3) ->
    (ClCompile target) ->
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : error C2220: warning treated as error - no 'object' file generated (....\src\optimizing-compiler-thread.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]
    .....
    .....
    .....
    c:\clearscript-5.3.4\clearscript\v8\v8\build\v8-ia32\src\utils.h : error C2220: warning treated as error - no 'object' file generated (....\src\extensions\gc-extension.cc) [C:\ClearScript-5.3.4\ClearScript\V8\V8\build\v8-ia32\tools\gyp\v8_base.ia32.vcxproj]
    133 Warning(s)
    131 Error(s)
    
    Time Elapsed 00:01:39.86

    What can i do?? Any suggestions please.

    Thanks!

    0 0

    Hello ZivLo! Thanks for reporting this issue. We are investigating. The problem seems to be related to your machine's locale or language settings, but so far we haven't been able to reproduce it.

    0 0

    Hi,

    Thanks for your hint, after change locale to English in the Control Panel >> Region and Language >> Administrative >> Change system locale, my problem is solved.

    C:\Program Files (x86)\Microsoft Visual Studio 11.0>chcp
    Active code page: 437

    C:\ClearScript-5.3.4>V8Update.cmd
    Build mode: Release
    V8 revision: Tested (15192, Version 3.19.18)
    Creating build directory ...
    Downloading V8 ...
    Patching V8 ...
    Downloading GYP ...
    Downloading Python ...
    Downloading Cygwin ...
    Building 32-bit V8 ...
    Building 64-bit V8 ...
    Creating lib directory ...
    Importing V8 libraries ...
    Creating include directory ...
    Importing V8 header files ...
    Updating patch file ...
    Succeeded!

    Thanks!!

older | 1 | 2 | (Page 3) | 4 | 5 | .... | 115 | newer