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 | .... | 4 | 5 | (Page 6) | 7 | 8 | .... | 115 | newer

    0 0

    The difference in average runtimes between the two techniques is now so small as to be negligible. That's good, because using the V8ScriptEngine.Script object to invoke the JavaScript method is infinitely preferable. Thanks!

    0 0

    Version 5.3.6: Added numeric conversion methods in HostFunctions, fixed bugs affecting numeric arguments and return values. Tested with V8 3.20.16.

    0 0

    5.3.6
    • Added numeric conversion methods in HostFunctions.
    • Fixed bugs affecting numeric arguments and return values.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.20.16.

    5.3.5
    • Fixed invocation of base interface methods on derived interface targets (Issue #14).
    • Fixed V8 and ClearScript builds on certain non-English locales (Issue #13).
    • Added boxed enum reference canonicalization (Issue #15).
    • PropertyBag enhancements.
    • Lots of minor host integration fixes.
    • Updates for breaking V8 API changes.
    • Several new tests.
    • Tested with V8 3.20.12.

    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.6
    • Added numeric conversion methods in HostFunctions.
    • Fixed bugs affecting numeric arguments and return values.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.20.16.

    5.3.5
    • Fixed invocation of base interface methods on derived interface targets (Issue #14).
    • Fixed V8 and ClearScript builds on certain non-English locales (Issue #13).
    • Added boxed enum reference canonicalization (Issue #15).
    • PropertyBag enhancements.
    • Lots of minor host integration fixes.
    • Updates for breaking V8 API changes.
    • Several new tests.
    • Tested with V8 3.20.12.

    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
  • 08/14/13--07:44: Updated Wiki: Announcements
  • 8/14/2013: Version 5.3.6 released.

    View the release notes and download the source code here.

    8/2/2013: Version 5.3.5 released.

    View the release notes and download the source code here.

    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
  • 08/14/13--07:46: Updated Wiki: Documentation
  • Documentation

    To learn more about ClearScript:
    • Check out the ClearScript tutorial: [Word], [PDF].
    • Browse the ClearScript Library Reference: [Reference.chm]. Save this file before opening it. If you get a security warning when you open it, uncheck "Always ask before opening this file".
    • View the latest information in the ClearScript ReadMe.
    • Take a look at our latest Announcements.

    0 0
  • 08/14/13--07:48: Updated Wiki: Home
  • InfoIcon.jpg8/14/2013: Version 5.3.6 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

    Hello qrli!

    I cannot call a CLR function with single precesion float parameters, because Javascript numbers are double.

    Version 5.3.6 includes a new toSingle() method for passing float arguments. Here's an example using ClearScriptConsole:
    -> list = new System.Collections.Generic.List(System.Single)
    [HostObject:List<Single>]
    -> list.Add(Math.PI)
    Error: The best overloaded method match for 'System.Collections.Generic.List<float>.Add(float)' has some invalid arguments
    -> list.Add(host.toSingle(Math.PI))
    -> list[0]
    3.14159274101257
    The new version also provides toByte(), toInt16(), etc.

    Cheers!

    0 0
  • 08/21/13--10:32: New Post: More Build Issues
  • The issue with PYTHONHOME applies to PYTHONPATH as well, I have msysgit installed and that was part of the installation. You may want to bake this into your V8Update as well.

    0 0
  • 08/21/13--13:17: New Post: More Build Issues
  • Thank you lolboxen! We'll take care of that.

    0 0

    ```
    public class TestItem
    {
    public string Str { get; set; }
    }

    class Program
    {
    static void Main(string[] args)
    {
    using (var runtime = new V8Runtime())
    using (var engine = runtime.CreateScriptEngine())
    {
    engine.AddHostObject("test", new TestItem());

    string scriptCode = "test";
    V8Script compiledScript = runtime.Compile(scriptCode);

    object result = engine.Evaluate(scriptCode); //TestItem type
    object resultFromCompiled = engine.Evaluate(compiledScript); // HostObject type

    if (!result.Equals(resultFromCompiled)) // Different type of objects.
    throw new ApplicationException();
    }

    Console.ReadLine();
    }
    }
    ```

    0 0

    ```
    public class TestItem
    {
    public string Str { get; set; }
    }

    class Program
    {
    static void Main(string[] args)
    {
    using (var runtime = new V8Runtime())
    using (var engine = runtime.CreateScriptEngine())
    {
    engine.AddHostObject("test", new TestItem());

    string scriptCode = "test";
    V8Script compiledScript = runtime.Compile(scriptCode);

    object result = engine.Evaluate(scriptCode); //TestItem type
    object resultFromCompiled = engine.Evaluate(compiledScript); // HostObject type

    if (!result.Equals(resultFromCompiled)) // Different type of objects.
    throw new ApplicationException();
    }

    Console.ReadLine();
    }
    }
    ```

    0 0

    ```
    public class TestItem
    {
    public string Str { get; set; }
    }

    class Program
    {
    static void Main(string[] args)
    {
    using (var runtime = new V8Runtime())
    using (var engine = runtime.CreateScriptEngine())
    {
    engine.AddHostObject("test", new TestItem());

    string scriptCode = "test";
    V8Script compiledScript = runtime.Compile(scriptCode);

    object result = engine.Evaluate(scriptCode); //TestItem type
    object resultFromCompiled = engine.Evaluate(compiledScript); // HostObject type

    if (!result.Equals(resultFromCompiled)) // Different type of objects.
    throw new ApplicationException();
    }

    Console.ReadLine();
    }
    }
    ```
    Comments: Wow, the test code calls that method seven times but never examines the return value. We'll post a fix later today. Thanks alexeyt!

    0 0

    ```
    public class TestItem
    {
    public string Str { get; set; }
    }

    class Program
    {
    static void Main(string[] args)
    {
    using (var runtime = new V8Runtime())
    using (var engine = runtime.CreateScriptEngine())
    {
    engine.AddHostObject("test", new TestItem());

    string scriptCode = "test";
    V8Script compiledScript = runtime.Compile(scriptCode);

    object result = engine.Evaluate(scriptCode); //TestItem type
    object resultFromCompiled = engine.Evaluate(compiledScript); // HostObject type

    if (!result.Equals(resultFromCompiled)) // Different type of objects.
    throw new ApplicationException();
    }

    Console.ReadLine();
    }
    }
    ```

    0 0

    Was clearscript ever made compatible with shadowcopy? I have 5.3.6 and shadow copy had to be disabled in order to work.

    0 0

    Hi lolboxen,

    ClearScript looks for its auxiliary assemblies in several places. One of them is the AppDomain base directory. For a web application we recommend that, in addition to referencing ClearScript.dll normally, you add the V8 assemblies as resource files at the root of your project/site. This setup should work with assembly shadow copy.

    If this doesn't work for you, please let us know exactly what you did to integrate ClearScript into your project.

    Thanks!

    0 0

    That is basically how I have the project setup. Clearscript.dll is added as a reference, ClearScriptV8-32.dll and v8-ia32.dll are added as resources. These get copied to bin directory and as a byproduct of being in my project to the root of the site.

    I am using Visual Studio 2012 with IISEXPRESS ASP.NET 4.5 MVC4. Also clearscript was built using release configuration.

    In addition kudos to you guys for be very active in support. I sifted through several c# wrappers for JS engines and none were active. Keep up the good work.

    0 0

    Thanks for your kind words!

    Unfortunately so far we haven't been able reproduce any issues with assembly shadow copy. If you leave it enabled, what symptoms do you see?

    We just created a new ASP.NET 4.5 MVC 4 application, added a reference to ClearScript.dll, added ClearScriptV8-32.dll and v8-ia32.dll to the project via "Add -> Existing Item...", and added a bit of code that uses V8ScriptEngine in Index.cshtml.

    The code worked correctly, and we verified that ClearScript.dll had been shadow-copied. Is there anything different about your configuration?

    0 0

    Ah I found the problem, those two files CANNOT be copied into the bin directory. They can ONLY exist in the root.

    0 0

    Ah, yes, we can see that setting ClearScriptV8-32.dll to "Copy Always" breaks the project, but we cannot explain why. In that configuration the application can't start at all; we're even seeing it in a pristine new project with only that file added. Oh well, as long as there's an easy workaround :)

older | 1 | .... | 4 | 5 | (Page 6) | 7 | 8 | .... | 115 | newer