Quantcast
Channel: ClearScript
Viewing all 2297 articles
Browse latest View live

Commented Issue: New V8 debug agent fails in ASP.NET projects [75]

$
0
0
This issue has to do with the DispatchDebugMessages path, which attempts to invoke a managed method on a C++ Concurrency Runtime worker thread.

That seems to work in desktop applications, but it throws a CLR-internal C++ exception in ASP.NET. The unhandled exception triggers fail-fast handling in the task infrastructure.

A potential fix might be to schedule debug message dispatch on the managed side, ensuring that the worker thread is safe for invoking managed code.
Comments: Fixed in [Version 5.4.2](https://clearscript.codeplex.com/SourceControl/changeset/bfd06449d9e70818985d855319b7bc3a955313aa).

Edited Issue: Ambiguity when passing null to overloaded methods [72]

$
0
0
Hi, I'm having another issue with passing null to overloaded methods. Here's code sample.
```

public class SimpleObject
{
public string Name { get; set; }
public string GetName()
{
return null;
}
}

public static class LogWriter
{
public static void WriteLine(string message)
{
Console.WriteLine(message);
}

public static void WriteLine(Exception e)
{
if (e == null) Console.WriteLine(string.Empty);
else Console.WriteLine(string.Format("Exception: {0}\n{1}", e.Message, e.StackTrace));
}
}

```
Exposing "SimpleObject" and "LogWriter"
```
Engine.AddHostObject("SimpleObject", new SimpleObject());
Engine.AddHostType("Logger", typeof(LogWriter));
```
Then I will get error by scripting "Logger.WriteLine(SimpleObject.Name)" or "Logger.WriteLine(SimpleObject.GetName())".

The call is ambiguous between the following methods or properties:
'ConsoleApplication1.LogWriter.WriteLine(string)' and 'ConsoleApplication1.LogWr
iter.WriteLine(System.Exception)'

Is that missing converting the value of the property/return value of the method to property type/method return type? In this case, it should be (string)null.

Thank you!

Commented Issue: Ambiguity when passing null to overloaded methods [72]

$
0
0
Hi, I'm having another issue with passing null to overloaded methods. Here's code sample.
```

public class SimpleObject
{
public string Name { get; set; }
public string GetName()
{
return null;
}
}

public static class LogWriter
{
public static void WriteLine(string message)
{
Console.WriteLine(message);
}

public static void WriteLine(Exception e)
{
if (e == null) Console.WriteLine(string.Empty);
else Console.WriteLine(string.Format("Exception: {0}\n{1}", e.Message, e.StackTrace));
}
}

```
Exposing "SimpleObject" and "LogWriter"
```
Engine.AddHostObject("SimpleObject", new SimpleObject());
Engine.AddHostType("Logger", typeof(LogWriter));
```
Then I will get error by scripting "Logger.WriteLine(SimpleObject.Name)" or "Logger.WriteLine(SimpleObject.GetName())".

The call is ambiguous between the following methods or properties:
'ConsoleApplication1.LogWriter.WriteLine(string)' and 'ConsoleApplication1.LogWr
iter.WriteLine(System.Exception)'

Is that missing converting the value of the property/return value of the method to property type/method return type? In this case, it should be (string)null.

Thank you!
Comments: Optional null result wrapping implemented in [Version 5.4.2](https://clearscript.codeplex.com/SourceControl/changeset/bfd06449d9e70818985d855319b7bc3a955313aa).

Edited Issue: Restricted access to non-public accessors of public properties is not enforced [71]

$
0
0
Hi, I'm having an issue with exposed host object which has a property with public getter and private setter.
For example, I can put a script like "SomeObject.Name = ...". Is there a way to prevent this?

```
public class SomeObject
{
private string _name;
public string Name
{
get { return this._name; }
private set { this._name = value; }
}
}
```

And also, If I try to expose an object instance as interface, I still be able to access to the object's members.
For example,
```
public class SomeObject : IInterface
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}

public string ToSomeString()
{
return this._name;
}
}

public interface IInterface
{
string ToSomeString();
}
```
```
IInterface obj = new SomeObject();
Engine.AddHostObject("O", obj);
```

I can put script like O.Name = “A”.

Thank you

Commented Issue: Restricted access to non-public accessors of public properties is not enforced [71]

$
0
0
Hi, I'm having an issue with exposed host object which has a property with public getter and private setter.
For example, I can put a script like "SomeObject.Name = ...". Is there a way to prevent this?

```
public class SomeObject
{
private string _name;
public string Name
{
get { return this._name; }
private set { this._name = value; }
}
}
```

And also, If I try to expose an object instance as interface, I still be able to access to the object's members.
For example,
```
public class SomeObject : IInterface
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}

public string ToSomeString()
{
return this._name;
}
}

public interface IInterface
{
string ToSomeString();
}
```
```
IInterface obj = new SomeObject();
Engine.AddHostObject("O", obj);
```

I can put script like O.Name = “A”.

Thank you
Comments: Fixed in [Version 5.4.2](https://clearscript.codeplex.com/SourceControl/changeset/bfd06449d9e70818985d855319b7bc3a955313aa).

Edited Feature: Enable simplified syntax for accessing default members [50]

$
0
0
ClearScript doesn't provide any syntactic shortcuts for accessing default members.

This is particularly noticeable with indexers, which currently must be accessed by name. For example, host dictionary indexers are actually named "Item" and support the following syntax (JavaScript):

``` JavaScript
value = dict.Item(key);
value = dict.Item.get(key);
dict.Item.set(key, value);
```

Because `Item` is a default property, it might also make sense to support one or more of the following:

``` JavaScript
value = dict(key)
value = dict.get(key)
dict.set(key, value)
```

Default methods, though rarely used, might also benefit from special handling.

Commented Feature: Enable simplified syntax for accessing default members [50]

$
0
0
ClearScript doesn't provide any syntactic shortcuts for accessing default members.

This is particularly noticeable with indexers, which currently must be accessed by name. For example, host dictionary indexers are actually named "Item" and support the following syntax (JavaScript):

``` JavaScript
value = dict.Item(key);
value = dict.Item.get(key);
dict.Item.set(key, value);
```

Because `Item` is a default property, it might also make sense to support one or more of the following:

``` JavaScript
value = dict(key)
value = dict.get(key)
dict.set(key, value)
```

Default methods, though rarely used, might also benefit from special handling.
Comments: Default member support improved in [Version 5.4.2](https://clearscript.codeplex.com/SourceControl/changeset/bfd06449d9e70818985d855319b7bc3a955313aa). Tunneling of `get` and `set` indexer methods is canceled.

New Post: Passing Action/Func into JS?

$
0
0
Hi again,

If you're using V8, consider upgrading to the just-released ClearScript 5.4.2, which provides a new toFunction method for delegates. This method creates a native JavaScript function that invokes the delegate:
engine.Script.onEvent = new Action<object>(arg => DoSomething(arg));
engine.Execute("eventSource.on('someEvent', onEvent.toFunction())");
This feature might be useful in situations where library code validates functions via typeof or toString().

Good luck!

New Post: Display progress when script is executing...

$
0
0
Hi,

Firstly, I should congratulate on this wonderful project. Among all V8 .NET projects that I have come across this seems the best. Easy to use, feature rich and most usage scenarios are explained in the discussion forum.

In my case, I am using the V8 engine to run a lengthy javascript which would run for several minutes. I need to be able to display progress to users. Is there some way to get notified from the script engine upon completion of each line of javascript? A generic method/property interception call or an event notification mechanism would be good. I didn't come across any solution in the forum though I have seen few discuss about debug option.

Please let me know if there are better alternatives.

Regards,
Ram

New Post: using v8 with c#.net : compile javascript and know for any possible error before executing

$
0
0
I am using C# .Net, ClearScript for v8 JavaScript work.
I need to check for possible errors (whatever possible) in javascript before i execute it.
I have checked that there are [.Compile], [.Execute] and [.Evaluate] functions.
But I want to know that how i can check javascript possible error first before executing it.
Is this possible. Please help me out.

New Post: using v8 with c#.net : compile javascript and know for any possible error before executing

$
0
0
Hi RavinWorx,

Consider using a JavaScript parsing library. Esprima is one that's written in JavaScript.

Edit: Note that a parsing library is useful if you need to perform semantic analysis of any kind. The ClearScript methods you mentioned all throw exceptions if the code contains syntax errors.

Good luck!

New Post: Display progress when script is executing...

$
0
0
Hi Ram,

Thank you very much for the positive feedback!

Unfortunately none of the script engines supported by ClearScript appear to provide the sort of notifications you're looking for. V8 has several low-level profiling hooks, but we haven't explored those and it isn't clear how useful they'd be for your purposes.

If your script code often calls into the host, you might be able to use ScriptEngine.GetStackTrace() as a basis for gauging execution progress, but stack trace parsing is a fragile approach. A better solution, if practical, is to have the script code report its own progress via a host API that you provide.

Thanks again, and good luck!

New Post: how to call c# member function from JavaScript with named parameter. what should i do

$
0
0
how to call c# member function from JavaScript with named parameter. what should i do
// i want my JavaScript Code will be something like this
// By this script i want to call c# method with named arguments

var retResult = new myCSharpMethod( a:'aa', b:'bb');  
// my C# class is as below
public class myCSharpClass
    {
        public string myCSharpMethod(string a="", string b="")
        {
            string strRet= a + " " + b;
            return strRet;
        }
    }

New Post: Display progress when script is executing...

$
0
0
Thanks for your reply... This is a very critical requirement for us. The javascript itself is written by a different class of users of the program and hence would be considered cumbersome for them to write additional progress code.

I had come across V8's interceptors (link) and its [usage] (http://markmail.org/message/ul5dkze73tbqj2su).

Can the same be done with Clearscript? If yes, can you please tell how?

Regards,
Ram

New Post: Named parameter support

$
0
0
Hi,

Does clearscript using V8 engine support named parameters? C# supports named params. So also ECMAScript 6 and JavaScript in new version of browsers.

Can I get this capability in clearscript?

Regards,
Ram

Created Feature: Support for specifying host method arguments by name [80]

$
0
0
Neither JavaScript nor VBScript have native support for named arguments, but some way to specify host method arguments by name might be useful.

New Post: how to call c# member function from JavaScript with named parameter. what should i do

$
0
0
ClearScript currently has no built-in support for specifying host method arguments by name. This is a feature we're tracking here.

New Post: Named parameter support

$
0
0
Hi Ram,

ClearScript currently has no built-in support for specifying host method arguments by name. This is a feature we're tracking here.

Note that JavaScript doesn't have native syntax for named arguments; functions in ECMAScript 6 can specify default arguments for optional parameters, but that's a different feature.

Thanks!

New Post: Display progress when script is executing...

$
0
0
Hello Ram,

Interception is the mechanism that allows JavaScript code running in V8 to invoke host methods and properties. The code that implements those methods and properties is free to examine the script environment, and we're evaluating a feature that would allow the host to be notified of all such invocations in one place.

However, this feature, if implemented, wouldn't notify the host of native script function calls or property access, so it probably wouldn't be sufficient for any meaningful determination of progress. Script code could spin forever within the script engine without the host knowing anything about it. Even if it were possible to hook all calls, buggy or malicious script code could still get stuck within a function.

Can you say more about how you'd use an interception or notification mechanism to measure progress?

Thanks!

Created Unassigned: Support for Chakra.dll (Edge engine) [81]

$
0
0
Any thoughts about supporting the Edge JS engine?
Viewing all 2297 articles
Browse latest View live


Latest Images