From b542e1656ae90b4315f63ae1ff29f96658e8b262 Mon Sep 17 00:00:00 2001 From: Stuart Meeks Date: Sat, 30 May 2026 01:01:59 +0000 Subject: [PATCH 1/2] Appease the editorconfig in CrashLog Three rules tripped on the Windows job (TreatWarningsAsErrors fires these as build breaks, not warnings): - IDE0058: StringBuilder fluent chains and Directory.CreateDirectory return values were ignored. Prefix with '_ = '. - IDE0330: .NET 9 introduced System.Threading.Lock, which the analyser now prefers over a plain object for the lock target. - IDE0370: the '!' on ex.StackTrace was unnecessary; the IsNullOrWhiteSpace check above it already narrows the type for the analyser. Co-Authored-By: Claude Opus 4.7 --- src/Snipdeck.App/CrashLog.cs | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Snipdeck.App/CrashLog.cs b/src/Snipdeck.App/CrashLog.cs index 197e207..75b198a 100644 --- a/src/Snipdeck.App/CrashLog.cs +++ b/src/Snipdeck.App/CrashLog.cs @@ -1,6 +1,7 @@ using System.Globalization; using System.Runtime.InteropServices; using System.Text; +using System.Threading; using Microsoft.Extensions.DependencyInjection; @@ -17,7 +18,7 @@ internal static class CrashLog { private const string _logFileName = "unhandled.log"; private const int _maxLogBytes = 5 * 1024 * 1024; - private static readonly object _writeLock = new(); + private static readonly Lock _writeLock = new(); public static void Write(string source, Exception exception) { @@ -31,7 +32,7 @@ public static void Write(string source, Exception exception) return; } - Directory.CreateDirectory(paths.LogsDirectory); + _ = Directory.CreateDirectory(paths.LogsDirectory); var logPath = Path.Combine(paths.LogsDirectory, _logFileName); var text = Format(source, exception); @@ -74,12 +75,12 @@ private static void RotateIfTooLarge(string logPath) private static string Format(string source, Exception exception) { var sb = new StringBuilder(); - sb.AppendLine(new string('=', 72)); - sb.Append(DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture)) - .Append(" ") - .AppendLine(source); + _ = sb.AppendLine(new string('=', 72)); + _ = sb.Append(DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture)) + .Append(" ") + .AppendLine(source); AppendException(sb, exception, depth: 0); - sb.AppendLine(); + _ = sb.AppendLine(); return sb.ToString(); } @@ -87,28 +88,28 @@ private static void AppendException(StringBuilder sb, Exception ex, int depth) { var indent = new string(' ', depth * 2); - sb.Append(indent).Append("Type: ").AppendLine(ex.GetType().FullName ?? ex.GetType().Name); + _ = sb.Append(indent).Append("Type: ").AppendLine(ex.GetType().FullName ?? ex.GetType().Name); if (ex is COMException) { - sb.Append(indent).Append("HRESULT: 0x") - .AppendLine(ex.HResult.ToString("X8", CultureInfo.InvariantCulture)); + _ = sb.Append(indent).Append("HRESULT: 0x") + .AppendLine(ex.HResult.ToString("X8", CultureInfo.InvariantCulture)); } - sb.Append(indent).Append("Message: ").AppendLine(ex.Message); + _ = sb.Append(indent).Append("Message: ").AppendLine(ex.Message); if (!string.IsNullOrEmpty(ex.Source)) { - sb.Append(indent).Append("Source: ").AppendLine(ex.Source); + _ = sb.Append(indent).Append("Source: ").AppendLine(ex.Source); } if (!string.IsNullOrWhiteSpace(ex.StackTrace)) { - sb.Append(indent).AppendLine("Stack:"); - foreach (var line in ex.StackTrace!.Split('\n')) + _ = sb.Append(indent).AppendLine("Stack:"); + foreach (var line in ex.StackTrace.Split('\n')) { - sb.Append(indent).Append(" ").AppendLine(line.TrimEnd('\r')); + _ = sb.Append(indent).Append(" ").AppendLine(line.TrimEnd('\r')); } } if (ex.InnerException is not null) { - sb.Append(indent).AppendLine("Inner:"); + _ = sb.Append(indent).AppendLine("Inner:"); AppendException(sb, ex.InnerException, depth + 1); } } From 20e7ae1e630a95a85a482e572fdea0bd12b7b3ca Mon Sep 17 00:00:00 2001 From: Stuart Meeks Date: Sat, 30 May 2026 01:06:27 +0000 Subject: [PATCH 2/2] Drop redundant System.Threading using System.Threading is in the SDK's implicit-usings set, so the explicit using directive trips IDE0005 (which TreatWarningsAsErrors turns into a build break). Co-Authored-By: Claude Opus 4.7 --- src/Snipdeck.App/CrashLog.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Snipdeck.App/CrashLog.cs b/src/Snipdeck.App/CrashLog.cs index 75b198a..ef8962f 100644 --- a/src/Snipdeck.App/CrashLog.cs +++ b/src/Snipdeck.App/CrashLog.cs @@ -1,7 +1,6 @@ using System.Globalization; using System.Runtime.InteropServices; using System.Text; -using System.Threading; using Microsoft.Extensions.DependencyInjection;