Skip to content

Commit 4e1ecb2

Browse files
committed
Add .NET Core build.
References #16 References reactjs/React.NET#294
1 parent 87247f3 commit 4e1ecb2

File tree

6 files changed

+46
-4
lines changed

6 files changed

+46
-4
lines changed

src/JSPool.Example.Console/Program.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,28 @@
77

88
using System;
99
using JavaScriptEngineSwitcher.Core;
10+
11+
#if NETCOREAPP1_0
12+
using JavaScriptEngineSwitcher.ChakraCore;
13+
#else
1014
using JavaScriptEngineSwitcher.V8;
15+
#endif
1116

1217
namespace JSPool.Example.ConsoleApp
1318
{
1419
public static class Program
1520
{
1621
static void Main(string[] args)
1722
{
18-
// Configure JavaScriptEngineSwitcher
23+
// Configure JavaScriptEngineSwitcher. Generally V8 is preferred, however
24+
// it's currently not supported on .NET Core.
25+
#if NETCOREAPP1_0
26+
JsEngineSwitcher.Instance.EngineFactories.AddChakraCore();
27+
JsEngineSwitcher.Instance.DefaultEngineName = ChakraCoreJsEngine.EngineName;
28+
#else
1929
JsEngineSwitcher.Instance.EngineFactories.AddV8();
2030
JsEngineSwitcher.Instance.DefaultEngineName = V8JsEngine.EngineName;
31+
#endif
2132

2233
var pool = new JsPool(new JsPoolConfig
2334
{

src/JSPool.Example.Console/project.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@
66

77
"dependencies": {
88
"JavaScriptEngineSwitcher.Core": "2.0.0-alpha1",
9-
"JavaScriptEngineSwitcher.V8": "2.0.0-alpha1",
109
"JSPool": {
1110
"target": "project"
1211
}
1312
},
1413

1514
"frameworks": {
1615
"net40-client": {
16+
"dependencies": {
17+
"JavaScriptEngineSwitcher.V8": "2.0.0-alpha1"
18+
}
19+
},
20+
"netcoreapp1.0": {
21+
"dependencies": {
22+
"JavaScriptEngineSwitcher.ChakraCore": "2.0.0-alpha1",
23+
"Microsoft.NETCore.App": {
24+
"type": "platform",
25+
"version": "1.0.0"
26+
}
27+
}
1728
}
1829
}
1930
}

src/JSPool/Exceptions/JsPoolExhaustedException.cs

+6
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
*/
77

88
using System;
9+
#if !NETSTANDARD1_3
910
using System.Runtime.Serialization;
11+
#endif
1012

1113
namespace JSPool.Exceptions
1214
{
1315
/// <summary>
1416
/// Thrown when no engines are available in the pool.
1517
/// </summary>
18+
#if !NETSTANDARD1_3
1619
[Serializable]
20+
#endif
1721
public class JsPoolExhaustedException : Exception
1822
{
1923
/// <summary>
@@ -33,11 +37,13 @@ public JsPoolExhaustedException(string message) : base(message) { }
3337
public JsPoolExhaustedException(string message, Exception innerException)
3438
: base(message, innerException) { }
3539

40+
#if !NETSTANDARD1_3
3641
/// <summary>
3742
/// Used by deserialization
3843
/// </summary>
3944
protected JsPoolExhaustedException(SerializationInfo info, StreamingContext context)
4045
: base(info, context)
4146
{ }
47+
#endif
4248
}
4349
}

src/JSPool/FileWatcher.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public virtual bool Start()
7676
throw new InvalidOperationException("Path must be set first");
7777
}
7878

79-
_timer = new Timer(OnTimer);
79+
_timer = new Timer(OnTimer, null, Timeout.Infinite, Timeout.Infinite);
8080
try
8181
{
8282
// Attempt to initialise a FileSystemWatcher so we can recycle the JavaScript

src/JSPool/JsEngineWithOwnThread.cs

+5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,12 @@ public JsEngineWithOwnThread(Func<IJsEngine> innerEngineFactory, CancellationTok
8888
// Cancellation token handles shutting down both when the whole pool is being shut down, and also
8989
// when just this engine is being disposed.
9090
_cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _disposedCancellation.Token).Token;
91+
92+
#if NETSTANDARD1_3
93+
_thread = new Thread(RunThread)
94+
#else
9195
_thread = new Thread(RunThread, THREAD_STACK_SIZE)
96+
#endif
9297
{
9398
Name = "JSPool Worker",
9499
IsBackground = true,

src/JSPool/project.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,16 @@
44
"version": "2.0.0-alpha1-*",
55
"frameworks": {
66
"net40-client": {},
7-
"net451": {}
7+
"net451": {},
8+
"netstandard13": {
9+
"dependencies": {
10+
"NETStandard.Library": "1.6.0",
11+
"System.Diagnostics.TraceSource": "4.0.0",
12+
"System.IO.FileSystem.Watcher": "4.0.0",
13+
"System.Reflection.TypeExtensions": "4.1.0",
14+
"System.Threading.Thread": "4.0.0"
15+
}
16+
}
817
},
918
"packOptions": {
1019
"licenseUrl": "https://github.com/Daniel15/JSPool/blob/master/LICENSE",

0 commit comments

Comments
 (0)