From 37eb30417d2e8149fe2e784998b9feec36850b1b Mon Sep 17 00:00:00 2001 From: Justin Swanson Date: Mon, 23 Feb 2026 16:09:27 -0600 Subject: [PATCH] Reduce build warnings by 32 (126 -> 94) - Remove unnecessary System.Threading.Tasks package reference (NU1510) - Remove unused catch exception variables (CS0168) - Suppress intentional self-comparison warnings in operator tests (CS1718) - Suppress interface-required but unused Error event in mock (CS0067) - Replace obsolete Subscribe call with SubscribeAsyncConcat (CS0618) --- CSharpExt.UnitTests/PercentTests.cs | 9 +++++++++ Directory.Packages.props | 2 +- Noggog.CSharpExt/Noggog.CSharpExt.csproj | 4 ---- Noggog.CSharpExt/WorkEngine/WorkConsumer.cs | 2 +- Noggog.Testing/Extensions/ShouldlyExt.cs | 6 +++--- Noggog.Testing/FileSystem/MockFileSystemWatcher.cs | 2 ++ Noggog.WPF/Extensions/DependencyObjectExt.cs | 2 +- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CSharpExt.UnitTests/PercentTests.cs b/CSharpExt.UnitTests/PercentTests.cs index 4c110323..d956e5de 100644 --- a/CSharpExt.UnitTests/PercentTests.cs +++ b/CSharpExt.UnitTests/PercentTests.cs @@ -147,7 +147,10 @@ public void LessThanCompare() c.ShouldBeTrue(); c = p2 < p1; c.ShouldBeFalse(); + +#pragma warning disable CS1718 // Intentional self-comparison to test operators c = p1 < p1; +#pragma warning restore CS1718 c.ShouldBeFalse(); } @@ -160,7 +163,9 @@ public void LessThanOrEqualCompare() c.ShouldBeTrue(); c = p2 <= p1; c.ShouldBeFalse(); +#pragma warning disable CS1718 // Intentional self-comparison to test operators c = p1 <= p1; +#pragma warning restore CS1718 c.ShouldBeTrue(); } @@ -173,7 +178,9 @@ public void GreaterThanOrEqualCompare() c.ShouldBeFalse(); c = p2 >= p1; c.ShouldBeTrue(); +#pragma warning disable CS1718 // Intentional self-comparison to test operators c = p1 >= p1; +#pragma warning restore CS1718 c.ShouldBeTrue(); } @@ -186,7 +193,9 @@ public void GreaterThanCompare() c.ShouldBeFalse(); c = p2 > p1; c.ShouldBeTrue(); +#pragma warning disable CS1718 // Intentional self-comparison to test operators c = p1 > p1; +#pragma warning restore CS1718 c.ShouldBeFalse(); } } \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index b85e1eb3..4fb4cf30 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -66,7 +66,7 @@ - + \ No newline at end of file diff --git a/Noggog.CSharpExt/Noggog.CSharpExt.csproj b/Noggog.CSharpExt/Noggog.CSharpExt.csproj index 359f675e..21c5dc56 100644 --- a/Noggog.CSharpExt/Noggog.CSharpExt.csproj +++ b/Noggog.CSharpExt/Noggog.CSharpExt.csproj @@ -33,10 +33,6 @@ - - - - diff --git a/Noggog.CSharpExt/WorkEngine/WorkConsumer.cs b/Noggog.CSharpExt/WorkEngine/WorkConsumer.cs index 3f838df9..fa50df20 100644 --- a/Noggog.CSharpExt/WorkEngine/WorkConsumer.cs +++ b/Noggog.CSharpExt/WorkEngine/WorkConsumer.cs @@ -152,7 +152,7 @@ public void Start() .Select(x => x ?? 0) .Select(x => x == 0 ? Environment.ProcessorCount : x) .DistinctUntilChanged() - .Subscribe(AddNewThreadsIfNeeded) + .SubscribeAsyncConcat(AddNewThreadsIfNeeded) .DisposeWithComposite(_disposable); } diff --git a/Noggog.Testing/Extensions/ShouldlyExt.cs b/Noggog.Testing/Extensions/ShouldlyExt.cs index f74c1648..06e719ff 100644 --- a/Noggog.Testing/Extensions/ShouldlyExt.cs +++ b/Noggog.Testing/Extensions/ShouldlyExt.cs @@ -44,7 +44,7 @@ internal static bool RoughlyEqual(TLhs actual, object? expected) TLhs? convertedExpected = (TLhs?)ConvertWithImplicitOperator(expected, actual.GetType()); if (object.Equals(actual, convertedExpected)) return true; } - catch (Exception e) + catch (Exception) { } @@ -53,7 +53,7 @@ internal static bool RoughlyEqual(TLhs actual, object? expected) TLhs? convertedExpected = (TLhs?)Convert.ChangeType(expected, actual.GetType()); if (object.Equals(actual, convertedExpected)) return true; } - catch (Exception e) + catch (Exception) { } @@ -64,7 +64,7 @@ internal static bool RoughlyEqual(TLhs actual, object? expected) var convertedExpected = convertibleExpected.ToType(actual.GetType(), null); if (object.Equals(actual, convertedExpected)) return true; } - catch (Exception e) + catch (Exception) { } } diff --git a/Noggog.Testing/FileSystem/MockFileSystemWatcher.cs b/Noggog.Testing/FileSystem/MockFileSystemWatcher.cs index f0c27756..2745efee 100644 --- a/Noggog.Testing/FileSystem/MockFileSystemWatcher.cs +++ b/Noggog.Testing/FileSystem/MockFileSystemWatcher.cs @@ -84,7 +84,9 @@ public IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, TimeS public event FileSystemEventHandler? Changed; public event FileSystemEventHandler? Created; public event FileSystemEventHandler? Deleted; +#pragma warning disable CS0067 // Required by IFileSystemWatcher interface public event ErrorEventHandler? Error; +#pragma warning restore CS0067 public event RenamedEventHandler? Renamed; public MockFileSystemWatcher(IFileSystem fileSystem) diff --git a/Noggog.WPF/Extensions/DependencyObjectExt.cs b/Noggog.WPF/Extensions/DependencyObjectExt.cs index 71e86ecc..3628306d 100644 --- a/Noggog.WPF/Extensions/DependencyObjectExt.cs +++ b/Noggog.WPF/Extensions/DependencyObjectExt.cs @@ -16,7 +16,7 @@ public static bool TryGetAncestor(this DependencyObject obj, [MaybeNullWhe { item = VisualTreeHelper.GetParent(item); } - catch (InvalidOperationException e) + catch (InvalidOperationException) { break; }