Taritsyn / JavaScriptEngineSwitcher

JavaScript Engine Switcher determines unified interface for access to the basic features of popular JavaScript engines. This library allows you to quickly and easily switch to using of another JavaScript engine.
Apache License 2.0
440 stars 49 forks source link

.Net Core 2.0 support #41

Closed 01willtx closed 5 years ago

01willtx commented 6 years ago

This really isn't a bug but wondering if/when there is a port to support .Net Core 2.0 coming soon.

Thanks!

I'm trying to use React.Net with JavaScriptEngineSwitcher.ChakraCore (osx)

  warning NU1701: Package 'JavaScriptEngineSwitcher.V8 3.0.0-alpha5' was restored using    '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Taritsyn commented 6 years ago

Hello, Will!

.NET Core 2.0 is backward compatible with .NET Core 1.0. Many have long used the JavaScript Engine Switcher and ReactJS.NET in ASP.NET Core 2.0 Web Applications (for example, ReactJsDotNetMeetup).

ReactJS.NET version 3.1 and JSPool version 3.0.1 do not support the JavaScript Engine Switcher version 3.X. You need to rollback to version 2.X.

This really isn't a bug but wondering if/when there is a port to support .Net Core 2.0 coming soon.

This week will release a version 3.0.0 Alpha 6, that will support .NET Standard 2.0. But with the JavaScriptEngineSwitcher.V8 module there are problems, because .NET Standard 2.0 does not support the IExpando interface.

Daniel15 commented 6 years ago

I didn't realise JavaScriptEngineSwitcher 3.0 was available. I might release an alpha of JSPool and Reactjs.net that supports it.

Sent from my phone.

On Oct 11, 2017 8:01 PM, "Andrey Taritsyn" notifications@github.com wrote:

Hello, Will!

.NET Core 2.0 is backward compatible with .NET Core 1.0. Many have long used the JavaScript Engine Switcher and ReactJS.NET in ASP.NET Core 2.0 Web Applications (for example, ReactJsDotNetMeetup https://github.com/DaniilSokolyuk/ReactJsDotNetMeetup).

ReactJS.NET version 3.1 and JSPool version 3.0.1 do not support the JavaScript Engine Switcher version 3.X. You need to rollback to version 2.X.

This really isn't a bug but wondering if/when there is a port to support .Net Core 2.0 coming soon.

This week will release a version 3.0.0 Alpha 6, that will support .NET Standard 2.0. But with the JavaScriptEngineSwitcher.V8 module there are problems, because .NET Standard 2.0 does not support the IExpando interface.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/41#issuecomment-335744586, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFnHa9pYJDmYOUYE5OnIQnw3MhZOYvlks5srIP9gaJpZM4P0n1R .

Taritsyn commented 6 years ago

I didn't realise JavaScriptEngineSwitcher 3.0 was available

@Daniel15 I wrote to you about it.

I might release an alpha of JSPool and Reactjs.net that supports it.

@Daniel15 I recommend to wait for release of version 3.0.0 Alpha 6.

Taritsyn commented 6 years ago

@01willtx In version 3.0.0 Alpha 6 in all modules, except the JavaScriptEngineSwitcher.V8 module, added support of .NET Standard 2.0. In JavaScriptEngineSwitcher.V8 failed to solve a problem with the System.Runtime.InteropServices.Expando.IExpando type. It only remains to wait, when authors of the ClearScript library will add support of .NET Standard.

imsmart-tech commented 6 years ago

Hi Andrey,

I am using ClearScript and trying to find a solution for a port to .NET Core 2 in my app and wondering if JavaScriptEngineSwitcher 3.0 alpha would help me make it work. You can find a more thorough description of what I'm looking for at https://stackoverflow.com/questions/47836113/how-to-execute-javascript-in-aspnet-javascriptservices-microsoft-aspnetcore-nod

Thanks in advance. Paul

Taritsyn commented 6 years ago

Hello, Paul!

ASPNET JavaScriptServices (Microsoft.AspNetCore.NodeServices) is a bad idea. You can read my opinion on this matter in the “NodeJS as a JS Engine?” discussion.

I recommend you to use the JavaScriptEngineSwitcher.ChakraCore from version 3.X. I already wrote about how to solve your problem.

imsmart-tech commented 6 years ago

Great. Before I dig into it, is there an equivalent to AddHostObject that I use in JavascriptEngineSwitcher.ChakraCore?

Taritsyn commented 6 years ago

Great. Before I dig into it, is there an equivalent to AddHostObject that I use in JavascriptEngineSwitcher.ChakraCore?

EmbedHostObject. See the IJsEngine interface and interop tests.

imsmart-tech commented 6 years ago

It's progressing. However, I'm getting an error

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot invoke a non-delegate type
   at CallSite.Target(Closure , CallSite , Object , IJsEngine , String , SmartBoolean )
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid4[T0,T1,T2,T3](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)

when calling addSmartPropertyBool (see code from https://stackoverflow.com/questions/47836113/how-to-execute-javascript-in-aspnet-javascriptservices-microsoft-aspnetcore-nod) It seems it does not like the syntax or cannot handle the object returned. I am now using IJsEngine instead of ScriptEngine.

imsmart-tech commented 6 years ago

Also, I expected this code

var TestB = new SmartBoolean(Guid.Empty, "_test", false);
script._engine.EmbedHostObject("_test", TestB);
script._engine.TimedEvaluate(Constants.DefaultScriptTimeout, "_test = true;");

would call the set operator of SmartBoolean but it's not.

Taritsyn commented 6 years ago

Hello, Paul!

EmbedHostObject is not full equivalent of the AddHostObject method. For example, EmbedHostObject method does not support collections and extension methods. I already told you, that to use the JavaScript Engine Switcher need to simplify your code and architecture.

It is possible, that the JavaScript Engine Switcher initially not suitable for your needs. Since your code is completely focused on working with the Microsoft ClearScript.V8 library, then you should wait for the implementation of .NET Standard 2.0 support.

Taritsyn commented 5 years ago

In version 3.0.0 in all modules, except the JavaScriptEngineSwitcher.V8, added support of .NET Standard 2.0.

rjamesnw commented 5 years ago

V8.Net supports .Net Core now.