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 | .... | 8 | 9 | (Page 10) | 11 | 12 | .... | 115 | newer

    0 0

    Dear Sir or Madam,
    I seems to having problems setting properties of type Nullable<> from within JScript.

    Sample script:
    ```
    function foo(obj, propValue)
    {
    // obj.Prop is declared as of type Nullable<double>
    // neither double nor Nullable<double> works for propValue parameter
    obj.Prop = propValue;
    }

    ```
    Please help,
    Yours faithfully

    MW

    0 0

    Dear Sir or Madam,
    I seems to having problems setting properties of type Nullable<> from within JScript.

    Sample script:
    ```
    function foo(obj, propValue)
    {
    // obj.Prop is declared as of type Nullable<double>
    // neither double nor Nullable<double> works for propValue parameter
    obj.Prop = propValue;
    }

    ```
    Please help,
    Yours faithfully

    MW
    Comments: Hello MW! You're right; ClearScript does not support nullable types at the moment. Thanks for reporting this issue! We'll fix this problem as soon as possible. In the meantime, you could work around it by accessing nullable properties from the host rather than the script engine. Suppose your class looks like this: ``` C# public class MyObj { public int? Prop { get; set; } } ``` You could define a temporary helper class like this: ``` C# public static class MyObjHelpers { public static void SetProp(this MyObj myObj, dynamic value) { myObj.Prop = value; } public static object GetProp(this MyObj myObj) { return myObj.Prop; } } ``` Exposing the helper class allows you to do this in script code: ``` JavaScript myObj.SetProp(null); myObj.SetProp(123); var value = myObj.GetProp(); ``` Thanks again, and good luck!

    0 0

    It would be great to get access to the IE9+ Chakra engine as a lightweight (in terms of file size), ES5 compatible alternative to V8.

    0 0

    It would be great to get access to the IE9+ Chakra engine as a lightweight (in terms of file size), ES5 compatible alternative to V8.
    Comments: Chakra support would be great, but it's unlikely in the short term. The only official Chakra API is [JsRT](http://msdn.microsoft.com/en-us/library/dn249673(v=vs.94).aspx), which doesn't support general interception in its initial (current) release. Without general interception, ClearScript-style hosting would be extremely inefficient.

    0 0

    It would be great to get access to the IE9+ Chakra engine as a lightweight (in terms of file size), ES5 compatible alternative to V8.
    Comments: Thanks for the reply. I will definitely check out the JsRT API. TBH I was pretty certain this was going to be a non-trivial request when I wrote it. Still, I wonder if there is some way to get access to the modern bits of Chakra (parsing, ES5 extras, JSON etc.) via it's ActiveScript implementation? So far all the attempts I've seen just make JScript go faster, but can't access the rest of the new features.

    0 0
  • 11/26/13--06:48: New Post: Script libraries
  • I would like to be able to build and use a lib of helper scripts preferably residing separately (in separate files or storage records).
    How can I load or include such scripts in addition to or perhaps from within a main script being executed.
    What would be your recommendations.

    Yours faithfully,
    MW

    0 0
  • 11/26/13--10:25: New Post: Script libraries
  • Hello MW!

    You can execute any number of library scripts to prepare the environment for your main script. There really are no limitations. You can do something simple:
    using (var engine = new V8ScriptEngine()) {
        engine.Execute(File.ReadAllText(@"C:\path\to\lib1.js"));
        engine.Execute(File.ReadAllText(@"C:\path\to\lib2.js"));
        // and so on
    }
    Or you can use a module manager such as RequireJS for a bit more structure; see here for a simple RequireJS implementation on ClearScript.

    And because ClearScript executes scripts from in-memory strings, you can use whatever storage is convenient - files, resources, database records, etc. You can also construct scripts on the fly in memory.

    Cheers!

    0 0

    It would be great to get access to the IE9+ Chakra engine as a lightweight (in terms of file size), ES5 compatible alternative to V8.
    Comments: >Still, I wonder if there is some way to get access to the modern bits of Chakra (parsing, ES5 extras, JSON etc.) via it's ActiveScript implementation? ‚Äč From [this page](http://www.panopticoncentral.net/2013/07/02/introducing-jsrt-embedding-javascript-on-windows/): _The new Chakra engine, which has a high-performance GC and JIT compiler, does not officially support the IActiveScript interfaces._ We remain very much interested in Chakra because it's the only modern JavaScript engine that supports debugging in Visual Studio, but it does look like ClearScript integration will take some time, and that's assuming that general interception is on the JsRT roadmap. Cheers!

    0 0

    It would be great to get access to the IE9+ Chakra engine as a lightweight (in terms of file size), ES5 compatible alternative to V8.

    0 0

    5.3.10
    • Added support for Visual Studio 2013.
    • Fixed ErrorDetails line number issue in WindowsScriptEngine (Issue #24).
    • Added ScriptEngine.FormatCode and V8Runtime.FormatCode. Code formatting is now disabled by default.
    • Fixed script access to nullable values (Issue #30).
    • Added ScriptEngine.GetStackTrace() (Issue #27).
    • Added V8Runtime.MaxStackUsage and V8ScriptEngine.MaxRuntimeStackUsage (Issue #26).
    • Fixed V8 root object marshaling crash when GlobalMembers is in effect.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.23.13.

    5.3.9
    • V8Update now fetches known-good versions of GYP, Python, and Cygwin (Issue #20).
    • Fixed HostMethod and HostIndexedProperty arguments.
    • Added tests for bug fixes.
    • Tested with V8 3.22.23.

    5.3.8
    • Added dynamic host object projection (Issue #3).
    • Added support for overloaded indexers and indexed properties.
    • Interface targets now expose System.Object members.
    • Expanded caching for improved performance and memory usage.
    • Fixed crashes and deadlocks when shutting down with Eclipse debugger attached.
    • Added support for custom preloading of auxiliary assemblies (Issue #17).
    • Added many new tests.
    • Migrated to new V8 Persistent API.
    • Tested with V8 3.22.11.

    5.3.7
    • Fixed V8ScriptEngine compiled script evaluation result marshaling (Issue #16).
    • Added a test for the fix.
    • Cleared PYTHONPATH in V8Update.
    • Tested with V8 3.21.2.

    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.10
    • Added support for Visual Studio 2013.
    • Fixed ErrorDetails line number issue in WindowsScriptEngine (Issue #24).
    • Added ScriptEngine.FormatCode and V8Runtime.FormatCode.
    • Code formatting is now disabled by default.
    • Fixed script access to nullable values (Issue #30).
    • Added ScriptEngine.GetStackTrace() (Issue #27).
    • Added V8Runtime.MaxStackUsage and V8ScriptEngine.MaxRuntimeStackUsage (Issue #26).
    • Fixed V8 root object marshaling crash when GlobalMembers is in effect.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.23.13.

    5.3.9
    • V8Update now fetches known-good versions of GYP, Python, and Cygwin (Issue #20).
    • Fixed HostMethod and HostIndexedProperty arguments.
    • Added tests for bug fixes.
    • Tested with V8 3.22.23.

    5.3.8
    • Added dynamic host object projection (Issue #3).
    • Added support for overloaded indexers and indexed properties.
    • Interface targets now expose System.Object members.
    • Expanded caching for improved performance and memory usage.
    • Fixed crashes and deadlocks when shutting down with Eclipse debugger attached.
    • Added support for custom preloading of auxiliary assemblies (Issue #17).
    • Added many new tests.
    • Migrated to new V8 Persistent API.
    • Tested with V8 3.22.11.

    5.3.7
    • Fixed V8ScriptEngine compiled script evaluation result marshaling (Issue #16).
    • Added a test for the fix.
    • Cleared PYTHONPATH in V8Update.
    • Tested with V8 3.21.2.

    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.10
    • Added support for Visual Studio 2013.
    • Fixed ErrorDetails line number issue in WindowsScriptEngine (Issue #24).
    • Added ScriptEngine.FormatCode and V8Runtime.FormatCode.
    • Code formatting is now disabled by default.
    • Fixed script access to nullable values (Issue #30).
    • Added ScriptEngine.GetStackTrace() (Issue #27).
    • Added V8Runtime.MaxStackUsage and V8ScriptEngine.MaxRuntimeStackUsage (Issue #26).
    • Fixed V8 root object marshaling crash when GlobalMembers is in effect.
    • Added tests for bug fixes and new APIs.
    • Tested with V8 3.23.13.

    5.3.9
    • V8Update now fetches known-good versions of GYP, Python, and Cygwin (Issue #20).
    • Fixed HostMethod and HostIndexedProperty arguments.
    • Added tests for bug fixes.
    • Tested with V8 3.22.23.

    5.3.8
    • Added dynamic host object projection (Issue #3).
    • Added support for overloaded indexers and indexed properties.
    • Interface targets now expose System.Object members.
    • Expanded caching for improved performance and memory usage.
    • Fixed crashes and deadlocks when shutting down with Eclipse debugger attached.
    • Added support for custom preloading of auxiliary assemblies (Issue #17).
    • Added many new tests.
    • Migrated to new V8 Persistent API.
    • Tested with V8 3.22.11.

    5.3.7
    • Fixed V8ScriptEngine compiled script evaluation result marshaling (Issue #16).
    • Added a test for the fix.
    • Cleared PYTHONPATH in V8Update.
    • Tested with V8 3.21.2.

    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
  • 11/28/13--12:34: Updated Wiki: Announcements
  • 11/28/2013: Version 5.3.10 released.

    View the release notes and download the source code here.

    10/29/2013: Version 5.3.9 released.

    View the release notes and download the source code here.

    10/14/2013: Version 5.3.8 released.

    View the release notes and download the source code here.

    8/22/2013: Version 5.3.7 released.

    View the release notes and download the source code here.

    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
  • 11/28/13--12:43: Updated Wiki: Home
  • InfoIcon.jpgVersion 5.3.10 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));
        ");
    
        // use a dynamic host object
        engine.Execute(@"
            expando = new lib.System.Dynamic.ExpandoObject();
            expando.foo = 123;
            expando.bar = 'qux';
            delete expando.foo;
        ");
    
        // 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

    An error in the 1st line is reported as being in line 0
    An error in the 2nd line is also reported as being in line 0
    And error in the 3rd as line 1
    And then it increments as you would expect 2,3,4 ...

    The JS engine is OK this is only in the VBScript engine.

    0 0

    An error in the 1st line is reported as being in line 0
    An error in the 2nd line is also reported as being in line 0
    And error in the 3rd as line 1
    And then it increments as you would expect 2,3,4 ...

    The JS engine is OK this is only in the VBScript engine.
    Comments: Fixed in [Version 5.3.10](https://clearscript.codeplex.com/SourceControl/changeset/133980c335b05a07025111150f9cc2f8bc25a7fd). Code formatting is now disabled by default.

    0 0

    Dear Sir or Madam,
    I seems to having problems setting properties of type Nullable<> from within JScript.

    Sample script:
    ```
    function foo(obj, propValue)
    {
    // obj.Prop is declared as of type Nullable<double>
    // neither double nor Nullable<double> works for propValue parameter
    obj.Prop = propValue;
    }

    ```
    Please help,
    Yours faithfully

    MW

    0 0

    Dear Sir or Madam,
    I seems to having problems setting properties of type Nullable<> from within JScript.

    Sample script:
    ```
    function foo(obj, propValue)
    {
    // obj.Prop is declared as of type Nullable<double>
    // neither double nor Nullable<double> works for propValue parameter
    obj.Prop = propValue;
    }

    ```
    Please help,
    Yours faithfully

    MW
    Comments: Fixed in [Version 5.3.10](https://clearscript.codeplex.com/SourceControl/changeset/133980c335b05a07025111150f9cc2f8bc25a7fd).

    0 0

    ClearScript collects script stack traces during error processing, but an API method exposing this capability for logging purposes would be useful as well.

    0 0

    ClearScript collects script stack traces during error processing, but an API method exposing this capability for logging purposes would be useful as well.
    Comments: API method added in [Version 5.3.10](https://clearscript.codeplex.com/SourceControl/changeset/133980c335b05a07025111150f9cc2f8bc25a7fd).

older | 1 | .... | 8 | 9 | (Page 10) | 11 | 12 | .... | 115 | newer