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.
This commit is contained in:
Frog
2026-06-21 17:21:33 -07:00
parent fb778bddfa
commit 9a9c533d08
2 changed files with 11 additions and 9 deletions
+8 -6
View File
@@ -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;
+3 -3
View File
@@ -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");