Skip to content

Commit

Permalink
Add .NET Core build.
Browse files Browse the repository at this point in the history
References #16
References reactjs/React.NET#294
  • Loading branch information
Daniel15 committed Sep 12, 2016
1 parent 87247f3 commit 4e1ecb2
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/JSPool.Example.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,28 @@

using System;
using JavaScriptEngineSwitcher.Core;

#if NETCOREAPP1_0
using JavaScriptEngineSwitcher.ChakraCore;
#else
using JavaScriptEngineSwitcher.V8;
#endif

namespace JSPool.Example.ConsoleApp
{
public static class Program
{
static void Main(string[] args)
{
// Configure JavaScriptEngineSwitcher
// Configure JavaScriptEngineSwitcher. Generally V8 is preferred, however
// it's currently not supported on .NET Core.
#if NETCOREAPP1_0
JsEngineSwitcher.Instance.EngineFactories.AddChakraCore();
JsEngineSwitcher.Instance.DefaultEngineName = ChakraCoreJsEngine.EngineName;
#else
JsEngineSwitcher.Instance.EngineFactories.AddV8();
JsEngineSwitcher.Instance.DefaultEngineName = V8JsEngine.EngineName;
#endif

var pool = new JsPool(new JsPoolConfig
{
Expand Down
13 changes: 12 additions & 1 deletion src/JSPool.Example.Console/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@

"dependencies": {
"JavaScriptEngineSwitcher.Core": "2.0.0-alpha1",
"JavaScriptEngineSwitcher.V8": "2.0.0-alpha1",
"JSPool": {
"target": "project"
}
},

"frameworks": {
"net40-client": {
"dependencies": {
"JavaScriptEngineSwitcher.V8": "2.0.0-alpha1"
}
},
"netcoreapp1.0": {
"dependencies": {
"JavaScriptEngineSwitcher.ChakraCore": "2.0.0-alpha1",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}
6 changes: 6 additions & 0 deletions src/JSPool/Exceptions/JsPoolExhaustedException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
*/

using System;
#if !NETSTANDARD1_3
using System.Runtime.Serialization;
#endif

namespace JSPool.Exceptions
{
/// <summary>
/// Thrown when no engines are available in the pool.
/// </summary>
#if !NETSTANDARD1_3
[Serializable]
#endif
public class JsPoolExhaustedException : Exception
{
/// <summary>
Expand All @@ -33,11 +37,13 @@ public JsPoolExhaustedException(string message) : base(message) { }
public JsPoolExhaustedException(string message, Exception innerException)
: base(message, innerException) { }

#if !NETSTANDARD1_3
/// <summary>
/// Used by deserialization
/// </summary>
protected JsPoolExhaustedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{ }
#endif
}
}
2 changes: 1 addition & 1 deletion src/JSPool/FileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public virtual bool Start()
throw new InvalidOperationException("Path must be set first");
}

_timer = new Timer(OnTimer);
_timer = new Timer(OnTimer, null, Timeout.Infinite, Timeout.Infinite);
try
{
// Attempt to initialise a FileSystemWatcher so we can recycle the JavaScript
Expand Down
5 changes: 5 additions & 0 deletions src/JSPool/JsEngineWithOwnThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ public JsEngineWithOwnThread(Func<IJsEngine> innerEngineFactory, CancellationTok
// Cancellation token handles shutting down both when the whole pool is being shut down, and also
// when just this engine is being disposed.
_cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _disposedCancellation.Token).Token;

#if NETSTANDARD1_3
_thread = new Thread(RunThread)
#else
_thread = new Thread(RunThread, THREAD_STACK_SIZE)
#endif
{
Name = "JSPool Worker",
IsBackground = true,
Expand Down
11 changes: 10 additions & 1 deletion src/JSPool/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
"version": "2.0.0-alpha1-*",
"frameworks": {
"net40-client": {},
"net451": {}
"net451": {},
"netstandard13": {
"dependencies": {
"NETStandard.Library": "1.6.0",
"System.Diagnostics.TraceSource": "4.0.0",
"System.IO.FileSystem.Watcher": "4.0.0",
"System.Reflection.TypeExtensions": "4.1.0",
"System.Threading.Thread": "4.0.0"
}
}
},
"packOptions": {
"licenseUrl": "https://github.com/Daniel15/JSPool/blob/master/LICENSE",
Expand Down

0 comments on commit 4e1ecb2

Please sign in to comment.