From 9a9c533d08bdea40db579043983e0ae49de5ac02 Mon Sep 17 00:00:00 2001 From: Frog Date: Sun, 21 Jun 2026 17:21:33 -0700 Subject: [PATCH] Fixes for MISC Build Warnings - Chaged several classes within ThemeManager to sealed since they're not inherrited from in other areas of the code. - Added Nullable section and defined some variables as nullable. --- CreamInstaller/Program.cs | 14 ++++++++------ CreamInstaller/Utility/ThemeManager.cs | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CreamInstaller/Program.cs b/CreamInstaller/Program.cs index 41241ff..6af66ed 100644 --- a/CreamInstaller/Program.cs +++ b/CreamInstaller/Program.cs @@ -1,3 +1,5 @@ +#nullable enable + using System; using System.Diagnostics; using System.Linq; @@ -12,8 +14,8 @@ namespace CreamInstaller; internal static class Program { - internal static readonly string Name = Application.CompanyName; - private static readonly string Description = Application.ProductName; + internal static readonly string Name = Application.CompanyName!; + private static readonly string Description = Application.ProductName!; internal static readonly string Version = Application.ProductVersion[ ..(Application.ProductVersion.IndexOf('+') is var index && index != -1 @@ -33,7 +35,7 @@ internal static class Program #endif private static readonly Process CurrentProcess = Process.GetCurrentProcess(); - internal static readonly string CurrentProcessFilePath = CurrentProcess.MainModule?.FileName; + internal static readonly string CurrentProcessFilePath = CurrentProcess.MainModule?.FileName ?? ""; internal static readonly int CurrentProcessId = CurrentProcess.Id; // Setting is now toggleable. Huzzah! @@ -47,10 +49,10 @@ internal static class Program // Dark mode enabled by default internal static bool DarkModeEnabled = true; - internal static bool IsGameBlocked(string name, string directory = null) + internal static bool IsGameBlocked(string name, string? directory = null) => GetGameBlockedReason(name, directory) is not null; - internal static string? GetGameBlockedReason(string name, string directory = null) + internal static string? GetGameBlockedReason(string name, string? directory = null) { if (!BlockProtectedGames) return null; if (ProtectedGames.Contains(name)) return "on protected games list"; @@ -145,7 +147,7 @@ internal static class Program }); } - private static void OnApplicationExit(object s, EventArgs e) + private static void OnApplicationExit(object? s, EventArgs e) { Canceled = true; diff --git a/CreamInstaller/Utility/ThemeManager.cs b/CreamInstaller/Utility/ThemeManager.cs index e9dc1f3..ba204f9 100644 --- a/CreamInstaller/Utility/ThemeManager.cs +++ b/CreamInstaller/Utility/ThemeManager.cs @@ -437,7 +437,7 @@ internal static class ThemeManager // Themed renderers for menus // ----------------------------------------------------------------- - private class DarkContextMenuRenderer : ToolStripProfessionalRenderer + private sealed class DarkContextMenuRenderer : ToolStripProfessionalRenderer { public DarkContextMenuRenderer() : base(new DarkMenuColorTable()) { } @@ -449,7 +449,7 @@ internal static class ThemeManager } } - private class DarkDropDownRenderer : ToolStripProfessionalRenderer + private sealed class DarkDropDownRenderer : ToolStripProfessionalRenderer { public DarkDropDownRenderer() : base(new DarkMenuColorTable()) { } @@ -461,7 +461,7 @@ internal static class ThemeManager } } - private class DarkMenuColorTable : ProfessionalColorTable + private sealed class DarkMenuColorTable : ProfessionalColorTable { public override Color MenuItemSelected => ColorTranslator.FromHtml("#2A2D2E"); public override Color MenuItemSelectedGradientBegin => ColorTranslator.FromHtml("#2A2D2E");