From e10eeefd216632d73927487821d7a4a54a2f5f35 Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Mon, 15 Jul 2024 10:01:41 +0900 Subject: [PATCH 1/6] Fix missing artwork file --- .../NetSparkleUpdater.UI.WinForms.NetFramework.nuspec | 1 + 1 file changed, 1 insertion(+) diff --git a/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec b/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec index 28fa9b83..beb6705c 100644 --- a/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec +++ b/nuget/winformsnetframework/NetSparkleUpdater.UI.WinForms.NetFramework.nuspec @@ -27,5 +27,6 @@ + From afac5f988925069d2a836e41c46601d1e501724d Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Mon, 15 Jul 2024 16:48:01 +0900 Subject: [PATCH 2/6] Increase LogWriter options Closes #594 --- UPGRADING.md | 5 ++ src/NetSparkle/Enums/LogWriterOutputMode.cs | 28 +++++++++++ src/NetSparkle/LogWriter.cs | 51 +++++++++++---------- 3 files changed, 59 insertions(+), 25 deletions(-) create mode 100644 src/NetSparkle/Enums/LogWriterOutputMode.cs diff --git a/UPGRADING.md b/UPGRADING.md index 6826f866..d2b345b7 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -25,6 +25,11 @@ * `AssemblyReflectionAccessor` has been deprecated. Please use `AsmResolverAccessor` instead. (#587) * `AssemblyDiagnosticAccessor.AssemblyVersion` now returns `FileVersionInfo.GetVersionInfo(assemblyName).ProductVersion` rather than `FileVersionInfo.GetVersionInfo(assemblyName).FileVersion` so we can get semver versioning information * For ed25519 use, changed from BouncyCastle to Chaos.NaCl (large file size savings and we don't need all of BouncyCastle's features). You can verify its use and code online here: https://github.com/NetSparkleUpdater/Chaos.NaCl. Additionally, this package is available on NuGet for your own projects. +* `LogWriter` has undergone several changes: + * `public static string tag = "netsparkle:";` has changed to `public string Tag { get; set; } = "netsparkle:";` + * Instead of a simple `bool` to control printing to `Trace.WriteLine` or `Console.WriteLine`, there is now a new enum, `NetSparkleUpdater.Enums.LogWriterOutputMode`, which you can use to control whether `LogWriter` outputs to `Console`, `Trace`, `Debug`, or to `None` (don't output at all). + * Removed `PrintDiagnosticToConsole` property and replaced it with `OutputMode` of type `LogWriterOutputMode`. + * The default print mode for `LogWriter` is still `Trace` by default, as it was in prior versions. **Changes/Fixes** diff --git a/src/NetSparkle/Enums/LogWriterOutputMode.cs b/src/NetSparkle/Enums/LogWriterOutputMode.cs new file mode 100644 index 00000000..a777055f --- /dev/null +++ b/src/NetSparkle/Enums/LogWriterOutputMode.cs @@ -0,0 +1,28 @@ +using System; +using System.Diagnostics; + +namespace NetSparkleUpdater.Enums +{ + /// + /// Output mode for the class + /// + public enum LogWriterOutputMode + { + /// + /// Don't output anything + /// + None = 0, + /// + /// Output to + /// + Console = 1, + /// + /// Output to + /// + Trace = 2, + /// + /// Output to + /// + Debug = 3 + } +} diff --git a/src/NetSparkle/LogWriter.cs b/src/NetSparkle/LogWriter.cs index 95a37f18..511472ea 100644 --- a/src/NetSparkle/LogWriter.cs +++ b/src/NetSparkle/LogWriter.cs @@ -1,66 +1,67 @@ using NetSparkleUpdater.Enums; using NetSparkleUpdater.Interfaces; using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace NetSparkleUpdater { /// - /// A simple class to handle log information for NetSparkleUpdater. + /// A simple class to handle logging information. /// Make sure to do any setup for this class that you want /// to do before calling StartLoop on your object. /// public class LogWriter : ILogger { /// - /// Tag to show before any log statements + /// Tag to show before any log statements. Can be set to null. /// - public static string tag = "netsparkle:"; + public string Tag { get; set; } = "netsparkle:"; /// - /// Empty constructor -> sets PrintDiagnosticToConsole to false + /// Create a LogWriter that outputs to by default /// public LogWriter() { - PrintDiagnosticToConsole = false; + OutputMode = LogWriterOutputMode.Trace; } /// - /// LogWriter constructor that takes a bool to determine - /// the value for printDiagnosticToConsole + /// Create a LogWriter that outputs via the given LogWriterOutputMode mode /// - /// False to print to ; - /// true to print to - public LogWriter(bool printDiagnosticToConsole) + /// for this LogWriter instance; + public LogWriter(LogWriterOutputMode outputMode) { - PrintDiagnosticToConsole = printDiagnosticToConsole; + OutputMode = outputMode; } #region Properties /// - /// True if this class should print to ; - /// false if this object should print to . - /// Defaults to false. + /// for this LogWriter instance. Set to + /// to make this LogWriter output nothing. /// - public bool PrintDiagnosticToConsole { get; set; } + public LogWriterOutputMode OutputMode { get; set; } #endregion /// public virtual void PrintMessage(string message, params object[] arguments) { - if (PrintDiagnosticToConsole) + switch (OutputMode) { - Console.WriteLine(tag + " " + message, arguments); - } - else - { - Trace.WriteLine(string.Format(tag + " " + message, arguments)); + case LogWriterOutputMode.Console: + Console.WriteLine(Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments); + break; + case LogWriterOutputMode.Trace: + Trace.WriteLine(string.Format(Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments)); + break; + case LogWriterOutputMode.Debug: + Debug.WriteLine(Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments); + break; + case LogWriterOutputMode.None: + break; + default: + break; } } } From 913f22dbb1df5447bcb7c07e28feafc1325b502d Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Mon, 15 Jul 2024 16:52:08 +0900 Subject: [PATCH 3/6] Fix invalid LogWriter uses --- src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs | 2 +- src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs | 2 +- src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs b/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs index f1f516d9..125a4a6f 100644 --- a/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs +++ b/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs @@ -23,7 +23,7 @@ public MainWindow() UIFactory = new NetSparkleUpdater.UI.Avalonia.UIFactory(Icon), // Avalonia version doesn't support separate threads: https://github.com/AvaloniaUI/Avalonia/issues/3434#issuecomment-573446972 ShowsUIOnMainThread = true, - LogWriter = new LogWriter(true) + LogWriter = new LogWriter() //UseNotificationToast = false // Avalonia version doesn't yet support notification toast messages }; // TLS 1.2 required by GitHub (https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/) diff --git a/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs b/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs index 326ea93a..4f78fc36 100644 --- a/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs +++ b/src/NetSparkle.Samples.Avalonia.MacOSZip/MainWindow.axaml.cs @@ -26,7 +26,7 @@ public MainWindow() UIFactory = new NetSparkleUpdater.UI.Avalonia.UIFactory(Icon), // Avalonia version doesn't support separate threads: https://github.com/AvaloniaUI/Avalonia/issues/3434#issuecomment-573446972 ShowsUIOnMainThread = true, - LogWriter = new LogWriter(true), + LogWriter = new LogWriter(), RelaunchAfterUpdate = true, //UseNotificationToast = false // Avalonia version doesn't yet support notification toast messages diff --git a/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs b/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs index 16c35b8d..aee01288 100644 --- a/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs +++ b/src/NetSparkle.Tools.AppCastGenerator/XMLAppCastMaker.cs @@ -1,4 +1,5 @@ using NetSparkleUpdater.AppCastHandlers; +using NetSparkleUpdater.Enums; using System; using System.Collections.Generic; using System.Drawing; @@ -56,7 +57,7 @@ public override (List, string) GetItemsAndProductNameFromExistingAp } var docDescendants = doc.Descendants("item"); - var logWriter = new LogWriter(true); + var logWriter = new LogWriter(LogWriterOutputMode.Console); foreach (var item in docDescendants) { var currentItem = AppCastItem.Parse("", "", "/", item, logWriter); From 8886aa6294b4998852492339e339baecbea74c21 Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Mon, 15 Jul 2024 16:59:12 +0900 Subject: [PATCH 4/6] Add timestamp to LogWriter output --- UPGRADING.md | 1 + src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs | 4 ++-- src/NetSparkle/LogWriter.cs | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index d2b345b7..f71d2fb7 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -30,6 +30,7 @@ * Instead of a simple `bool` to control printing to `Trace.WriteLine` or `Console.WriteLine`, there is now a new enum, `NetSparkleUpdater.Enums.LogWriterOutputMode`, which you can use to control whether `LogWriter` outputs to `Console`, `Trace`, `Debug`, or to `None` (don't output at all). * Removed `PrintDiagnosticToConsole` property and replaced it with `OutputMode` of type `LogWriterOutputMode`. * The default print mode for `LogWriter` is still `Trace` by default, as it was in prior versions. + * By default, timestamps are now output along with the `Tag` and actual log item **Changes/Fixes** diff --git a/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs b/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs index 125a4a6f..28fa9cff 100644 --- a/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs +++ b/src/NetSparkle.Samples.Avalonia.MacOS/MainWindow.axaml.cs @@ -3,8 +3,8 @@ using Avalonia.Interactivity; using Avalonia.Markup.Xaml; using Avalonia.Media.Imaging; +using NetSparkleUpdater.Enums; using NetSparkleUpdater.SignatureVerifiers; -using NetSparkleUpdater.UI.Avalonia; using System.IO; namespace NetSparkleUpdater.Samples.Avalonia @@ -23,7 +23,7 @@ public MainWindow() UIFactory = new NetSparkleUpdater.UI.Avalonia.UIFactory(Icon), // Avalonia version doesn't support separate threads: https://github.com/AvaloniaUI/Avalonia/issues/3434#issuecomment-573446972 ShowsUIOnMainThread = true, - LogWriter = new LogWriter() + LogWriter = new LogWriter(LogWriterOutputMode.Console) //UseNotificationToast = false // Avalonia version doesn't yet support notification toast messages }; // TLS 1.2 required by GitHub (https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/) diff --git a/src/NetSparkle/LogWriter.cs b/src/NetSparkle/LogWriter.cs index 511472ea..c1197940 100644 --- a/src/NetSparkle/LogWriter.cs +++ b/src/NetSparkle/LogWriter.cs @@ -47,16 +47,17 @@ public LogWriter(LogWriterOutputMode outputMode) /// public virtual void PrintMessage(string message, params object[] arguments) { + var timestamp = string.Format("[{0:s}]", DateTime.Now); switch (OutputMode) { case LogWriterOutputMode.Console: - Console.WriteLine(Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments); + Console.WriteLine(timestamp + " " + Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments); break; case LogWriterOutputMode.Trace: - Trace.WriteLine(string.Format(Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments)); + Trace.WriteLine(string.Format(timestamp + " " + Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments)); break; case LogWriterOutputMode.Debug: - Debug.WriteLine(Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments); + Debug.WriteLine(timestamp + " " + Tag + (string.IsNullOrWhiteSpace(Tag) ? "" : " ") + message, arguments); break; case LogWriterOutputMode.None: break; From 8737b37d980d104c57e9de8ce7d83b004164ca11 Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Mon, 15 Jul 2024 17:01:14 +0900 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6cb04b0e..213ae2f8 100644 --- a/README.md +++ b/README.md @@ -452,7 +452,7 @@ Right now, we are compatible with version 11. If you need to make changes, you c Here are some things you can do to figure out how to get your app running: -* Make sure you have enabled and debugged your application thoroughly. A great way to do this is to set `SparkleUpdater.LogWriter = new LogWriter(true)` and then watch your console output while debugging. +* Make sure you have enabled and debugged your application thoroughly. A great way to do this is to set `SparkleUpdater.LogWriter = new LogWriter(LogWriterOutputMode.Console)` and then watch your console output while debugging. * Look at the NetSparkleUpdater samples by downloading this repo and running the samples. You can even try putting your app cast URL in there and using your public key to debug with the source code! * Ask for help in our [Gitter](https://gitter.im/NetSparkleUpdater/NetSparkle) * Post an issue and wait for someone to respond with assistance From f4eddb09e48fe37391bb93bdde6ea18ca45878c5 Mon Sep 17 00:00:00 2001 From: Michael Babienco Date: Mon, 15 Jul 2024 17:02:07 +0900 Subject: [PATCH 6/6] Fix more invalid LogWriter use --- .../AppCastMakerTests.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs b/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs index daee1b4a..a45fc3da 100644 --- a/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs +++ b/src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs @@ -1,13 +1,9 @@ using NetSparkleUpdater.AppCastGenerator; -using Org.BouncyCastle.Crypto; -using Org.BouncyCastle.Crypto.Generators; -using Org.BouncyCastle.Crypto.Parameters; +using NetSparkleUpdater.Enums; using Org.BouncyCastle.Security; using System; using System.IO; using System.Linq; -using System.Text; -using System.Runtime.CompilerServices; using Xunit; using System.Runtime.InteropServices; using System.Diagnostics; @@ -771,7 +767,7 @@ public void NetSparkleCanParseHumanReadableAppCast() new NetSparkleUpdater.SignatureVerifiers.Ed25519Checker( NetSparkleUpdater.Enums.SecurityMode.Strict, publicKeyString), - new NetSparkleUpdater.LogWriter(true)); + new NetSparkleUpdater.LogWriter(LogWriterOutputMode.Console)); var didSucceed = appCastHandler.DownloadAndParse(); Assert.True(didSucceed); var updates = appCastHandler.GetAvailableUpdates(); @@ -938,7 +934,7 @@ public void CanSetCriticalVersion() new NetSparkleUpdater.SignatureVerifiers.Ed25519Checker( NetSparkleUpdater.Enums.SecurityMode.Strict, publicKeyString), - new NetSparkleUpdater.LogWriter(true)); + new NetSparkleUpdater.LogWriter(LogWriterOutputMode.Console)); var didSucceed = appCastHandler.DownloadAndParse(); Assert.True(didSucceed); var updates = appCastHandler.GetAvailableUpdates();