Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
dotnet restore SysManager/SysManager.Tests/SysManager.Tests.csproj
dotnet restore SysManager/SysManager.UITests/SysManager.UITests.csproj

- name: Check formatting
run: dotnet format SysManager/SysManager/SysManager.csproj --verify-no-changes --verbosity diagnostic

- name: Build (Release)
run: dotnet build SysManager/SysManager/SysManager.csproj -c Release --no-restore

Expand Down
2 changes: 1 addition & 1 deletion SysManager/SysManager/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[assembly: AssemblyTrademark("SysManager by laurentiu021")]
[assembly: InternalsVisibleTo("SysManager.Tests")]

[assembly:ThemeInfo(
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
Expand Down
16 changes: 8 additions & 8 deletions SysManager/SysManager/Models/FriendlyEventEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public sealed partial class FriendlyEventEntry : ObservableObject
public string SeverityIcon => Severity switch
{
EventSeverity.Critical => "⛔",
EventSeverity.Error => "🔴",
EventSeverity.Warning => "🟡",
EventSeverity.Info => "🔵",
EventSeverity.Verbose => "⚪",
EventSeverity.Error => "🔴",
EventSeverity.Warning => "🟡",
EventSeverity.Info => "🔵",
EventSeverity.Verbose => "⚪",
_ => "•"
};

public string SeverityColor => Severity switch
{
EventSeverity.Critical => "#FF3B30",
EventSeverity.Error => "#FF6B6B",
EventSeverity.Warning => "#FFD166",
EventSeverity.Info => "#4CC9F0",
EventSeverity.Verbose => "#9AA0A6",
EventSeverity.Error => "#FF6B6B",
EventSeverity.Warning => "#FFD166",
EventSeverity.Info => "#4CC9F0",
EventSeverity.Verbose => "#9AA0A6",
_ => "#9AA0A6"
};

Expand Down
10 changes: 5 additions & 5 deletions SysManager/SysManager/Services/DeepCleanupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ private sealed record Def(
private static List<Def> BuildDefinitions()
{
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
var programData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
var systemDrive = Path.GetPathRoot(Environment.SystemDirectory) ?? @"C:\";
var windowsDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
var tempUser = Path.GetTempPath();
var programData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
var systemDrive = Path.GetPathRoot(Environment.SystemDirectory) ?? @"C:\";
var windowsDir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
var tempUser = Path.GetTempPath();
var pfx86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
var pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

var defs = new List<Def>
{
Expand Down
22 changes: 18 additions & 4 deletions SysManager/SysManager/Services/DiskHealthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,31 @@ private static void ApplyVerdict(DiskHealthReport r)

private static string MapMedia(uint v) => v switch
{
3 => "HDD", 4 => "SSD", 5 => "SCM", _ => "Unspecified"
3 => "HDD",
4 => "SSD",
5 => "SCM",
_ => "Unspecified"
};

private static string MapBus(uint v) => v switch
{
1 => "SCSI", 3 => "ATA", 6 => "Fibre", 7 => "USB", 8 => "RAID",
9 => "iSCSI", 10 => "SAS", 11 => "SATA", 17 => "NVMe", _ => "Other"
1 => "SCSI",
3 => "ATA",
6 => "Fibre",
7 => "USB",
8 => "RAID",
9 => "iSCSI",
10 => "SAS",
11 => "SATA",
17 => "NVMe",
_ => "Other"
};

private static string MapHealth(uint v) => v switch
{
0 => "Healthy", 1 => "Warning", 2 => "Unhealthy", _ => "Unknown"
0 => "Healthy",
1 => "Warning",
2 => "Unhealthy",
_ => "Unknown"
};
}
10 changes: 5 additions & 5 deletions SysManager/SysManager/Services/EventExplainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ private static bool TryLookup(FriendlyEventEntry e, out (string Explanation, str
private static string BuildGenericExplanation(FriendlyEventEntry e) => e.Severity switch
{
EventSeverity.Critical => $"Critical condition reported by '{e.ProviderName}'. The system or a core component is in trouble.",
EventSeverity.Error => $"An error was logged by '{e.ProviderName}'.",
EventSeverity.Warning => $"A warning from '{e.ProviderName}' — not necessarily broken, but worth a look if it repeats.",
EventSeverity.Info => $"Informational event from '{e.ProviderName}'.",
EventSeverity.Error => $"An error was logged by '{e.ProviderName}'.",
EventSeverity.Warning => $"A warning from '{e.ProviderName}' — not necessarily broken, but worth a look if it repeats.",
EventSeverity.Info => $"Informational event from '{e.ProviderName}'.",
_ => "Low-level diagnostic event."
};

private static string BuildGenericRecommendation(FriendlyEventEntry e) => e.Severity switch
{
EventSeverity.Critical => "Read the full message below. If it repeats, search the web for 'Event ID " + e.EventId + " " + e.ProviderName + "'.",
EventSeverity.Error => "If this keeps repeating, search for 'Event ID " + e.EventId + " " + e.ProviderName + "'.",
EventSeverity.Warning => "Usually safe to ignore one-offs. Check if it's a pattern.",
EventSeverity.Error => "If this keeps repeating, search for 'Event ID " + e.EventId + " " + e.ProviderName + "'.",
EventSeverity.Warning => "Usually safe to ignore one-offs. Check if it's a pattern.",
_ => "No action needed."
};
}
13 changes: 11 additions & 2 deletions SysManager/SysManager/Services/FixedDriveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,20 @@ public static IReadOnlyList<FixedDrive> Enumerate()

private static string MapMedia(uint v) => v switch
{
3 => "HDD", 4 => "SSD", 5 => "SCM", _ => ""
3 => "HDD",
4 => "SSD",
5 => "SCM",
_ => ""
};

private static string MapBus(uint v) => v switch
{
1 => "SCSI", 3 => "ATA", 7 => "USB", 10 => "SAS", 11 => "SATA", 17 => "NVMe", _ => ""
1 => "SCSI",
3 => "ATA",
7 => "USB",
10 => "SAS",
11 => "SATA",
17 => "NVMe",
_ => ""
};
}
2 changes: 1 addition & 1 deletion SysManager/SysManager/Services/IconExtractorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed class IconExtractorService
// Lazy-initialized contextual fallback icons (shell32.dll icon indices)
private static readonly Lazy<ImageSource?> _appFallback = new(() => ExtractShell32Icon(2));
private static readonly Lazy<ImageSource?> _windowsIcon = new(() => ExtractShell32Icon(44));
private static readonly Lazy<ImageSource?> _gearIcon = new(() => ExtractShell32Icon(15));
private static readonly Lazy<ImageSource?> _gearIcon = new(() => ExtractShell32Icon(15));

/// <summary>
/// Gets the icon for the given file path or command string.
Expand Down
10 changes: 7 additions & 3 deletions SysManager/SysManager/Services/LargeFileScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
string[] files = [];
string[] dirs = [];
try { files = Directory.GetFiles(cur); } catch (IOException) { } catch (UnauthorizedAccessException) { }
try { dirs = Directory.GetDirectories(cur); } catch (IOException) { } catch (UnauthorizedAccessException) { }
try { dirs = Directory.GetDirectories(cur); } catch (IOException) { } catch (UnauthorizedAccessException) { }

Check notice

Code scanning / CodeQL

Poor error handling: empty catch block Note

Poor error handling: empty catch block.

Check notice

Code scanning / CodeQL

Poor error handling: empty catch block Note

Poor error handling: empty catch block.
Comment thread
laurentiu021 marked this conversation as resolved.
Dismissed
Comment thread
laurentiu021 marked this conversation as resolved.
Dismissed

foreach (var f in files)
{
Expand All @@ -84,7 +84,9 @@
heap.Add((fi.Length, f));
meta[f] = new LargeFileEntry
{
Path = f, Name = fi.Name, SizeBytes = fi.Length,
Path = f,
Name = fi.Name,
SizeBytes = fi.Length,
LastModified = fi.LastWriteTime
};
}
Expand All @@ -98,7 +100,9 @@
heap.Add((fi.Length, f));
meta[f] = new LargeFileEntry
{
Path = f, Name = fi.Name, SizeBytes = fi.Length,
Path = f,
Name = fi.Name,
SizeBytes = fi.Length,
LastModified = fi.LastWriteTime
};
}
Expand Down
37 changes: 30 additions & 7 deletions SysManager/SysManager/Services/SystemInfoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,28 @@ private static List<DiskInfo> QueryDisks()
};
var busType = (ushort)Convert.ToUInt32(mo["BusType"] ?? 0u) switch
{
1 => "SCSI", 2 => "ATAPI", 3 => "ATA", 4 => "1394", 5 => "SSA",
6 => "Fibre", 7 => "USB", 8 => "RAID", 9 => "iSCSI", 10 => "SAS",
11 => "SATA", 12 => "SD", 13 => "MMC", 17 => "NVMe",
1 => "SCSI",
2 => "ATAPI",
3 => "ATA",
4 => "1394",
5 => "SSA",
6 => "Fibre",
7 => "USB",
8 => "RAID",
9 => "iSCSI",
10 => "SAS",
11 => "SATA",
12 => "SD",
13 => "MMC",
17 => "NVMe",
_ => "Other"
};
var health = (ushort)Convert.ToUInt32(mo["HealthStatus"] ?? 0u) switch
{
0 => "Healthy", 1 => "Warning", 2 => "Unhealthy", _ => "Unknown"
0 => "Healthy",
1 => "Warning",
2 => "Unhealthy",
_ => "Unknown"
};
var opStatus = mo["OperationalStatus"] is ushort[] arr && arr.Length > 0
? string.Join(",", arr.Select(OpStatusName))
Expand Down Expand Up @@ -235,8 +249,17 @@ private static List<DiskInfo> QueryDisks()

private static string OpStatusName(ushort v) => v switch
{
1 => "Other", 2 => "Unknown", 3 => "OK", 4 => "Degraded",
5 => "Stressed", 6 => "Predictive Failure", 7 => "Error", 8 => "Non-Recoverable Error",
9 => "Starting", 10 => "Stopping", 11 => "Stopped", _ => $"Code {v}"
1 => "Other",
2 => "Unknown",
3 => "OK",
4 => "Degraded",
5 => "Stressed",
6 => "Predictive Failure",
7 => "Error",
8 => "Non-Recoverable Error",
9 => "Starting",
10 => "Stopping",
11 => "Stopped",
_ => $"Code {v}"
};
}
20 changes: 10 additions & 10 deletions SysManager/SysManager/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace SysManager.Services;
public sealed class UpdateService
{
public const string Owner = "laurentiu021";
public const string Repo = "SystemManager";
public const string Repo = "SystemManager";
public const string AssetName = "SysManager.exe";

private static readonly HttpClient Http = CreateClient();
Expand Down Expand Up @@ -367,20 +367,20 @@ public static bool VerifyAuthenticode(string filePath)

private sealed class GhRelease
{
[JsonPropertyName("tag_name")] public string? TagName { get; set; }
[JsonPropertyName("name")] public string? Name { get; set; }
[JsonPropertyName("body")] public string? Body { get; set; }
[JsonPropertyName("html_url")] public string? HtmlUrl { get; set; }
[JsonPropertyName("tag_name")] public string? TagName { get; set; }
[JsonPropertyName("name")] public string? Name { get; set; }
[JsonPropertyName("body")] public string? Body { get; set; }
[JsonPropertyName("html_url")] public string? HtmlUrl { get; set; }
[JsonPropertyName("published_at")] public DateTimeOffset? PublishedAt { get; set; }
[JsonPropertyName("prerelease")] public bool Prerelease { get; set; }
[JsonPropertyName("draft")] public bool Draft { get; set; }
[JsonPropertyName("assets")] public GhAsset[]? Assets { get; set; }
[JsonPropertyName("prerelease")] public bool Prerelease { get; set; }
[JsonPropertyName("draft")] public bool Draft { get; set; }
[JsonPropertyName("assets")] public GhAsset[]? Assets { get; set; }
}

private sealed class GhAsset
{
[JsonPropertyName("name")] public string? Name { get; set; }
[JsonPropertyName("size")] public long Size { get; set; }
[JsonPropertyName("name")] public string? Name { get; set; }
[JsonPropertyName("size")] public long Size { get; set; }
[JsonPropertyName("browser_download_url")] public string? BrowserDownloadUrl { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Author: laurentiu021 · https://github.com/laurentiu021/SystemManager
// License: MIT

using System.Management;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Serilog;
using System.Management;
using SysManager.Models;
using SysManager.Services;

Expand Down
12 changes: 6 additions & 6 deletions SysManager/SysManager/ViewModels/DeepCleanupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ private async Task LoadLocationsAsync()

AddLocation("📥 Downloads", Helpers.KnownFolders.GetDownloadsPath());
AddLocation("📄 Documents", Helpers.KnownFolders.GetDocumentsPath());
AddLocation("🖥️ Desktop", Helpers.KnownFolders.GetDesktopPath());
AddLocation("🎬 Videos", Helpers.KnownFolders.GetVideosPath());
AddLocation("🖼️ Pictures", Helpers.KnownFolders.GetPicturesPath());
AddLocation("🎵 Music", Helpers.KnownFolders.GetMusicPath());
AddLocation("🖥️ Desktop", Helpers.KnownFolders.GetDesktopPath());
AddLocation("🎬 Videos", Helpers.KnownFolders.GetVideosPath());
AddLocation("🖼️ Pictures", Helpers.KnownFolders.GetPicturesPath());
AddLocation("🎵 Music", Helpers.KnownFolders.GetMusicPath());

var pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var pfx86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
AddLocation("💼 Program Files", pf);
AddLocation("💼 Program Files", pf);
AddLocation("💼 Program Files (x86)", pfx86);

var drives = await _drives.EnumerateAsync();
Expand Down
14 changes: 7 additions & 7 deletions SysManager/SysManager/ViewModels/LogsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ private bool EntryFilter(object o)
var sevOk = e.Severity switch
{
EventSeverity.Critical => ShowCritical,
EventSeverity.Error => ShowError,
EventSeverity.Warning => ShowWarning,
EventSeverity.Info => ShowInfo,
EventSeverity.Verbose => ShowVerbose,
EventSeverity.Error => ShowError,
EventSeverity.Warning => ShowWarning,
EventSeverity.Info => ShowInfo,
EventSeverity.Verbose => ShowVerbose,
_ => true
};
if (!sevOk) return false;
Expand Down Expand Up @@ -321,9 +321,9 @@ private void UpdateCounts(FriendlyEventEntry e, int delta)
switch (e.Severity)
{
case EventSeverity.Critical: CriticalCount += delta; break;
case EventSeverity.Error: ErrorCount += delta; break;
case EventSeverity.Warning: WarningCount += delta; break;
case EventSeverity.Info: InfoCount += delta; break;
case EventSeverity.Error: ErrorCount += delta; break;
case EventSeverity.Warning: WarningCount += delta; break;
case EventSeverity.Info: InfoCount += delta; break;
}
}

Expand Down
Loading
Loading