Вопрос по javascript, .net – Существуют ли какие-либо реализации .NET CLR / DLR в ECMAScript?

38

Кто-нибудь знает оreal (я ... без всякой поддержки) реализации ECMAScript для.NET CLR/DLR? В идеале что-то вродеwhat Rhino is for Java, Твердый порт Rhino, работающий на .NET Framework / Mono Framework, был бы идеальным.

Я видел только несколько упомянутых проектов, но никогда не видел ни одного из обнаруженных или в действительности чего-либо, на чем мне когда-либо удавалось запустить сценарий. Вот что я уже знаю:

MSScriptControl ActiveX Control: AFAIK, this was Microsoft's last real ECMAScript-compliant implementaiton (runs JScript 5.7). I've integrated with MSScriptControl but don't consider COM interop to be an answer to this question. x64 is a killer for this option.

JScript.NET: I don't count JScript.NET as it could never successfully parse any of my real scripts. It seems to have trouble with closures.

Managed JScript: Sounds like what I want but it appears to be dead in the water. It was a major example implementation for the DLR but then got entangled with SilverLight and seems to have faded as a priority since 2007. Creditable sources on the status of this would be helpful.

MyJScript: Built as a tutorial implementation for the DLR. Anyone know how complete of an implementation this is?

Jint: JavaScript interpreter for .NET. Doesn't as of yet support Currying or try-catch-finally.

RemObjects Script for .NET: An interesting contender still in the works. I'm confused by their marketing as to what it will actually be, but it sounds like it might eventually be a fit. If anyone knows more about it that would be helpful as well.

V8 for .NET: This would be great if someone ported V8 to .NET. As far as I know there isn't a large effort around this either. The link is to an idea for calling into it from a managed C++ wrapper.

Для фона я хочу иметь возможность выполнять JavaScript изнутри .NET; то есть загрузить набор сценариев в контекст и вызвать в этом контексте и получить результаты выполнения. В настоящее время я прыгаю через обручи, чтобы использовать MSScriptControl через громоздкие COM-взаимодействия. Несоответствие COM делает его действительно сложным для развертывания и обеспечения согласованного выполнения.

Мне бы хотелось иметь возможность выполнять достаточно сложные тестовые сценарии JavaScript из .NET. Это не для создания пользовательских макросов или простых крошечных скриптов; Мне нужна настоящая JavaScript-среда, такая как Rhino. Если бы реализация работала поверх CLR (а не COM), это действительно помогло бы решить некоторые из текущих проблем.

Error: User Rate Limit Exceededikvm.net Stobor
Error: User Rate Limit Exceeded Ionuț G. Stan
Error: User Rate Limit Exceeded ChaosPandion
Error: User Rate Limit Exceeded Sébastien Ros - MSFT
Error: User Rate Limit Exceeded Jared Updike

Ваш Ответ

9   ответов
7

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Update

Error: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceededgithub.com/sebastienros/jint
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
1

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded[ComVisile]Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded'AllowBob'sCLRClass=true'.

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded mckamey
8

Error: User Rate Limit ExceededError: User Rate Limit Exceeded.

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

using System;
using Microsoft.ClearScript;
using Microsoft.ClearScript.V8;

// create a script engine
using (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);
}
4

Error: User Rate Limit Exceededjsc /fast- bar.js

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded.

12

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceededjurascript.codeplex.comError: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
17

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded mckamey
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded mckamey
Error: User Rate Limit Exceeded
6

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded mckamey
12

Error: User Rate Limit Exceeded

  • Jurassic (Had a commit within the last year.)
  • Jint (currently taking pull requests.)

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

  • Rhino over IKVM (Mentioned in comments, but here's a link to more information about doing it.)
Error: User Rate Limit Exceeded mckamey
Error: User Rate Limit Exceededironjs.wordpress.com
4

V8.NET

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededgithub.com/rjamesnw/v8dotnet

Похожие вопросы