diff --git a/.gitignore b/.gitignore index dbe22b800..7d5fa201e 100644 --- a/.gitignore +++ b/.gitignore @@ -163,3 +163,4 @@ TestResult.xml /src/Unosquare.Labs.EmbedIO.Samples/nuget.config /test/Unosquare.Labs.EmbedIO.Tests/nuget.config *.targets +/.vscode diff --git a/src/Unosquare.Labs.EmbedIO.Command/Program.cs b/src/Unosquare.Labs.EmbedIO.Command/Program.cs index 283c4e650..1942aacc7 100644 --- a/src/Unosquare.Labs.EmbedIO.Command/Program.cs +++ b/src/Unosquare.Labs.EmbedIO.Command/Program.cs @@ -1,12 +1,13 @@ namespace Unosquare.Labs.EmbedIO.Command { using CommandLine; + using Swan; using System; using System.Reflection; using Unosquare.Labs.EmbedIO.Modules; /// - /// Entry poing + /// Entry point /// internal class Program { @@ -18,13 +19,14 @@ private static void Main(string[] args) { var options = new Options(); - Console.WriteLine("Unosquare.Labs.EmbedIO Web Server"); + "Unosquare.Labs.EmbedIO Web Server".Info(); if (!Parser.Default.ParseArguments(args, options)) return; - Console.WriteLine(" Command-Line Utility: Press any key to stop the server."); + " Command-Line Utility: Press any key to stop the server.".Info(); var serverUrl = "http://localhost:" + options.Port + "/"; + using ( var server = options.NoVerbose ? WebServer.Create(serverUrl) @@ -43,14 +45,14 @@ private static void Main(string[] args) { foreach (var api in options.ApiAssemblies) { - server.Log.DebugFormat("Registering Assembly {0}", api); + $"Registering Assembly {api}".Debug(); LoadApi(api, server); } } // start the server server.RunAsync(); - Console.ReadKey(true); + Terminal.ReadKey(true); } } diff --git a/src/Unosquare.Labs.EmbedIO.Command/project.json b/src/Unosquare.Labs.EmbedIO.Command/project.json index ad2dfeae9..75cc0e7f1 100644 --- a/src/Unosquare.Labs.EmbedIO.Command/project.json +++ b/src/Unosquare.Labs.EmbedIO.Command/project.json @@ -1,21 +1,22 @@ { - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true - }, + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true + }, - "dependencies": { - "Newtonsoft.Json": "9.0.1", - "CommandLineParser": "1.9.71", - "Unosquare.Labs.EmbedIO": { "target": "project" } - }, + "dependencies": { + "Newtonsoft.Json": "9.0.1", + "CommandLineParser": "1.9.71", + "Unosquare.Swan": "0.9.0", + "Unosquare.Labs.EmbedIO": { "target": "project" } + }, - "frameworks": { - "net452": { - + "frameworks": { + "net452": { + + } + }, + "runtimes": { + "win": {} } - }, - "runtimes": { - "win": {} - } } \ No newline at end of file diff --git a/src/Unosquare.Labs.EmbedIO.Samples/Program.cs b/src/Unosquare.Labs.EmbedIO.Samples/Program.cs index dafcc46e1..b3fd37e3e 100644 --- a/src/Unosquare.Labs.EmbedIO.Samples/Program.cs +++ b/src/Unosquare.Labs.EmbedIO.Samples/Program.cs @@ -94,7 +94,7 @@ private static void Main(string[] args) server.RunAsync(); // Fire up the browser to show the content! -#if DEBUG && !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if DEBUG && !NETCOREAPP1_1 && !NETSTANDARD1_6 var browser = new System.Diagnostics.Process() { StartInfo = new System.Diagnostics.ProcessStartInfo(url) diff --git a/src/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs b/src/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs index 15010f1b9..beb52e799 100644 --- a/src/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs +++ b/src/Unosquare.Labs.EmbedIO.Samples/StaticFilesSample.cs @@ -23,7 +23,7 @@ public static string HtmlRootPath // This lets you edit the files without restarting the server. #if DEBUG && !MONO -#if NETCOREAPP1_0 +#if NETCOREAPP1_1 return Path.Combine(Directory.GetParent(assemblyPath).Parent.Parent.FullName, "html"); #else return Path.Combine(Directory.GetParent(assemblyPath).Parent.Parent.Parent.FullName, "html"); diff --git a/src/Unosquare.Labs.EmbedIO.Samples/WebSocketsSample.cs b/src/Unosquare.Labs.EmbedIO.Samples/WebSocketsSample.cs index 40b3e1b61..a2f2ccc72 100644 --- a/src/Unosquare.Labs.EmbedIO.Samples/WebSocketsSample.cs +++ b/src/Unosquare.Labs.EmbedIO.Samples/WebSocketsSample.cs @@ -166,7 +166,7 @@ protected override void OnClientConnected(WebSocketContext context) StartInfo = new ProcessStartInfo() { CreateNoWindow = true, -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 ErrorDialog = false, #endif FileName = "cmd.exe", diff --git a/src/Unosquare.Labs.EmbedIO.Samples/project.json b/src/Unosquare.Labs.EmbedIO.Samples/project.json index 94df1523e..c2c458667 100644 --- a/src/Unosquare.Labs.EmbedIO.Samples/project.json +++ b/src/Unosquare.Labs.EmbedIO.Samples/project.json @@ -1,40 +1,37 @@ { - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true, - "copyToOutput": ["html\\"] - }, + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true, + "copyToOutput": ["html\\"] + }, - "dependencies": { - "LiteLib": "0.9.1", - "Newtonsoft.Json": "9.0.1", - "Tubular.ServerSide": "1.0.8", - "Unosquare.Labs.EmbedIO": { "target": "project" } - }, + "dependencies": { + "LiteLib": "0.9.2", + "Newtonsoft.Json": "9.0.1", + "Tubular.ServerSide": "1.0.8", + "Unosquare.Labs.EmbedIO": { "target": "project" } + }, - "frameworks": { - "netcoreapp1.0": { - "imports": "dnxcore50", - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" + "frameworks": { + "netcoreapp1.1": { + "imports": "dnxcore50", + "dependencies": { + "Microsoft.NETCore.App": "1.1.0" + } + }, + "net452": { + "frameworkAssemblies": { + "System.ComponentModel.DataAnnotations": "" + } + }, + "net46": { + "frameworkAssemblies": { + "System.ComponentModel.DataAnnotations": "" + } } - } - }, - "net452": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "" - } }, - "net46": { - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "" - } + "runtimes": { + "win": {}, + "win81-x64": {} } - }, - "runtimes": { - "win": {}, - "win81-x64": {} - } } \ No newline at end of file diff --git a/src/Unosquare.Labs.EmbedIO/Constants.cs b/src/Unosquare.Labs.EmbedIO/Constants.cs index 165fb401c..32db20647 100644 --- a/src/Unosquare.Labs.EmbedIO/Constants.cs +++ b/src/Unosquare.Labs.EmbedIO/Constants.cs @@ -25,7 +25,7 @@ public static class Constants /// The format culture used for header outputs /// public static readonly CultureInfo StandardCultureInfo = -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 CultureInfo.CreateSpecificCulture("en-US"); #else new CultureInfo("en-US"); @@ -35,7 +35,7 @@ public static class Constants /// The standard string comparer /// public static StringComparer StandardStringComparer = -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 StringComparer.InvariantCultureIgnoreCase; #else StringComparer.OrdinalIgnoreCase; @@ -45,7 +45,7 @@ public static class Constants /// The default encoding /// public static Encoding DefaultEncoding = -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 Encoding.Default; #else Encoding.GetEncoding(0); diff --git a/src/Unosquare.Labs.EmbedIO/Extensions.cs b/src/Unosquare.Labs.EmbedIO/Extensions.cs index 4f2f99da2..d1d6f9174 100644 --- a/src/Unosquare.Labs.EmbedIO/Extensions.cs +++ b/src/Unosquare.Labs.EmbedIO/Extensions.cs @@ -526,7 +526,7 @@ public static MemoryStream Compress(this Stream buffer) public static string ComputeMd5Hash(Stream stream) { var md5 = MD5.Create(); -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 const int bufferSize = 4096; var readAheadBuffer = new byte[bufferSize]; diff --git a/src/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs b/src/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs index 4fa272018..4f03304c3 100644 --- a/src/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs +++ b/src/Unosquare.Labs.EmbedIO/Modules/StaticFilesModule.cs @@ -342,7 +342,7 @@ private bool HandleGet(HttpListenerContext context, WebServer server, bool sendB } finally { -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 buffer.Close(); #endif buffer.Dispose(); diff --git a/src/Unosquare.Labs.EmbedIO/System.Net/SystemUri.cs b/src/Unosquare.Labs.EmbedIO/System.Net/SystemUri.cs index 3570a18ed..a06766b39 100644 --- a/src/Unosquare.Labs.EmbedIO/System.Net/SystemUri.cs +++ b/src/Unosquare.Labs.EmbedIO/System.Net/SystemUri.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP1_0 || NETSTANDARD1_6 +#if NETCOREAPP1_1 || NETSTANDARD1_6 namespace System { /// diff --git a/src/Unosquare.Labs.EmbedIO/project.json b/src/Unosquare.Labs.EmbedIO/project.json index 26d7a3b7d..4e54ea395 100644 --- a/src/Unosquare.Labs.EmbedIO/project.json +++ b/src/Unosquare.Labs.EmbedIO/project.json @@ -1,53 +1,47 @@ { - "version": "1.2.4-*", - "buildOptions": { - "xmlDoc": true - }, + "version": "1.2.5-*", + "buildOptions": { + "xmlDoc": true + }, - "dependencies": { - "Newtonsoft.Json": "9.0.1" - }, + "dependencies": { + "Newtonsoft.Json": "9.0.1" + }, - "frameworks": { - "netcoreapp1.0": { - "imports": "dnxcore50", - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" + "frameworks": { + "netcoreapp1.1": { + "imports": "dnxcore50", + "dependencies": { + "Microsoft.NETCore.App": "1.1.0", + "System.Security.Cryptography.Primitives": "4.3.0", + "System.Net.Primitives": "4.3.0", + "System.Collections.Specialized": "4.3.0", + "System.Collections.NonGeneric": "4.3.0", + "System.Security.Claims": "4.3.0" + } }, - "System.Security.Cryptography.Primitives": "4.0.0", - "System.Net.Primitives": "4.0.11", - "System.Collections.Specialized": "4.0.1", - "System.Collections.NonGeneric": "4.0.1", - "System.Security.Claims": "4.0.1" - } - }, - "netstandard1.6": { - "dependencies" : { - "NETStandard.Library": "1.6.1", - "System.Security.Cryptography.Primitives": "4.3.0", - "System.Net.Primitives": "4.3.0", - "System.Net.Requests": "4.3.0", - "System.Collections.Specialized": "4.3.0", - "System.Collections.NonGeneric": "4.3.0", - "System.Security.Claims": "4.3.0", - "System.Net.Security": "4.3.0", - "System.Net.NameResolution": "4.3.0", - "System.Threading.Thread": "4.3.0", - "System.Threading.ThreadPool": "4.3.0", - "System.IO.FileSystem.Watcher": "4.3.0" - } - }, - "net452": { + "netstandard1.6": { + "dependencies": { + "NETStandard.Library": "1.6.1", + "System.Security.Cryptography.Primitives": "4.3.0", + "System.Net.Primitives": "4.3.0", + "System.Net.Requests": "4.3.0", + "System.Collections.Specialized": "4.3.0", + "System.Collections.NonGeneric": "4.3.0", + "System.Security.Claims": "4.3.0", + "System.Net.Security": "4.3.0", + "System.Net.NameResolution": "4.3.0", + "System.Threading.Thread": "4.3.0", + "System.Threading.ThreadPool": "4.3.0", + "System.IO.FileSystem.Watcher": "4.3.0" + } + }, + "net452": { + }, + "net46": {} }, - "net46": { - "dependencies": { - } + "runtimes": { + "win": {} } - }, - "runtimes": { - "win": {} - } } \ No newline at end of file diff --git a/test/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs b/test/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs index c2c8c6687..b5713895b 100644 --- a/test/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs +++ b/test/Unosquare.Labs.EmbedIO.Tests/StaticFilesModuleTest.cs @@ -119,7 +119,7 @@ public async Task GetEtag() Assert.Fail("The Exception should raise"); } -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 [Test] public void GetInitialPartial() { @@ -288,7 +288,7 @@ public async Task GetNotPartial() } } -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 [Test] public async Task GetGzipCompressFile() { @@ -359,6 +359,8 @@ public async Task TestCaseSensitiveFile() var file = Path.GetTempPath() + Guid.NewGuid().ToString().ToLower(); File.WriteAllText(file, ""); + Assert.IsTrue(File.Exists(file), "File was created"); + if (File.Exists(file.ToUpper())) { Assert.Ignore("File-system is not case sensitive, ignoring"); diff --git a/test/Unosquare.Labs.EmbedIO.Tests/WebServerCultureTest.cs b/test/Unosquare.Labs.EmbedIO.Tests/WebServerCultureTest.cs index 732145899..86c71675f 100644 --- a/test/Unosquare.Labs.EmbedIO.Tests/WebServerCultureTest.cs +++ b/test/Unosquare.Labs.EmbedIO.Tests/WebServerCultureTest.cs @@ -1,4 +1,4 @@ -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 using System; using System.Collections.Generic; using System.IO; diff --git a/test/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs b/test/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs index 34f4f363c..011b8f3fb 100644 --- a/test/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs +++ b/test/Unosquare.Labs.EmbedIO.Tests/WebSocketsModuleTest.cs @@ -1,7 +1,7 @@ namespace Unosquare.Labs.EmbedIO.Tests { using System; -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 using System.Net.WebSockets; #endif using System.Threading; @@ -31,7 +31,7 @@ public async Task TestConnectWebSocket() Assert.AreEqual(WebServer.Module().Handlers.Count, 1, "WebSocketModule has one handler"); -#if !NETCOREAPP1_0 && !NETSTANDARD1_6 +#if !NETCOREAPP1_1 && !NETSTANDARD1_6 var clientSocket = new ClientWebSocket(); var ct = new CancellationTokenSource(); await clientSocket.ConnectAsync(new Uri(Resources.WsServerAddress + "test"), ct.Token); @@ -44,8 +44,8 @@ public async Task TestConnectWebSocket() await clientSocket.SendAsync(message, WebSocketMessageType.Text, true, ct.Token); var result = await clientSocket.ReceiveAsync(buffer, ct.Token); - Assert.IsTrue(result.EndOfMessage); - Assert.IsTrue(System.Text.Encoding.UTF8.GetString(buffer.Array).TrimEnd((char) 0) == "WELCOME"); + Assert.IsTrue(result.EndOfMessage, "End of message is true"); + Assert.IsTrue(System.Text.Encoding.UTF8.GetString(buffer.Array).TrimEnd((char) 0) == "WELCOME", "Final message is WELCOME"); #endif } diff --git a/test/Unosquare.Labs.EmbedIO.Tests/project.json b/test/Unosquare.Labs.EmbedIO.Tests/project.json index 86ac0cd96..c3e451455 100644 --- a/test/Unosquare.Labs.EmbedIO.Tests/project.json +++ b/test/Unosquare.Labs.EmbedIO.Tests/project.json @@ -1,57 +1,54 @@ { - "version": "1.0.0-*", - "buildOptions": { - "emitEntryPoint": true, - "copyToOutput": [ "html" ] - }, - "dependencies": { - "dotnet-test-nunit": "3.4.0-beta-3", - "Newtonsoft.Json": "9.0.1", - "Unosquare.Labs.EmbedIO": { "target": "project" }, - "NUnit": "3.5.0" - }, + "version": "1.0.0-*", + "buildOptions": { + "emitEntryPoint": true, + "copyToOutput": ["html"] + }, + "dependencies": { + "dotnet-test-nunit": "3.4.0-beta-3", + "Newtonsoft.Json": "9.0.1", + "Unosquare.Labs.EmbedIO": { "target": "project" }, + "NUnit": "3.5.0" + }, - "testRunner": "nunit", + "testRunner": "nunit", - "frameworks": { - "netcoreapp1.0": { - "imports": "dnxcore50", - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.1" + "frameworks": { + "netcoreapp1.1": { + "imports": "dnxcore50", + "dependencies": { + "Microsoft.NETCore.App": "1.1.0", + "System.Net.Http": "4.3.0" + } }, - "System.Net.Http": "4.1.0" - } - }, - "netstandard1.6": { - "imports": [ "dnxcore50", "netcoreapp1.0" ], - "dependencies": { - "NETStandard.Library": "1.6.1" - } - }, - "net452": { - "frameworkAssemblies": { - "System.Net.Http": "" - }, - "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*" - } + "netstandard1.6": { + "imports": ["dnxcore50", "netcoreapp1.1"], + "dependencies": { + "NETStandard.Library": "1.6.1" + } + }, + "net452": { + "frameworkAssemblies": { + "System.Net.Http": "" + }, + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*" + } + }, + "net46": { + "frameworkAssemblies": { + "System.Net.Http": "" + }, + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-*" + } + } }, - "net46": { - "frameworkAssemblies": { - "System.Net.Http": "" - }, - "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-*" - } - } - }, - "runtimes": { - "win": {}, - "win81-x64": {}, - "ubuntu.14.04-x64": {}, - "osx.10.11-x64": {} - } -} + "runtimes": { + "win": {}, + "win81-x64": {}, + "ubuntu.14.04-x64": {}, + "osx.10.11-x64": {} + } +} \ No newline at end of file