From 797848f322bc8fd3d2909b027151d2ea1b42e362 Mon Sep 17 00:00:00 2001 From: Jack Rhodes Date: Sat, 8 Feb 2020 13:47:43 +0000 Subject: [PATCH 1/4] Migrate to dotnet core 3.1 --- SmartHunter/Core/Log.cs | 12 ++++-------- SmartHunter/SmartHunter.csproj | 18 ++++++------------ 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/SmartHunter/Core/Log.cs b/SmartHunter/Core/Log.cs index 434f3ff9..fca20cb7 100644 --- a/SmartHunter/Core/Log.cs +++ b/SmartHunter/Core/Log.cs @@ -1,7 +1,6 @@ -using System; +using System; using System.ComponentModel; using System.IO; -using System.Security.AccessControl; namespace SmartHunter.Core { @@ -16,17 +15,14 @@ public static void WriteLine(string message) string line = String.Format("[{0:yyyy-MM-dd HH:mm:ss}] {1}", DateTimeOffset.Now.ToUniversalTime(), message); Console.WriteLine(line); - if (LineReceived != null) - { - LineReceived(null, new GenericEventArgs(line)); - } + LineReceived?.Invoke(null, new GenericEventArgs(line)); bool isDesignInstance = LicenseManager.UsageMode == LicenseUsageMode.Designtime; if (!isDesignInstance) { try { - using (FileStream fileStream = new FileStream(s_FileName, FileMode.OpenOrCreate, FileSystemRights.AppendData, FileShare.Write, 4096, FileOptions.None)) + using (FileStream fileStream = new FileStream(s_FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Write, 4096, FileOptions.None)) { using (StreamWriter streamWriter = new StreamWriter(fileStream)) { @@ -44,4 +40,4 @@ public static void WriteException(Exception exception) WriteLine($"{exception.GetType().Name}: {exception.Message}\r\n{exception.StackTrace}"); } } -} \ No newline at end of file +} diff --git a/SmartHunter/SmartHunter.csproj b/SmartHunter/SmartHunter.csproj index 1a4f49c7..baaf1f5b 100644 --- a/SmartHunter/SmartHunter.csproj +++ b/SmartHunter/SmartHunter.csproj @@ -1,8 +1,8 @@ - + {F5F99CEF-1C16-48E6-A88B-1A66D3B53998} WinExe - net461 + netcoreapp3.1 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true false @@ -20,21 +20,15 @@ pdbonly + true + true - - - - - - - - - - + + From 72990a3e3cd989b6cec8bffa67cd732b0d15d04e Mon Sep 17 00:00:00 2001 From: Jack Rhodes Date: Sat, 8 Feb 2020 14:42:27 +0000 Subject: [PATCH 2/4] Remove R2r changes --- SmartHunter/SmartHunter.csproj | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SmartHunter/SmartHunter.csproj b/SmartHunter/SmartHunter.csproj index baaf1f5b..036d2e3f 100644 --- a/SmartHunter/SmartHunter.csproj +++ b/SmartHunter/SmartHunter.csproj @@ -1,4 +1,4 @@ - + {F5F99CEF-1C16-48E6-A88B-1A66D3B53998} WinExe @@ -20,8 +20,6 @@ pdbonly - true - true From 654db89abef49da5573b89cf99be0bef35e06f0d Mon Sep 17 00:00:00 2001 From: Jack Rhodes Date: Sat, 15 Feb 2020 11:04:07 +0000 Subject: [PATCH 3/4] Integrate single file exe --- SmartHunter/Core/Config/ConfigContainer.cs | 35 +++++++---- SmartHunter/Core/Helpers/Updater.cs | 5 ++ SmartHunter/SmartHunter.csproj | 71 +++++++++++----------- 3 files changed, 66 insertions(+), 45 deletions(-) diff --git a/SmartHunter/Core/Config/ConfigContainer.cs b/SmartHunter/Core/Config/ConfigContainer.cs index 15f3ae1a..1a2133a8 100644 --- a/SmartHunter/Core/Config/ConfigContainer.cs +++ b/SmartHunter/Core/Config/ConfigContainer.cs @@ -4,6 +4,7 @@ using System.Text; using Newtonsoft.Json; using Newtonsoft.Json.Converters; +using SmartHunter.Ui.Windows; using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; namespace SmartHunter.Core.Config @@ -28,7 +29,7 @@ public void HandleDeserializationError(object sender, ErrorEventArgs args) Log.WriteException(args.ErrorContext.Error); args.ErrorContext.Handled = true; } - + override protected void OnChanged() { Load(); @@ -36,7 +37,7 @@ override protected void OnChanged() void Load() { - if (File.Exists(FullPathFileName))// && FileName.Equals("Config.json")) + if (File.Exists(FullPathFileName)) { try { @@ -49,10 +50,12 @@ void Load() } } - var settings = new JsonSerializerSettings(); - settings.Formatting = Formatting.Indented; - settings.ContractResolver = new ContractResolver(); - settings.Error = HandleDeserializationError; + var settings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + ContractResolver = new ContractResolver(), + Error = HandleDeserializationError + }; // Solves dictionary/lists being added to instead of overwritten but causes problems elsewhere // https://stackoverflow.com/questions/29113063/json-net-why-does-it-add-to-list-instead-of-overwriting @@ -88,17 +91,27 @@ public void Save() try { - var settings = new JsonSerializerSettings(); - settings.Formatting = Formatting.Indented; - settings.NullValueHandling = NullValueHandling.Ignore; - settings.ContractResolver = new ContractResolver(); + var settings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + NullValueHandling = NullValueHandling.Ignore, + ContractResolver = new ContractResolver() + }; settings.Converters.Add(new StringEnumConverter()); settings.Converters.Add(new StringFloatConverter()); var jsonString = JsonConvert.SerializeObject(Values, settings); - File.WriteAllText(FullPathFileName, jsonString); + using (var fileStream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Write, 4096, FileOptions.None)) + { + using var streamWriter = new StreamWriter(fileStream) + { + AutoFlush = true + }; + + streamWriter.Write(jsonString); + } Log.WriteLine($"{FileName} saved"); } diff --git a/SmartHunter/Core/Helpers/Updater.cs b/SmartHunter/Core/Helpers/Updater.cs index a17dc03e..517dcd2b 100644 --- a/SmartHunter/Core/Helpers/Updater.cs +++ b/SmartHunter/Core/Helpers/Updater.cs @@ -16,6 +16,11 @@ public class Updater public bool CheckForUpdates(bool forceCheck = false) { +#if DEBUG + + return false; +#endif + if (_needUpdates.Count == 0 || forceCheck == true) { try diff --git a/SmartHunter/SmartHunter.csproj b/SmartHunter/SmartHunter.csproj index 036d2e3f..2de9ef30 100644 --- a/SmartHunter/SmartHunter.csproj +++ b/SmartHunter/SmartHunter.csproj @@ -1,35 +1,38 @@ - - {F5F99CEF-1C16-48E6-A88B-1A66D3B53998} - WinExe - netcoreapp3.1 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - true - false - latest - SmartHunter - false - 1.2.0.0 - 1.2.0.0 - bin\$(Configuration) - true - false - - - full - - - pdbonly - - - - - - - - - - - - - \ No newline at end of file + + {F5F99CEF-1C16-48E6-A88B-1A66D3B53998} + WinExe + netcoreapp3.1 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + false + latest + SmartHunter + false + 1.2.0.0 + 1.2.0.0 + bin\$(Configuration) + true + true + win-x64 + true + false + + + full + + + pdbonly + + + + + + + + + + + + + From b4d8478967aaedf61aec708d56cd6eaebfb91649 Mon Sep 17 00:00:00 2001 From: Jack Rhodes Date: Sat, 15 Feb 2020 12:54:52 +0000 Subject: [PATCH 4/4] Add basic build script --- .github/workflows/build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..5501f8b6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,17 @@ +name: .NET Core + +on: [push] + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.101 + - name: Build + run: dotnet build --configuration Release \ No newline at end of file