From 0334d5d4956d978992edf481e3dd248a11a32fcf Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:24:09 +0000
Subject: [PATCH 01/15] Initial plan
From 18c80cee8184325ee0be03577f1b0dd2038fd830 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:34:12 +0000
Subject: [PATCH 02/15] Update logger method calls to match IDrivelutionLogger
interface signature in Linux implementation files
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Configuration/DriverUpdateOptions.cs | 22 ------
.../Abstractions/Events/DrivelutionLogger.cs | 62 +++++++++++++++
.../Abstractions/Events/IDrivelutionLogger.cs | 38 +++++++++
.../Abstractions/Events/LogEventArgs.cs | 44 +++++++++++
.../Core/DriverUpdaterFactory.cs | 21 ++---
.../Core/Logging/LoggerConfigurator.cs | 77 ++-----------------
.../GeneralDrivelution.cs | 11 +--
.../Linux/Implementation/LinuxDriverBackup.cs | 14 ++--
.../Implementation/LinuxDriverValidator.cs | 8 +-
.../Implementation/LinuxGeneralDrivelution.cs | 76 +++++++++---------
.../Implementation/WindowsDriverBackup.cs | 12 +--
.../Implementation/WindowsDriverValidator.cs | 15 ++--
.../WindowsGeneralDrivelution.cs | 49 ++++++------
13 files changed, 245 insertions(+), 204 deletions(-)
create mode 100644 src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs
create mode 100644 src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs
create mode 100644 src/c#/GeneralUpdate.Drivelution/Abstractions/Events/LogEventArgs.cs
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/Configuration/DriverUpdateOptions.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/Configuration/DriverUpdateOptions.cs
index b450a267..2ac883f9 100644
--- a/src/c#/GeneralUpdate.Drivelution/Abstractions/Configuration/DriverUpdateOptions.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/Configuration/DriverUpdateOptions.cs
@@ -12,29 +12,7 @@ public class DrivelutionOptions
///
public string DefaultBackupPath { get; set; } = "./DriverBackups";
- ///
- /// 日志级别(Debug/Info/Warn/Error/Fatal)
- /// Log level (Debug/Info/Warn/Error/Fatal)
- ///
- public string LogLevel { get; set; } = "Info";
-
- ///
- /// 日志文件路径
- /// Log file path
- ///
- public string LogFilePath { get; set; } = "./Logs/drivelution-.log";
- ///
- /// 是否启用控制台日志
- /// Enable console logging
- ///
- public bool EnableConsoleLogging { get; set; } = true;
-
- ///
- /// 是否启用文件日志
- /// Enable file logging
- ///
- public bool EnableFileLogging { get; set; } = true;
///
/// 默认重试次数
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs
new file mode 100644
index 00000000..3835fd51
--- /dev/null
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs
@@ -0,0 +1,62 @@
+namespace GeneralUpdate.Drivelution.Abstractions.Events;
+
+///
+/// Default implementation of IDrivelutionLogger that raises events
+///
+public class DrivelutionLogger : IDrivelutionLogger
+{
+ ///
+ public event EventHandler? LogMessage;
+
+ ///
+ public void Debug(string message, params object[] args)
+ {
+ RaiseLogEvent(LogLevel.Debug, message, null, args);
+ }
+
+ ///
+ public void Information(string message, params object[] args)
+ {
+ RaiseLogEvent(LogLevel.Information, message, null, args);
+ }
+
+ ///
+ public void Warning(string message, params object[] args)
+ {
+ RaiseLogEvent(LogLevel.Warning, message, null, args);
+ }
+
+ ///
+ public void Error(string message, Exception? exception = null, params object[] args)
+ {
+ RaiseLogEvent(LogLevel.Error, message, exception, args);
+ }
+
+ ///
+ public void Fatal(string message, Exception? exception = null, params object[] args)
+ {
+ RaiseLogEvent(LogLevel.Fatal, message, exception, args);
+ }
+
+ private void RaiseLogEvent(LogLevel level, string message, Exception? exception, params object[] args)
+ {
+ try
+ {
+ var formattedMessage = args.Length > 0 ? string.Format(message, args) : message;
+
+ var eventArgs = new LogEventArgs
+ {
+ Level = level,
+ Message = formattedMessage,
+ Exception = exception,
+ Timestamp = DateTime.UtcNow
+ };
+
+ LogMessage?.Invoke(this, eventArgs);
+ }
+ catch
+ {
+ // Silently ignore exceptions in logging to prevent cascading failures
+ }
+ }
+}
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs
new file mode 100644
index 00000000..f2f504a5
--- /dev/null
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs
@@ -0,0 +1,38 @@
+namespace GeneralUpdate.Drivelution.Abstractions.Events;
+
+///
+/// Logger interface for Drivelution operations
+/// Provides event-based logging mechanism to replace Serilog
+///
+public interface IDrivelutionLogger
+{
+ ///
+ /// Event raised when a log message is generated
+ ///
+ event EventHandler? LogMessage;
+
+ ///
+ /// Logs a debug message
+ ///
+ void Debug(string message, params object[] args);
+
+ ///
+ /// Logs an information message
+ ///
+ void Information(string message, params object[] args);
+
+ ///
+ /// Logs a warning message
+ ///
+ void Warning(string message, params object[] args);
+
+ ///
+ /// Logs an error message
+ ///
+ void Error(string message, Exception? exception = null, params object[] args);
+
+ ///
+ /// Logs a fatal message
+ ///
+ void Fatal(string message, Exception? exception = null, params object[] args);
+}
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/LogEventArgs.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/LogEventArgs.cs
new file mode 100644
index 00000000..c154d208
--- /dev/null
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/LogEventArgs.cs
@@ -0,0 +1,44 @@
+namespace GeneralUpdate.Drivelution.Abstractions.Events;
+
+///
+/// Event arguments for log messages from Drivelution operations
+///
+public class LogEventArgs : EventArgs
+{
+ ///
+ /// Log level
+ ///
+ public LogLevel Level { get; set; }
+
+ ///
+ /// Log message
+ ///
+ public string Message { get; set; } = string.Empty;
+
+ ///
+ /// Exception if any
+ ///
+ public Exception? Exception { get; set; }
+
+ ///
+ /// Timestamp of the log
+ ///
+ public DateTime Timestamp { get; set; } = DateTime.UtcNow;
+
+ ///
+ /// Additional context data
+ ///
+ public Dictionary? Context { get; set; }
+}
+
+///
+/// Log level enumeration
+///
+public enum LogLevel
+{
+ Debug,
+ Information,
+ Warning,
+ Error,
+ Fatal
+}
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index 10a2e4af..224e3d2f 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -1,10 +1,10 @@
using System.Runtime.InteropServices;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Windows.Implementation;
using GeneralUpdate.Drivelution.Linux.Implementation;
using GeneralUpdate.Drivelution.MacOS.Implementation;
-using Serilog;
namespace GeneralUpdate.Drivelution.Core;
@@ -22,7 +22,7 @@ public static class DrivelutionFactory
/// 配置选项(可选)/ Configuration options (optional)
/// 平台特定的驱动更新器实现 / Platform-specific driver updater implementation
/// 当前平台不支持时抛出 / Thrown when current platform is not supported
- public static IGeneralDrivelution Create(ILogger? logger = null, DrivelutionOptions? options = null)
+ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
{
// Use default logger if not provided
logger ??= CreateDefaultLogger(options);
@@ -53,7 +53,7 @@ public static IGeneralDrivelution Create(ILogger? logger = null, DrivelutionOpti
else
{
var osDescription = RuntimeInformation.OSDescription;
- logger.Error("Unsupported platform detected: {Platform}", osDescription);
+ logger.Error("Unsupported platform detected: {Platform}", null, osDescription);
throw new PlatformNotSupportedException(
$"Current platform '{osDescription}' is not supported. " +
"Supported platforms: Windows (8+), Linux (Ubuntu 18.04+, CentOS 7+, Debian 10+)");
@@ -66,7 +66,7 @@ public static IGeneralDrivelution Create(ILogger? logger = null, DrivelutionOpti
///
/// 日志记录器 / Logger
/// 平台特定的驱动验证器实现 / Platform-specific driver validator implementation
- public static IDriverValidator CreateValidator(ILogger? logger = null)
+ public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null)
{
logger ??= CreateDefaultLogger();
@@ -94,7 +94,7 @@ public static IDriverValidator CreateValidator(ILogger? logger = null)
///
/// 日志记录器 / Logger
/// 平台特定的驱动备份实现 / Platform-specific driver backup implementation
- public static IDriverBackup CreateBackup(ILogger? logger = null)
+ public static IDriverBackup CreateBackup(IDrivelutionLogger? logger = null)
{
logger ??= CreateDefaultLogger();
@@ -149,15 +149,8 @@ public static bool IsPlatformSupported()
/// 创建默认日志记录器
/// Creates a default logger
///
- private static ILogger CreateDefaultLogger(DrivelutionOptions? options = null)
+ private static IDrivelutionLogger CreateDefaultLogger(DrivelutionOptions? options = null)
{
- if (options != null)
- {
- return Logging.LoggerConfigurator.ConfigureLogger(options);
- }
- else
- {
- return Logging.LoggerConfigurator.CreateDefaultLogger();
- }
+ return Logging.LoggerConfigurator.ConfigureLogger(options);
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/Logging/LoggerConfigurator.cs b/src/c#/GeneralUpdate.Drivelution/Core/Logging/LoggerConfigurator.cs
index 5a488595..19ab718d 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/Logging/LoggerConfigurator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/Logging/LoggerConfigurator.cs
@@ -1,6 +1,5 @@
-using Serilog;
-using Serilog.Events;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
+using GeneralUpdate.Drivelution.Abstractions.Events;
namespace GeneralUpdate.Drivelution.Core.Logging;
@@ -16,64 +15,10 @@ public static class LoggerConfigurator
///
/// 驱动更新配置选项 / Driver update configuration options
/// 配置好的日志器 / Configured logger
- public static ILogger ConfigureLogger(DrivelutionOptions options)
+ public static IDrivelutionLogger ConfigureLogger(DrivelutionOptions? options = null)
{
- if (options == null)
- {
- throw new ArgumentNullException(nameof(options));
- }
-
- var loggerConfig = new LoggerConfiguration();
-
- // Set log level
- var logLevel = ParseLogLevel(options.LogLevel);
- loggerConfig.MinimumLevel.Is(logLevel);
-
- // Configure console sink
- if (options.EnableConsoleLogging)
- {
- loggerConfig.WriteTo.Console(
- outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}");
- }
-
- // Configure file sink
- if (options.EnableFileLogging)
- {
- var logPath = string.IsNullOrWhiteSpace(options.LogFilePath)
- ? "./Logs/drivelution-.log"
- : options.LogFilePath;
-
- loggerConfig.WriteTo.File(
- logPath,
- rollingInterval: RollingInterval.Day,
- outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}",
- retainedFileCountLimit: 30,
- fileSizeLimitBytes: 10 * 1024 * 1024); // 10MB per file
- }
-
- // Enrich with context information
- loggerConfig.Enrich.FromLogContext();
-
- return loggerConfig.CreateLogger();
- }
-
- ///
- /// 解析日志级别
- /// Parses log level
- ///
- /// 日志级别字符串 / Log level string
- /// 日志事件级别 / Log event level
- private static LogEventLevel ParseLogLevel(string logLevel)
- {
- return logLevel?.ToUpperInvariant() switch
- {
- "DEBUG" or "VERBOSE" => LogEventLevel.Debug,
- "INFO" or "INFORMATION" => LogEventLevel.Information,
- "WARN" or "WARNING" => LogEventLevel.Warning,
- "ERROR" => LogEventLevel.Error,
- "FATAL" or "CRITICAL" => LogEventLevel.Fatal,
- _ => LogEventLevel.Information
- };
+ // Return a new logger instance that raises events instead of writing to files
+ return new DrivelutionLogger();
}
///
@@ -81,18 +26,8 @@ private static LogEventLevel ParseLogLevel(string logLevel)
/// Creates default logger
///
/// 默认配置的日志器 / Logger with default configuration
- public static ILogger CreateDefaultLogger()
+ public static IDrivelutionLogger CreateDefaultLogger()
{
- return new LoggerConfiguration()
- .MinimumLevel.Information()
- .WriteTo.Console(
- outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
- .WriteTo.File(
- "./Logs/drivelution-.log",
- rollingInterval: RollingInterval.Day,
- outputTemplate: "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Level:u3}] {Message:lj}{NewLine}{Exception}",
- retainedFileCountLimit: 30)
- .Enrich.FromLogContext()
- .CreateLogger();
+ return new DrivelutionLogger();
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
index bcdb417b..b8920e3b 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
@@ -1,9 +1,9 @@
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Logging;
using GeneralUpdate.Drivelution.Core.Utilities;
-using Serilog;
namespace GeneralUpdate.Drivelution;
@@ -18,7 +18,7 @@ namespace GeneralUpdate.Drivelution;
/// var result = await updater.UpdateAsync(driverInfo, strategy);
///
/// // With configuration
-/// var options = new DrivelutionOptions { LogLevel = "Info" };
+/// var options = new DrivelutionOptions { };
/// var updater = GeneralDrivelution.Create(options);
/// var result = await updater.UpdateAsync(driverInfo, strategy);
///
@@ -33,10 +33,7 @@ public static class GeneralDrivelution
/// Thrown when platform is not supported
public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
{
- var logger = options != null
- ? LoggerConfigurator.ConfigureLogger(options)
- : LoggerConfigurator.CreateDefaultLogger();
-
+ var logger = LoggerConfigurator.ConfigureLogger(options);
return Core.DrivelutionFactory.Create(logger, options);
}
@@ -46,7 +43,7 @@ public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
/// Custom logger
/// Configuration options (optional)
/// Platform-adapted driver updater
- public static IGeneralDrivelution Create(ILogger logger, DrivelutionOptions? options = null)
+ public static IGeneralDrivelution Create(IDrivelutionLogger logger, DrivelutionOptions? options = null)
{
return Core.DrivelutionFactory.Create(logger, options);
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs
index 9cb1c698..4ec1073a 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs
@@ -1,7 +1,7 @@
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
-using Serilog;
namespace GeneralUpdate.Drivelution.Linux.Implementation;
@@ -12,9 +12,9 @@ namespace GeneralUpdate.Drivelution.Linux.Implementation;
[SupportedOSPlatform("linux")]
public class LinuxDriverBackup : IDriverBackup
{
- private readonly ILogger _logger;
+ private readonly IDrivelutionLogger _logger;
- public LinuxDriverBackup(ILogger logger)
+ public LinuxDriverBackup(IDrivelutionLogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -51,12 +51,12 @@ public async Task BackupAsync(
await sourceStream.CopyToAsync(destinationStream, cancellationToken);
}
- _logger.Information("Backup completed: {BackupPath}", backupPathWithTimestamp);
+ _logger.Information($"Backup completed: {backupPathWithTimestamp}");
return true;
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to backup driver");
+ _logger.Error("Failed to backup driver", ex);
throw new DriverBackupException($"Failed to backup driver: {ex.Message}", ex);
}
}
@@ -96,7 +96,7 @@ public async Task RestoreAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to restore driver");
+ _logger.Error("Failed to restore driver", ex);
throw new DriverRollbackException($"Failed to restore driver: {ex.Message}", ex);
}
}
@@ -119,7 +119,7 @@ public async Task DeleteBackupAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to delete backup");
+ _logger.Error("Failed to delete backup", ex);
return false;
}
}, cancellationToken);
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
index b2f27996..3029b494 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
@@ -1,10 +1,10 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
using GeneralUpdate.Drivelution.Linux.Helpers;
-using Serilog;
namespace GeneralUpdate.Drivelution.Linux.Implementation;
@@ -15,9 +15,9 @@ namespace GeneralUpdate.Drivelution.Linux.Implementation;
[SupportedOSPlatform("linux")]
public class LinuxDriverValidator : IDriverValidator
{
- private readonly ILogger _logger;
+ private readonly IDrivelutionLogger _logger;
- public LinuxDriverValidator(ILogger logger)
+ public LinuxDriverValidator(IDrivelutionLogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -52,7 +52,7 @@ public async Task ValidateSignatureAsync(
return await LinuxSignatureHelper.ValidateGpgSignatureAsync(filePath, signaturePath, trustedPublishers);
}
- _logger.Warning("No signature file found for: {FilePath}", filePath);
+ _logger.Warning($"No signature file found for: {filePath}");
return !trustedPublishers.Any(); // If no trusted publishers specified, accept unsigned
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
index fa6f5058..c2b82c60 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
@@ -1,11 +1,11 @@
using System.Runtime.Versioning;
using System.Diagnostics.CodeAnalysis;
using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
using GeneralUpdate.Drivelution.Linux.Helpers;
-using Serilog;
namespace GeneralUpdate.Drivelution.Linux.Implementation;
@@ -16,11 +16,11 @@ namespace GeneralUpdate.Drivelution.Linux.Implementation;
[SupportedOSPlatform("linux")]
public class LinuxGeneralDrivelution : IGeneralDrivelution
{
- private readonly ILogger _logger;
+ private readonly IDrivelutionLogger _logger;
private readonly IDriverValidator _validator;
private readonly IDriverBackup _backup;
- public LinuxGeneralDrivelution(ILogger logger, IDriverValidator validator, IDriverBackup backup)
+ public LinuxGeneralDrivelution(IDrivelutionLogger logger, IDriverValidator validator, IDriverBackup backup)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_validator = validator ?? throw new ArgumentNullException(nameof(validator));
@@ -43,8 +43,7 @@ public async Task UpdateAsync(
try
{
- _logger.Information("Starting driver update for: {DriverName} v{Version}",
- driverInfo.Name, driverInfo.Version);
+ _logger.Information($"Starting driver update for: {driverInfo.Name} v{driverInfo.Version}");
// Permission check
await LinuxPermissionHelper.EnsureSudoAsync();
@@ -77,7 +76,7 @@ public async Task UpdateAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Driver update failed");
+ _logger.Error("Driver update failed", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = new ErrorInfo
@@ -131,11 +130,11 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information("Rolling back driver from backup: {BackupPath}", backupPath);
+ _logger.Information($"Rolling back driver from backup: {backupPath}");
if (!Directory.Exists(backupPath))
{
- _logger.Error("Backup directory not found: {BackupPath}", backupPath);
+ _logger.Error($"Backup directory not found: {backupPath}");
return false;
}
@@ -144,7 +143,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
if (!koFiles.Any())
{
- _logger.Warning("No kernel module backups found in: {BackupPath}", backupPath);
+ _logger.Warning($"No kernel module backups found in: {backupPath}");
return false;
}
@@ -152,7 +151,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information("Attempting to restore kernel module: {Module}", koFile);
+ _logger.Information($"Attempting to restore kernel module: {koFile}");
// Copy back to /lib/modules or appropriate location
var moduleName = Path.GetFileNameWithoutExtension(koFile);
@@ -161,11 +160,11 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
await ExecuteCommandAsync("modprobe", $"-r {moduleName}", cancellationToken);
// Try to reload the backed-up module (if system supports it)
- _logger.Information("Restored module: {Module}", moduleName);
+ _logger.Information($"Restored module: {moduleName}");
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to restore module: {Module}", koFile);
+ _logger.Warning($"Failed to restore module: {koFile}", ex);
}
}
@@ -173,14 +172,14 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to rollback driver");
+ _logger.Error("Failed to rollback driver", ex);
return false;
}
}
private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, CancellationToken cancellationToken)
{
- _logger.Information("Installing Linux driver: {DriverPath}", driverInfo.FilePath);
+ _logger.Information($"Installing Linux driver: {driverInfo.FilePath}");
var filePath = driverInfo.FilePath;
var extension = Path.GetExtension(filePath).ToLowerInvariant();
@@ -205,7 +204,7 @@ private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, Cancell
}
else
{
- _logger.Warning("Unknown driver format: {Extension}. Attempting generic installation.", extension);
+ _logger.Warning($"Unknown driver format: {extension}. Attempting generic installation.");
// Try to detect and install generically
await InstallKernelModuleAsync(filePath, cancellationToken);
}
@@ -214,7 +213,7 @@ private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, Cancell
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to install Linux driver");
+ _logger.Error("Failed to install Linux driver", ex);
throw new DriverInstallationException(
$"Failed to install Linux driver: {ex.Message}", ex);
}
@@ -222,7 +221,7 @@ private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, Cancell
private async Task InstallKernelModuleAsync(string modulePath, CancellationToken cancellationToken)
{
- _logger.Information("Installing kernel module: {ModulePath}", modulePath);
+ _logger.Information($"Installing kernel module: {modulePath}");
var moduleName = Path.GetFileNameWithoutExtension(modulePath);
@@ -244,7 +243,7 @@ private async Task InstallKernelModuleAsync(string modulePath, CancellationToken
var kernelVersion = await GetKernelVersionAsync(cancellationToken);
var targetDir = $"/lib/modules/{kernelVersion}/extra";
- _logger.Information("Target module directory: {TargetDir}", targetDir);
+ _logger.Information($"Target module directory: {targetDir}");
// Note: This would typically require root permissions
// In a real scenario, you'd use sudo or elevated permissions
@@ -254,7 +253,7 @@ private async Task InstallKernelModuleAsync(string modulePath, CancellationToken
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to load kernel module");
+ _logger.Error("Failed to load kernel module", ex);
throw;
}
}
@@ -262,7 +261,7 @@ private async Task InstallKernelModuleAsync(string modulePath, CancellationToken
private async Task InstallDebPackageAsync(string packagePath, CancellationToken cancellationToken)
{
- _logger.Information("Installing Debian package: {PackagePath}", packagePath);
+ _logger.Information($"Installing Debian package: {packagePath}");
try
{
@@ -272,14 +271,14 @@ private async Task InstallDebPackageAsync(string packagePath, CancellationToken
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to install Debian package");
+ _logger.Error("Failed to install Debian package", ex);
throw;
}
}
private async Task InstallRpmPackageAsync(string packagePath, CancellationToken cancellationToken)
{
- _logger.Information("Installing RPM package: {PackagePath}", packagePath);
+ _logger.Information($"Installing RPM package: {packagePath}");
try
{
@@ -298,7 +297,7 @@ private async Task InstallRpmPackageAsync(string packagePath, CancellationToken
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to install RPM package");
+ _logger.Error("Failed to install RPM package", ex);
throw;
}
}
@@ -341,8 +340,7 @@ private async Task ExecuteCommandAsync(string command, string arguments,
if (process.ExitCode != 0)
{
- _logger.Warning("Command {Command} {Arguments} exited with code {ExitCode}. Error: {Error}",
- command, arguments, process.ExitCode, error);
+ _logger.Warning($"Command {command} {arguments} exited with code {process.ExitCode}. Error: {error}");
throw new InvalidOperationException($"Command failed with exit code {process.ExitCode}: {error}");
}
@@ -370,11 +368,11 @@ public async Task> GetDriversFromDirectoryAsync(
try
{
- _logger.Information("Reading driver information from directory: {DirectoryPath}", directoryPath);
+ _logger.Information($"Reading driver information from directory: {directoryPath}");
if (!Directory.Exists(directoryPath))
{
- _logger.Warning("Directory not found: {DirectoryPath}", directoryPath);
+ _logger.Warning($"Directory not found: {directoryPath}");
return driverInfoList;
}
@@ -390,7 +388,7 @@ public async Task> GetDriversFromDirectoryAsync(
driverFiles = driverFiles.Concat(debFiles).Concat(rpmFiles).ToArray();
}
- _logger.Information("Found {Count} driver files matching pattern: {Pattern}", driverFiles.Length, pattern);
+ _logger.Information($"Found {driverFiles.Length} driver files matching pattern: {pattern}");
foreach (var filePath in driverFiles)
{
@@ -403,20 +401,20 @@ public async Task> GetDriversFromDirectoryAsync(
if (driverInfo != null)
{
driverInfoList.Add(driverInfo);
- _logger.Information("Parsed driver: {DriverName} v{Version}", driverInfo.Name, driverInfo.Version);
+ _logger.Information($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to parse driver file: {FilePath}", filePath);
+ _logger.Warning($"Failed to parse driver file: {filePath}", ex);
}
}
- _logger.Information("Successfully loaded {Count} driver(s) from directory", driverInfoList.Count);
+ _logger.Information($"Successfully loaded {driverInfoList.Count} driver(s) from directory");
}
catch (Exception ex)
{
- _logger.Error(ex, "Error reading drivers from directory: {DirectoryPath}", directoryPath);
+ _logger.Error($"Error reading drivers from directory: {directoryPath}", ex);
}
return driverInfoList;
@@ -463,7 +461,7 @@ public async Task> GetDriversFromDirectoryAsync(
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to parse driver file: {FilePath}", filePath);
+ _logger.Warning($"Failed to parse driver file: {filePath}", ex);
return null;
}
}
@@ -506,9 +504,9 @@ private async Task ParseKernelModuleAsync(string koPath, DriverInfo driverInfo,
driverInfo.Version = "1.0.0";
}
}
- catch (Exception ex)
+ catch (Exception)
{
- _logger.Debug(ex, "Could not get module info for: {KoPath}", koPath);
+ _logger.Debug($"Could not get module info for: {koPath}");
driverInfo.Version = "1.0.0";
}
}
@@ -545,9 +543,9 @@ private async Task ParseDebPackageAsync(string debPath, DriverInfo driverInfo, C
driverInfo.Version = "1.0.0";
}
}
- catch (Exception ex)
+ catch (Exception)
{
- _logger.Debug(ex, "Could not get package info for: {DebPath}", debPath);
+ _logger.Debug($"Could not get package info for: {debPath}");
driverInfo.Version = "1.0.0";
}
}
@@ -592,9 +590,9 @@ private async Task ParseRpmPackageAsync(string rpmPath, DriverInfo driverInfo, C
driverInfo.Version = "1.0.0";
}
}
- catch (Exception ex)
+ catch (Exception)
{
- _logger.Debug(ex, "Could not get package info for: {RpmPath}", rpmPath);
+ _logger.Debug($"Could not get package info for: {rpmPath}");
driverInfo.Version = "1.0.0";
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
index ffb53f59..c724c073 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
@@ -1,7 +1,7 @@
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
-using Serilog;
namespace GeneralUpdate.Drivelution.Windows.Implementation;
@@ -12,9 +12,9 @@ namespace GeneralUpdate.Drivelution.Windows.Implementation;
[SupportedOSPlatform("windows")]
public class WindowsDriverBackup : IDriverBackup
{
- private readonly ILogger _logger;
+ private readonly IDrivelutionLogger _logger;
- public WindowsDriverBackup(ILogger logger)
+ public WindowsDriverBackup(IDrivelutionLogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -62,7 +62,7 @@ public async Task BackupAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to backup driver");
+ _logger.Error("Failed to backup driver", ex);
throw new DriverBackupException($"Failed to backup driver: {ex.Message}", ex);
}
}
@@ -110,7 +110,7 @@ public async Task RestoreAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to restore driver");
+ _logger.Error("Failed to restore driver", ex);
throw new DriverRollbackException($"Failed to restore driver: {ex.Message}", ex);
}
}
@@ -140,7 +140,7 @@ public async Task DeleteBackupAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to delete backup");
+ _logger.Error("Failed to delete backup", ex);
return false;
}
}, cancellationToken);
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
index c92af9b1..d37358fc 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
@@ -1,11 +1,10 @@
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
using GeneralUpdate.Drivelution.Windows.Helpers;
-using Serilog;
namespace GeneralUpdate.Drivelution.Windows.Implementation;
@@ -16,9 +15,9 @@ namespace GeneralUpdate.Drivelution.Windows.Implementation;
[SupportedOSPlatform("windows")]
public class WindowsDriverValidator : IDriverValidator
{
- private readonly ILogger _logger;
+ private readonly IDrivelutionLogger _logger;
- public WindowsDriverValidator(ILogger logger)
+ public WindowsDriverValidator(IDrivelutionLogger logger)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
@@ -49,7 +48,7 @@ public async Task ValidateIntegrityAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "File integrity validation failed with exception");
+ _logger.Error("File integrity validation failed with exception", ex);
throw new DriverValidationException(
$"Failed to validate file integrity: {ex.Message}",
"Integrity",
@@ -58,8 +57,6 @@ public async Task ValidateIntegrityAsync(
}
///
- [RequiresUnreferencedCode("X509Certificate validation may require runtime reflection")]
- [RequiresDynamicCode("X509Certificate validation may require runtime code generation")]
public async Task ValidateSignatureAsync(
string filePath,
IEnumerable trustedPublishers,
@@ -84,7 +81,7 @@ public async Task ValidateSignatureAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Driver signature validation failed with exception");
+ _logger.Error("Driver signature validation failed with exception", ex);
throw new DriverValidationException(
$"Failed to validate driver signature: {ex.Message}",
"Signature",
@@ -120,7 +117,7 @@ public async Task ValidateCompatibilityAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Driver compatibility validation failed with exception");
+ _logger.Error("Driver compatibility validation failed with exception", ex);
throw new DriverValidationException(
$"Failed to validate driver compatibility: {ex.Message}",
"Compatibility",
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
index df7ba8fe..b49eb46e 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
@@ -1,11 +1,11 @@
using System.Diagnostics;
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
using GeneralUpdate.Drivelution.Windows.Helpers;
-using Serilog;
namespace GeneralUpdate.Drivelution.Windows.Implementation;
@@ -16,11 +16,11 @@ namespace GeneralUpdate.Drivelution.Windows.Implementation;
[SupportedOSPlatform("windows")]
public class WindowsGeneralDrivelution : IGeneralDrivelution
{
- private readonly ILogger _logger;
+ private readonly IDrivelutionLogger _logger;
private readonly IDriverValidator _validator;
private readonly IDriverBackup _backup;
- public WindowsGeneralDrivelution(ILogger logger, IDriverValidator validator, IDriverBackup backup)
+ public WindowsGeneralDrivelution(IDrivelutionLogger logger, IDriverValidator validator, IDriverBackup backup)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_validator = validator ?? throw new ArgumentNullException(nameof(validator));
@@ -116,7 +116,7 @@ public async Task UpdateAsync(
}
catch (DriverPermissionException ex)
{
- _logger.Error(ex, "Permission denied during driver update");
+ _logger.Error("Permission denied during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.PermissionDenied, false);
@@ -124,7 +124,7 @@ public async Task UpdateAsync(
}
catch (DriverValidationException ex)
{
- _logger.Error(ex, "Validation failed during driver update");
+ _logger.Error("Validation failed during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.HashValidationFailed, false);
@@ -132,7 +132,7 @@ public async Task UpdateAsync(
}
catch (DriverInstallationException ex)
{
- _logger.Error(ex, "Installation failed during driver update");
+ _logger.Error("Installation failed during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.InstallationFailed, ex.CanRetry);
@@ -152,7 +152,7 @@ public async Task UpdateAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Unexpected error during driver update");
+ _logger.Error("Unexpected error during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.Unknown, false);
@@ -178,7 +178,7 @@ public async Task ValidateAsync(DriverInfo driverInfo, CancellationToken c
// Validate file exists
if (!File.Exists(driverInfo.FilePath))
{
- _logger.Error("Driver file not found: {FilePath}", driverInfo.FilePath);
+ _logger.Error($"Driver file not found: {driverInfo.FilePath}");
return false;
}
@@ -217,7 +217,7 @@ public async Task ValidateAsync(DriverInfo driverInfo, CancellationToken c
}
catch (Exception ex)
{
- _logger.Error(ex, "Driver validation failed");
+ _logger.Error("Driver validation failed", ex);
return false;
}
}
@@ -231,7 +231,7 @@ public async Task BackupAsync(DriverInfo driverInfo, string backupPath, Ca
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to backup driver");
+ _logger.Error("Failed to backup driver", ex);
return false;
}
}
@@ -250,7 +250,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
if (!Directory.Exists(backupPath))
{
- _logger.Error("Backup directory not found: {BackupPath}", backupPath);
+ _logger.Error($"Backup directory not found: {backupPath}");
return false;
}
@@ -278,7 +278,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to restore driver from: {InfFile}", infFile);
+ _logger.Warning($"Failed to restore driver from: {infFile}", ex);
}
}
}
@@ -287,7 +287,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
}
catch (Exception ex)
{
- _logger.Error(ex, "Failed to rollback driver");
+ _logger.Error("Failed to rollback driver", ex);
throw new DriverRollbackException($"Failed to rollback driver: {ex.Message}", ex);
}
}
@@ -317,7 +317,7 @@ private async Task ExecuteDriverInstallationAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Driver installation failed");
+ _logger.Error("Driver installation failed", ex);
throw new DriverInstallationException($"Failed to install driver: {ex.Message}", ex);
}
}
@@ -352,8 +352,7 @@ private async Task InstallDriverUsingPnPUtilAsync(string driverPath, Cancellatio
if (process.ExitCode != 0)
{
- _logger.Error("PnPUtil failed with exit code {ExitCode}. Error: {Error}",
- process.ExitCode, error);
+ _logger.Error($"PnPUtil failed with exit code {process.ExitCode}. Error: {error}");
throw new DriverInstallationException(
$"PnPUtil failed with exit code {process.ExitCode}: {error}");
}
@@ -400,7 +399,7 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to verify driver installation");
+ _logger.Warning("Failed to verify driver installation", ex);
// Return true to not block the update if verification fails
return true;
}
@@ -425,7 +424,7 @@ private async Task TryRollbackAsync(string backupPath, CancellationToken c
}
catch (Exception ex)
{
- _logger.Error(ex, "Rollback failed");
+ _logger.Error("Rollback failed", ex);
return false;
}
}
@@ -498,7 +497,7 @@ public async Task> GetDriversFromDirectoryAsync(
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to parse driver file: {FilePath}", filePath);
+ _logger.Warning($"Failed to parse driver file: {filePath}", ex);
}
}
@@ -506,7 +505,7 @@ public async Task> GetDriversFromDirectoryAsync(
}
catch (Exception ex)
{
- _logger.Error(ex, "Error reading drivers from directory: {DirectoryPath}", directoryPath);
+ _logger.Error($"Error reading drivers from directory: {directoryPath}", ex);
}
return driverInfoList;
@@ -574,16 +573,16 @@ public async Task> GetDriversFromDirectoryAsync(
}
}
}
- catch (Exception ex)
+ catch
{
- _logger.Debug(ex, "Could not get signature for file: {FilePath}", filePath);
+ _logger.Debug($"Could not get signature for file: {filePath}");
}
return driverInfo;
}
catch (Exception ex)
{
- _logger.Warning(ex, "Failed to parse driver file: {FilePath}", filePath);
+ _logger.Warning($"Failed to parse driver file: {filePath}", ex);
return null;
}
}
@@ -646,9 +645,9 @@ private async Task ParseInfFileAsync(string infPath, DriverInfo driverInfo, Canc
driverInfo.Version = "1.0.0";
}
}
- catch (Exception ex)
+ catch
{
- _logger.Debug(ex, "Could not parse INF file: {InfPath}", infPath);
+ _logger.Debug($"Could not parse INF file: {infPath}");
}
}
}
From 49946885baaf42e2e8682ff5d37a67b32cc93548 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:36:41 +0000
Subject: [PATCH 03/15] Remove AOT-incompatible attributes from Linux and MacOS
implementations
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Linux/Implementation/LinuxDriverValidator.cs | 3 ---
.../Linux/Implementation/LinuxGeneralDrivelution.cs | 3 ---
.../MacOS/Implementation/MacOsGeneralDrivelution.cs | 7 -------
3 files changed, 13 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
index 3029b494..ad685525 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
@@ -1,4 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Events;
@@ -33,8 +32,6 @@ public async Task ValidateIntegrityAsync(
}
///
- [RequiresUnreferencedCode("Signature validation may require runtime reflection on some platforms")]
- [RequiresDynamicCode("Signature validation may require runtime code generation on some platforms")]
public async Task ValidateSignatureAsync(
string filePath,
IEnumerable trustedPublishers,
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
index c2b82c60..044cc287 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
@@ -1,5 +1,4 @@
using System.Runtime.Versioning;
-using System.Diagnostics.CodeAnalysis;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
@@ -28,8 +27,6 @@ public LinuxGeneralDrivelution(IDrivelutionLogger logger, IDriverValidator valid
}
///
- [RequiresUnreferencedCode("Update process may include signature validation that requires runtime reflection on some platforms")]
- [RequiresDynamicCode("Update process may include signature validation that requires runtime code generation on some platforms")]
public async Task UpdateAsync(
DriverInfo driverInfo,
UpdateStrategy strategy,
diff --git a/src/c#/GeneralUpdate.Drivelution/MacOS/Implementation/MacOsGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/MacOS/Implementation/MacOsGeneralDrivelution.cs
index 2cfd84a6..d23a345d 100644
--- a/src/c#/GeneralUpdate.Drivelution/MacOS/Implementation/MacOsGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/MacOS/Implementation/MacOsGeneralDrivelution.cs
@@ -1,4 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.Versioning;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Models;
@@ -24,8 +23,6 @@ namespace GeneralUpdate.Drivelution.MacOS.Implementation;
public class MacOsGeneralDrivelution : IGeneralDrivelution
{
///
- [RequiresUnreferencedCode("Update process may include signature validation that requires runtime reflection on some platforms")]
- [RequiresDynamicCode("Update process may include signature validation that requires runtime code generation on some platforms")]
public Task UpdateAsync(
DriverInfo driverInfo,
UpdateStrategy strategy,
@@ -37,8 +34,6 @@ public Task UpdateAsync(
}
///
- [RequiresUnreferencedCode("Validation includes signature validation that may require runtime reflection on some platforms")]
- [RequiresDynamicCode("Validation includes signature validation that may require runtime code generation on some platforms")]
public Task ValidateAsync(
DriverInfo driverInfo,
CancellationToken cancellationToken = default)
@@ -96,8 +91,6 @@ public Task ValidateIntegrityAsync(
}
///
- [RequiresUnreferencedCode("Signature validation may require runtime reflection on some platforms")]
- [RequiresDynamicCode("Signature validation may require runtime code generation on some platforms")]
public Task ValidateSignatureAsync(
string filePath,
IEnumerable trustedPublishers,
From d19ece463bead8905b02050153a4f17010d84a52 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:38:08 +0000
Subject: [PATCH 04/15] Remove Serilog and AOT attributes from Drivelution
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Abstractions/IDriverValidator.cs | 7 -------
.../Abstractions/IGeneralDrivelution.cs | 11 -----------
.../GeneralUpdate.Drivelution.csproj | 6 ------
.../Windows/Helpers/WindowsSignatureHelper.cs | 7 -------
4 files changed, 31 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/IDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/IDriverValidator.cs
index 6e8e84b2..d8c798dc 100644
--- a/src/c#/GeneralUpdate.Drivelution/Abstractions/IDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/IDriverValidator.cs
@@ -1,4 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
using GeneralUpdate.Drivelution.Abstractions.Models;
namespace GeneralUpdate.Drivelution.Abstractions;
@@ -28,12 +27,6 @@ public interface IDriverValidator
/// 信任的发布者列表 / Trusted publishers list
/// 取消令牌 / Cancellation token
/// 验证是否通过 / Validation result
- ///
- /// Note: On Windows, this may require reflection for X509Certificate validation.
- /// Platform-specific implementations should add appropriate AOT compatibility attributes.
- ///
- [RequiresUnreferencedCode("Signature validation may require runtime reflection on some platforms")]
- [RequiresDynamicCode("Signature validation may require runtime code generation on some platforms")]
Task ValidateSignatureAsync(string filePath, IEnumerable trustedPublishers, CancellationToken cancellationToken = default);
///
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/IGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/IGeneralDrivelution.cs
index 093e0360..f3d95162 100644
--- a/src/c#/GeneralUpdate.Drivelution/Abstractions/IGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/IGeneralDrivelution.cs
@@ -1,4 +1,3 @@
-using System.Diagnostics.CodeAnalysis;
using GeneralUpdate.Drivelution.Abstractions.Models;
namespace GeneralUpdate.Drivelution.Abstractions;
@@ -15,11 +14,6 @@ public interface IGeneralDrivelution
/// Update strategy
/// Cancellation token
/// Update result
- ///
- /// Note: Update process may include signature validation that requires reflection on some platforms.
- ///
- [RequiresUnreferencedCode("Update process may include signature validation that requires runtime reflection on some platforms")]
- [RequiresDynamicCode("Update process may include signature validation that requires runtime code generation on some platforms")]
Task UpdateAsync(DriverInfo driverInfo, UpdateStrategy strategy, CancellationToken cancellationToken = default);
///
@@ -28,11 +22,6 @@ public interface IGeneralDrivelution
/// Driver information
/// Cancellation token
/// Validation result
- ///
- /// Note: Includes signature validation that may require reflection on some platforms.
- ///
- [RequiresUnreferencedCode("Validation includes signature validation that may require runtime reflection on some platforms")]
- [RequiresDynamicCode("Validation includes signature validation that may require runtime code generation on some platforms")]
Task ValidateAsync(DriverInfo driverInfo, CancellationToken cancellationToken = default);
///
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
index a89c36c0..3b918ae9 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
@@ -12,10 +12,4 @@
full
-
-
-
-
-
-
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Helpers/WindowsSignatureHelper.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Helpers/WindowsSignatureHelper.cs
index 655dd1ea..60747c09 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Helpers/WindowsSignatureHelper.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Helpers/WindowsSignatureHelper.cs
@@ -1,7 +1,6 @@
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography.X509Certificates;
-using System.Diagnostics.CodeAnalysis;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
namespace GeneralUpdate.Drivelution.Windows.Helpers;
@@ -20,8 +19,6 @@ public static class WindowsSignatureHelper
/// 文件路径 / File path
/// 信任的发布者列表 / Trusted publishers list
/// 是否验证通过 / Whether validation succeeded
- [RequiresUnreferencedCode("X509Certificate validation may require runtime reflection")]
- [RequiresDynamicCode("X509Certificate validation may require runtime code generation")]
public static async Task ValidateAuthenticodeSignatureAsync(string filePath, IEnumerable trustedPublishers)
{
return await Task.Run(() => ValidateAuthenticodeSignature(filePath, trustedPublishers));
@@ -34,8 +31,6 @@ public static async Task ValidateAuthenticodeSignatureAsync(string filePat
/// 文件路径 / File path
/// 信任的发布者列表 / Trusted publishers list
/// 是否验证通过 / Whether validation succeeded
- [RequiresUnreferencedCode("X509Certificate validation may require runtime reflection")]
- [RequiresDynamicCode("X509Certificate validation may require runtime code generation")]
public static bool ValidateAuthenticodeSignature(string filePath, IEnumerable trustedPublishers)
{
if (!File.Exists(filePath))
@@ -118,8 +113,6 @@ public static bool ValidateAuthenticodeSignature(string filePath, IEnumerable
/// 文件路径 / File path
/// 是否已签名 / Whether signed
- [RequiresUnreferencedCode("X509Certificate validation may require runtime reflection")]
- [RequiresDynamicCode("X509Certificate validation may require runtime code generation")]
public static bool IsFileSigned(string filePath)
{
if (!File.Exists(filePath))
From 0a809e5f51d1f38f25f7a36d4779543ac38b2e96 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:40:44 +0000
Subject: [PATCH 05/15] Change from project reference to file linking for
Drivelution
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../GeneralUpdate.Core.csproj | 36 ++++++++++++++++++-
.../Pipeline/DrivelutionMiddleware.cs | 3 --
2 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
index 0a61943a..e101ec7b 100644
--- a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
+++ b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
@@ -24,6 +24,9 @@
true
netstandard2.0;net8.0
+
+ enable
+
@@ -90,8 +93,39 @@
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
index cfcb4fac..240b1d41 100644
--- a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
+++ b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
@@ -1,7 +1,6 @@
#if NET8_0_OR_GREATER
using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -17,8 +16,6 @@ namespace GeneralUpdate.Core.Pipeline;
///
public class DrivelutionMiddleware : IMiddleware
{
- [RequiresUnreferencedCode("Driver update process includes signature validation that may require runtime reflection on some platforms")]
- [RequiresDynamicCode("Driver update process includes signature validation that may require runtime code generation on some platforms")]
public async Task InvokeAsync(PipelineContext context)
{
try
From 2e460ead0b5fb07734afa17caa5d4e4e9d056f60 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:42:11 +0000
Subject: [PATCH 06/15] Update tests to use new DrivelutionLogger interface
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Core/DriverUpdaterFactoryTests.cs | 21 +++++--------------
.../GeneralDrivelutionTests.cs | 17 +++++----------
2 files changed, 10 insertions(+), 28 deletions(-)
diff --git a/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs b/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs
index eecd821c..9581a653 100644
--- a/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs
+++ b/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs
@@ -1,8 +1,7 @@
using GeneralUpdate.Drivelution.Core;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
-using Serilog;
-using Serilog.Core;
+using GeneralUpdate.Drivelution.Abstractions.Events;
namespace DrivelutionTest.Core;
@@ -33,10 +32,7 @@ public void Create_WithoutParameters_ReturnsNonNullInstance()
public void Create_WithCustomLogger_ReturnsInstance()
{
// Arrange
- var logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .WriteTo.Console()
- .CreateLogger();
+ var logger = new DrivelutionLogger();
// Act
var updater = DrivelutionFactory.Create(logger);
@@ -55,8 +51,7 @@ public void Create_WithCustomOptions_ReturnsInstance()
// Arrange
var options = new DrivelutionOptions
{
- LogLevel = "Debug",
- LogFilePath = "./logs/test.log"
+ DefaultBackupPath = "./backups"
};
// Act
@@ -150,10 +145,7 @@ public void CreateValidator_WithCustomLogger_ReturnsInstance()
}
// Arrange
- var logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .WriteTo.Console()
- .CreateLogger();
+ var logger = new DrivelutionLogger();
// Act
var validator = DrivelutionFactory.CreateValidator(logger);
@@ -176,10 +168,7 @@ public void CreateBackup_WithCustomLogger_ReturnsInstance()
}
// Arrange
- var logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .WriteTo.Console()
- .CreateLogger();
+ var logger = new DrivelutionLogger();
// Act
var backup = DrivelutionFactory.CreateBackup(logger);
diff --git a/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs b/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs
index 87973a42..03578631 100644
--- a/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs
+++ b/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs
@@ -1,7 +1,7 @@
using GeneralUpdate.Drivelution;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
-using Serilog;
+using GeneralUpdate.Drivelution.Abstractions.Events;
namespace DrivelutionTest;
@@ -33,8 +33,7 @@ public void Create_WithOptions_ReturnsNonNullInstance()
// Arrange
var options = new DrivelutionOptions
{
- LogLevel = "Information",
- LogFilePath = "./logs/test.log"
+ DefaultBackupPath = "./backups"
};
// Act
@@ -51,10 +50,7 @@ public void Create_WithOptions_ReturnsNonNullInstance()
public void Create_WithCustomLogger_ReturnsNonNullInstance()
{
// Arrange
- var logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .WriteTo.Console()
- .CreateLogger();
+ var logger = new DrivelutionLogger();
// Act
var updater = GeneralDrivelution.Create(logger);
@@ -70,13 +66,10 @@ public void Create_WithCustomLogger_ReturnsNonNullInstance()
public void Create_WithCustomLoggerAndOptions_ReturnsInstance()
{
// Arrange
- var logger = new LoggerConfiguration()
- .MinimumLevel.Debug()
- .WriteTo.Console()
- .CreateLogger();
+ var logger = new DrivelutionLogger();
var options = new DrivelutionOptions
{
- LogLevel = "Debug"
+ DefaultBackupPath = "./backups"
};
// Act
From 9ae89857f48fa43661b954874f38d0268aa45c72 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:46:18 +0000
Subject: [PATCH 07/15] Fix logger calls to use string interpolation instead of
Serilog-style placeholders
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Abstractions/Events/DrivelutionLogger.cs | 13 +++---
.../Abstractions/Events/IDrivelutionLogger.cs | 6 +--
.../Core/DriverUpdaterFactory.cs | 2 +-
.../Implementation/LinuxGeneralDrivelution.cs | 12 ++---
.../Implementation/WindowsDriverBackup.cs | 16 +++----
.../Implementation/WindowsDriverValidator.cs | 11 ++---
.../WindowsGeneralDrivelution.cs | 46 +++++++++----------
7 files changed, 52 insertions(+), 54 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs
index 3835fd51..dac4330a 100644
--- a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/DrivelutionLogger.cs
@@ -9,21 +9,21 @@ public class DrivelutionLogger : IDrivelutionLogger
public event EventHandler? LogMessage;
///
- public void Debug(string message, params object[] args)
+ public void Debug(string message, Exception? exception = null, params object[] args)
{
- RaiseLogEvent(LogLevel.Debug, message, null, args);
+ RaiseLogEvent(LogLevel.Debug, message, exception, args);
}
///
- public void Information(string message, params object[] args)
+ public void Information(string message, Exception? exception = null, params object[] args)
{
- RaiseLogEvent(LogLevel.Information, message, null, args);
+ RaiseLogEvent(LogLevel.Information, message, exception, args);
}
///
- public void Warning(string message, params object[] args)
+ public void Warning(string message, Exception? exception = null, params object[] args)
{
- RaiseLogEvent(LogLevel.Warning, message, null, args);
+ RaiseLogEvent(LogLevel.Warning, message, exception, args);
}
///
@@ -42,6 +42,7 @@ private void RaiseLogEvent(LogLevel level, string message, Exception? exception,
{
try
{
+ // Format message if args provided
var formattedMessage = args.Length > 0 ? string.Format(message, args) : message;
var eventArgs = new LogEventArgs
diff --git a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs
index f2f504a5..34688032 100644
--- a/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Abstractions/Events/IDrivelutionLogger.cs
@@ -14,17 +14,17 @@ public interface IDrivelutionLogger
///
/// Logs a debug message
///
- void Debug(string message, params object[] args);
+ void Debug(string message, Exception? exception = null, params object[] args);
///
/// Logs an information message
///
- void Information(string message, params object[] args);
+ void Information(string message, Exception? exception = null, params object[] args);
///
/// Logs a warning message
///
- void Warning(string message, params object[] args);
+ void Warning(string message, Exception? exception = null, params object[] args);
///
/// Logs an error message
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index 224e3d2f..86b123c5 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -53,7 +53,7 @@ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, Driv
else
{
var osDescription = RuntimeInformation.OSDescription;
- logger.Error("Unsupported platform detected: {Platform}", null, osDescription);
+ logger.Error($"Unsupported platform detected: {osDescription}");
throw new PlatformNotSupportedException(
$"Current platform '{osDescription}' is not supported. " +
"Supported platforms: Windows (8+), Linux (Ubuntu 18.04+, CentOS 7+, Debian 10+)");
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
index 044cc287..7ac91f92 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
@@ -501,9 +501,9 @@ private async Task ParseKernelModuleAsync(string koPath, DriverInfo driverInfo,
driverInfo.Version = "1.0.0";
}
}
- catch (Exception)
+ catch (Exception ex)
{
- _logger.Debug($"Could not get module info for: {koPath}");
+ _logger.Debug($"Could not get module info for: {koPath}", ex);
driverInfo.Version = "1.0.0";
}
}
@@ -540,9 +540,9 @@ private async Task ParseDebPackageAsync(string debPath, DriverInfo driverInfo, C
driverInfo.Version = "1.0.0";
}
}
- catch (Exception)
+ catch (Exception ex)
{
- _logger.Debug($"Could not get package info for: {debPath}");
+ _logger.Debug($"Could not get package info for: {debPath}", ex);
driverInfo.Version = "1.0.0";
}
}
@@ -587,9 +587,9 @@ private async Task ParseRpmPackageAsync(string rpmPath, DriverInfo driverInfo, C
driverInfo.Version = "1.0.0";
}
}
- catch (Exception)
+ catch (Exception ex)
{
- _logger.Debug($"Could not get package info for: {rpmPath}");
+ _logger.Debug($"Could not get package info for: {rpmPath}", ex);
driverInfo.Version = "1.0.0";
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
index c724c073..73209c4f 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
@@ -25,7 +25,7 @@ public async Task BackupAsync(
string backupPath,
CancellationToken cancellationToken = default)
{
- _logger.Information("Backing up driver from {SourcePath} to {BackupPath}", sourcePath, backupPath);
+ _logger.Information($"Backing up driver from {sourcePath} to {backupPath}");
try
{
@@ -39,7 +39,7 @@ public async Task BackupAsync(
if (!string.IsNullOrEmpty(backupDir) && !Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
- _logger.Information("Created backup directory: {BackupDir}", backupDir);
+ _logger.Information($"Created backup directory: {backupDir}");
}
// Add timestamp to backup filename to avoid conflicts
@@ -57,7 +57,7 @@ public async Task BackupAsync(
await sourceStream.CopyToAsync(destinationStream, cancellationToken);
}
- _logger.Information("Driver backup completed successfully: {BackupPath}", backupPathWithTimestamp);
+ _logger.Information($"Driver backup completed successfully: {backupPathWithTimestamp}");
return true;
}
catch (Exception ex)
@@ -73,7 +73,7 @@ public async Task RestoreAsync(
string targetPath,
CancellationToken cancellationToken = default)
{
- _logger.Information("Restoring driver from {BackupPath} to {TargetPath}", backupPath, targetPath);
+ _logger.Information($"Restoring driver from {backupPath} to {targetPath}");
try
{
@@ -87,7 +87,7 @@ public async Task RestoreAsync(
if (!string.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir))
{
Directory.CreateDirectory(targetDir);
- _logger.Information("Created target directory: {TargetDir}", targetDir);
+ _logger.Information($"Created target directory: {targetDir}");
}
// Backup existing target file if it exists
@@ -95,7 +95,7 @@ public async Task RestoreAsync(
{
var tempBackup = $"{targetPath}.old";
File.Move(targetPath, tempBackup, true);
- _logger.Information("Moved existing file to temporary backup: {TempBackup}", tempBackup);
+ _logger.Information($"Moved existing file to temporary backup: {tempBackup}");
}
// Copy backup file to target location
@@ -120,7 +120,7 @@ public async Task DeleteBackupAsync(
string backupPath,
CancellationToken cancellationToken = default)
{
- _logger.Information("Deleting backup: {BackupPath}", backupPath);
+ _logger.Information($"Deleting backup: {backupPath}");
return await Task.Run(() =>
{
@@ -134,7 +134,7 @@ public async Task DeleteBackupAsync(
}
else
{
- _logger.Warning("Backup file not found: {BackupPath}", backupPath);
+ _logger.Warning($"Backup file not found: {backupPath}");
return false;
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
index d37358fc..27501d9e 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
@@ -29,7 +29,7 @@ public async Task ValidateIntegrityAsync(
string hashAlgorithm = "SHA256",
CancellationToken cancellationToken = default)
{
- _logger.Information("Validating file integrity: {FilePath}", filePath);
+ _logger.Information($"Validating file integrity: {filePath}");
try
{
@@ -62,7 +62,7 @@ public async Task ValidateSignatureAsync(
IEnumerable trustedPublishers,
CancellationToken cancellationToken = default)
{
- _logger.Information("Validating driver signature: {FilePath}", filePath);
+ _logger.Information($"Validating driver signature: {filePath}");
try
{
@@ -94,7 +94,7 @@ public async Task ValidateCompatibilityAsync(
DriverInfo driverInfo,
CancellationToken cancellationToken = default)
{
- _logger.Information("Validating driver compatibility for: {DriverName}", driverInfo.Name);
+ _logger.Information($"Validating driver compatibility for: {driverInfo.Name}");
try
{
@@ -108,9 +108,8 @@ public async Task ValidateCompatibilityAsync(
{
_logger.Warning("Driver compatibility validation failed");
var report = CompatibilityChecker.GetCompatibilityReport(driverInfo);
- _logger.Warning("Compatibility report: Current OS={CurrentOS}, Target OS={TargetOS}, " +
- "Current Arch={CurrentArch}, Target Arch={TargetArch}",
- report.CurrentOS, report.TargetOS, report.CurrentArchitecture, report.TargetArchitecture);
+ _logger.Warning($"Compatibility report: Current OS={report.CurrentOS}, Target OS={report.TargetOS}, " +
+ $"Current Arch={report.CurrentArchitecture}, Target Arch={report.TargetArchitecture}");
}
return isCompatible;
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
index b49eb46e..dce0b104 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
@@ -41,8 +41,7 @@ public async Task UpdateAsync(
try
{
- _logger.Information("Starting driver update for: {DriverName} v{Version}",
- driverInfo.Name, driverInfo.Version);
+ _logger.Information($"Starting driver update for: {driverInfo.Name} v{driverInfo.Version}");
result.StepLogs.Add($"[{DateTime.Now:HH:mm:ss}] Starting driver update");
@@ -78,7 +77,7 @@ public async Task UpdateAsync(
if (await BackupAsync(driverInfo, backupPath, cancellationToken))
{
result.BackupPath = backupPath;
- _logger.Information("Backup created at: {BackupPath}", backupPath);
+ _logger.Information($"Backup created at: {backupPath}");
}
}
@@ -161,8 +160,7 @@ public async Task UpdateAsync(
finally
{
result.EndTime = DateTime.UtcNow;
- _logger.Information("Driver update process ended. Duration: {Duration}ms, Success: {Success}",
- result.DurationMs, result.Success);
+ _logger.Information($"Driver update process ended. Duration: {result.DurationMs}ms, Success: {result.Success}");
}
return result;
@@ -171,7 +169,7 @@ public async Task UpdateAsync(
///
public async Task ValidateAsync(DriverInfo driverInfo, CancellationToken cancellationToken = default)
{
- _logger.Information("Validating driver: {DriverName}", driverInfo.Name);
+ _logger.Information($"Validating driver: {driverInfo.Name}");
try
{
@@ -241,7 +239,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information("Rolling back driver from backup: {BackupPath}", backupPath);
+ _logger.Information($"Rolling back driver from backup: {backupPath}");
// Implement rollback logic
// This involves:
@@ -258,11 +256,11 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
var backupFiles = Directory.GetFiles(backupPath, "*.*", SearchOption.AllDirectories);
if (!backupFiles.Any())
{
- _logger.Warning("No backup files found in: {BackupPath}", backupPath);
+ _logger.Warning($"No backup files found in: {backupPath}");
return false;
}
- _logger.Information("Found {Count} backup files", backupFiles.Length);
+ _logger.Information($"Found {backupFiles.Length} backup files");
// For INF-based drivers, try to reinstall the backed up version
var infFiles = backupFiles.Where(f => f.EndsWith(".inf", StringComparison.OrdinalIgnoreCase)).ToArray();
@@ -273,7 +271,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information("Attempting to restore driver from: {InfFile}", infFile);
+ _logger.Information($"Attempting to restore driver from: {infFile}");
await InstallDriverUsingPnPUtilAsync(infFile, cancellationToken);
}
catch (Exception ex)
@@ -301,7 +299,7 @@ private async Task ExecuteDriverInstallationAsync(
UpdateStrategy strategy,
CancellationToken cancellationToken)
{
- _logger.Information("Executing driver installation: {DriverPath}", driverInfo.FilePath);
+ _logger.Information($"Executing driver installation: {driverInfo.FilePath}");
try
{
@@ -328,7 +326,7 @@ private async Task ExecuteDriverInstallationAsync(
///
private async Task InstallDriverUsingPnPUtilAsync(string driverPath, CancellationToken cancellationToken)
{
- _logger.Information("Installing driver using PnPUtil: {DriverPath}", driverPath);
+ _logger.Information($"Installing driver using PnPUtil: {driverPath}");
var startInfo = new ProcessStartInfo
{
@@ -348,7 +346,7 @@ private async Task InstallDriverUsingPnPUtilAsync(string driverPath, Cancellatio
await process.WaitForExitAsync(cancellationToken);
- _logger.Information("PnPUtil output: {Output}", output);
+ _logger.Information($"PnPUtil output: {output}");
if (process.ExitCode != 0)
{
@@ -366,7 +364,7 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
{
try
{
- _logger.Information("Verifying driver installation for: {DriverPath}", driverInfo.FilePath);
+ _logger.Information($"Verifying driver installation for: {driverInfo.FilePath}");
// Use PnPUtil to enumerate installed drivers and check if our driver is present
var processStartInfo = new ProcessStartInfo
@@ -394,7 +392,7 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
bool isInstalled = output.Contains(driverFileName, StringComparison.OrdinalIgnoreCase) ||
output.Contains(Path.GetFileNameWithoutExtension(driverInfo.FilePath), StringComparison.OrdinalIgnoreCase);
- _logger.Information("Driver verification result: {IsInstalled}", isInstalled);
+ _logger.Information($"Driver verification result: {isInstalled}");
return isInstalled;
}
catch (Exception ex)
@@ -467,11 +465,11 @@ public async Task> GetDriversFromDirectoryAsync(
try
{
- _logger.Information("Reading driver information from directory: {DirectoryPath}", directoryPath);
+ _logger.Information($"Reading driver information from directory: {directoryPath}");
if (!Directory.Exists(directoryPath))
{
- _logger.Warning("Directory not found: {DirectoryPath}", directoryPath);
+ _logger.Warning($"Directory not found: {directoryPath}");
return driverInfoList;
}
@@ -479,7 +477,7 @@ public async Task> GetDriversFromDirectoryAsync(
var pattern = searchPattern ?? "*.inf";
var driverFiles = Directory.GetFiles(directoryPath, pattern, SearchOption.AllDirectories);
- _logger.Information("Found {Count} driver files matching pattern: {Pattern}", driverFiles.Length, pattern);
+ _logger.Information($"Found {driverFiles.Length} driver files matching pattern: {pattern}");
foreach (var filePath in driverFiles)
{
@@ -492,7 +490,7 @@ public async Task> GetDriversFromDirectoryAsync(
if (driverInfo != null)
{
driverInfoList.Add(driverInfo);
- _logger.Information("Parsed driver: {DriverName} v{Version}", driverInfo.Name, driverInfo.Version);
+ _logger.Information($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
catch (Exception ex)
@@ -501,7 +499,7 @@ public async Task> GetDriversFromDirectoryAsync(
}
}
- _logger.Information("Successfully loaded {Count} driver(s) from directory", driverInfoList.Count);
+ _logger.Information($"Successfully loaded {driverInfoList.Count} driver(s) from directory");
}
catch (Exception ex)
{
@@ -573,9 +571,9 @@ public async Task> GetDriversFromDirectoryAsync(
}
}
}
- catch
+ catch (Exception ex)
{
- _logger.Debug($"Could not get signature for file: {filePath}");
+ _logger.Debug($"Could not get signature for file: {filePath}", ex);
}
return driverInfo;
@@ -645,9 +643,9 @@ private async Task ParseInfFileAsync(string infPath, DriverInfo driverInfo, Canc
driverInfo.Version = "1.0.0";
}
}
- catch
+ catch (Exception ex)
{
- _logger.Debug($"Could not parse INF file: {infPath}");
+ _logger.Debug($"Could not parse INF file: {infPath}", ex);
}
}
}
From 748c3d47bedb08b083469caeb4f587539d2bc158 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 15:57:35 +0000
Subject: [PATCH 08/15] Upgrade GeneralUpdate.Drivelution to .NET 10 instead of
.NET Standard 2.0
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
src/c#/DrivelutionTest/DrivelutionTest.csproj | 2 +-
src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj | 8 ++++----
.../GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs | 2 +-
src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs | 2 +-
src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs | 2 +-
.../GeneralUpdate.Drivelution.csproj | 2 +-
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/c#/DrivelutionTest/DrivelutionTest.csproj b/src/c#/DrivelutionTest/DrivelutionTest.csproj
index 7c3fec32..c869734a 100644
--- a/src/c#/DrivelutionTest/DrivelutionTest.csproj
+++ b/src/c#/DrivelutionTest/DrivelutionTest.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
enable
enable
diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
index e101ec7b..612e68e2 100644
--- a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
+++ b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
@@ -22,9 +22,9 @@
public
upgrade,update
true
- netstandard2.0;net8.0
+ netstandard2.0;net10.0
-
+
enable
@@ -93,8 +93,8 @@
-
-
+
+
diff --git a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
index 240b1d41..93037dcb 100644
--- a/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
+++ b/src/c#/GeneralUpdate.Core/Pipeline/DrivelutionMiddleware.cs
@@ -1,4 +1,4 @@
-#if NET8_0_OR_GREATER
+#if NET10_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.IO;
diff --git a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
index 751453e1..d326d8de 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/LinuxStrategy.cs
@@ -33,7 +33,7 @@ protected override PipelineBuilder BuildPipeline(PipelineContext context)
.UseMiddlewareIf(_configinfo.PatchEnabled)
.UseMiddleware()
.UseMiddleware();
-#if NET8_0_OR_GREATER
+#if NET10_0_OR_GREATER
builder.UseMiddlewareIf(_configinfo.DriveEnabled == true);
#endif
return builder;
diff --git a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
index 0169a5bf..ab839f8a 100644
--- a/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
+++ b/src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs
@@ -35,7 +35,7 @@ protected override PipelineBuilder BuildPipeline(PipelineContext context)
.UseMiddlewareIf(_configinfo.PatchEnabled)
.UseMiddleware()
.UseMiddleware();
-#if NET8_0_OR_GREATER
+#if NET10_0_OR_GREATER
builder.UseMiddlewareIf(_configinfo.DriveEnabled == true);
#endif
return builder;
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
index 3b918ae9..a24ba0f4 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
enable
enable
From f1d313c3e033d5035bf26adc7ef9fbd404e52317 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 16:33:25 +0000
Subject: [PATCH 09/15] Replace _logger with GeneralTracer in Drivelution
implementation files
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Core/DriverUpdaterFactory.cs | 22 ++---
.../GeneralUpdate.Drivelution.csproj | 4 +
.../Linux/Implementation/LinuxDriverBackup.cs | 17 ++--
.../Implementation/LinuxDriverValidator.cs | 9 +-
.../Implementation/LinuxGeneralDrivelution.cs | 82 ++++++++---------
.../Implementation/WindowsDriverBackup.cs | 33 +++----
.../Implementation/WindowsDriverValidator.cs | 33 +++----
.../WindowsGeneralDrivelution.cs | 92 +++++++++----------
8 files changed, 140 insertions(+), 152 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index 86b123c5..120dc190 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -24,23 +24,23 @@ public static class DrivelutionFactory
/// 当前平台不支持时抛出 / Thrown when current platform is not supported
public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
{
- // Use default logger if not provided
+ // Use default logger if not provided (kept for backward compatibility but not used internally anymore)
logger ??= CreateDefaultLogger(options);
// Detect platform and create appropriate implementation
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
logger.Information("Detected Windows platform, creating WindowsGeneralDrivelution");
- var validator = new WindowsDriverValidator(logger);
- var backup = new WindowsDriverBackup(logger);
- return new WindowsGeneralDrivelution(logger, validator, backup);
+ var validator = new WindowsDriverValidator();
+ var backup = new WindowsDriverBackup();
+ return new WindowsGeneralDrivelution(validator, backup);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
logger.Information("Detected Linux platform, creating LinuxGeneralDrivelution");
- var validator = new LinuxDriverValidator(logger);
- var backup = new LinuxDriverBackup(logger);
- return new LinuxGeneralDrivelution(logger, validator, backup);
+ var validator = new LinuxDriverValidator();
+ var backup = new LinuxDriverBackup();
+ return new LinuxGeneralDrivelution(validator, backup);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
@@ -72,11 +72,11 @@ public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- return new WindowsDriverValidator(logger);
+ return new WindowsDriverValidator();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- return new LinuxDriverValidator(logger);
+ return new LinuxDriverValidator();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
@@ -100,11 +100,11 @@ public static IDriverBackup CreateBackup(IDrivelutionLogger? logger = null)
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- return new WindowsDriverBackup(logger);
+ return new WindowsDriverBackup();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- return new LinuxDriverBackup(logger);
+ return new LinuxDriverBackup();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
index a24ba0f4..85d060dd 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
@@ -12,4 +12,8 @@
full
+
+
+
+
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs
index 4ec1073a..0fda85e8 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverBackup.cs
@@ -1,6 +1,6 @@
using System.Runtime.Versioning;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
namespace GeneralUpdate.Drivelution.Linux.Implementation;
@@ -12,11 +12,8 @@ namespace GeneralUpdate.Drivelution.Linux.Implementation;
[SupportedOSPlatform("linux")]
public class LinuxDriverBackup : IDriverBackup
{
- private readonly IDrivelutionLogger _logger;
-
- public LinuxDriverBackup(IDrivelutionLogger logger)
+ public LinuxDriverBackup()
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
///
@@ -51,12 +48,12 @@ public async Task BackupAsync(
await sourceStream.CopyToAsync(destinationStream, cancellationToken);
}
- _logger.Information($"Backup completed: {backupPathWithTimestamp}");
+ GeneralTracer.Info($"Backup completed: {backupPathWithTimestamp}");
return true;
}
catch (Exception ex)
{
- _logger.Error("Failed to backup driver", ex);
+ GeneralTracer.Error("Failed to backup driver", ex);
throw new DriverBackupException($"Failed to backup driver: {ex.Message}", ex);
}
}
@@ -91,12 +88,12 @@ public async Task RestoreAsync(
await sourceStream.CopyToAsync(destinationStream, cancellationToken);
}
- _logger.Information("Restore completed");
+ GeneralTracer.Info("Restore completed");
return true;
}
catch (Exception ex)
{
- _logger.Error("Failed to restore driver", ex);
+ GeneralTracer.Error("Failed to restore driver", ex);
throw new DriverRollbackException($"Failed to restore driver: {ex.Message}", ex);
}
}
@@ -119,7 +116,7 @@ public async Task DeleteBackupAsync(
}
catch (Exception ex)
{
- _logger.Error("Failed to delete backup", ex);
+ GeneralTracer.Error("Failed to delete backup", ex);
return false;
}
}, cancellationToken);
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
index ad685525..aed8cc49 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxDriverValidator.cs
@@ -1,6 +1,6 @@
using System.Runtime.Versioning;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
using GeneralUpdate.Drivelution.Linux.Helpers;
@@ -14,11 +14,8 @@ namespace GeneralUpdate.Drivelution.Linux.Implementation;
[SupportedOSPlatform("linux")]
public class LinuxDriverValidator : IDriverValidator
{
- private readonly IDrivelutionLogger _logger;
-
- public LinuxDriverValidator(IDrivelutionLogger logger)
+ public LinuxDriverValidator()
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
///
@@ -49,7 +46,7 @@ public async Task ValidateSignatureAsync(
return await LinuxSignatureHelper.ValidateGpgSignatureAsync(filePath, signaturePath, trustedPublishers);
}
- _logger.Warning($"No signature file found for: {filePath}");
+ GeneralTracer.Warn($"No signature file found for: {filePath}");
return !trustedPublishers.Any(); // If no trusted publishers specified, accept unsigned
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
index 7ac91f92..960b28c7 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
@@ -1,6 +1,6 @@
using System.Runtime.Versioning;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
@@ -15,13 +15,11 @@ namespace GeneralUpdate.Drivelution.Linux.Implementation;
[SupportedOSPlatform("linux")]
public class LinuxGeneralDrivelution : IGeneralDrivelution
{
- private readonly IDrivelutionLogger _logger;
private readonly IDriverValidator _validator;
private readonly IDriverBackup _backup;
- public LinuxGeneralDrivelution(IDrivelutionLogger logger, IDriverValidator validator, IDriverBackup backup)
+ public LinuxGeneralDrivelution(IDriverValidator validator, IDriverBackup backup)
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
_validator = validator ?? throw new ArgumentNullException(nameof(validator));
_backup = backup ?? throw new ArgumentNullException(nameof(backup));
}
@@ -40,7 +38,7 @@ public async Task UpdateAsync(
try
{
- _logger.Information($"Starting driver update for: {driverInfo.Name} v{driverInfo.Version}");
+ GeneralTracer.Info($"Starting driver update for: {driverInfo.Name} v{driverInfo.Version}");
// Permission check
await LinuxPermissionHelper.EnsureSudoAsync();
@@ -73,7 +71,7 @@ public async Task UpdateAsync(
}
catch (Exception ex)
{
- _logger.Error("Driver update failed", ex);
+ GeneralTracer.Error("Driver update failed", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = new ErrorInfo
@@ -127,11 +125,11 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information($"Rolling back driver from backup: {backupPath}");
+ GeneralTracer.Info($"Rolling back driver from backup: {backupPath}");
if (!Directory.Exists(backupPath))
{
- _logger.Error($"Backup directory not found: {backupPath}");
+ GeneralTracer.Error($"Backup directory not found: {backupPath}");
return false;
}
@@ -140,7 +138,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
if (!koFiles.Any())
{
- _logger.Warning($"No kernel module backups found in: {backupPath}");
+ GeneralTracer.Warn($"No kernel module backups found in: {backupPath}");
return false;
}
@@ -148,7 +146,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information($"Attempting to restore kernel module: {koFile}");
+ GeneralTracer.Info($"Attempting to restore kernel module: {koFile}");
// Copy back to /lib/modules or appropriate location
var moduleName = Path.GetFileNameWithoutExtension(koFile);
@@ -157,11 +155,11 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
await ExecuteCommandAsync("modprobe", $"-r {moduleName}", cancellationToken);
// Try to reload the backed-up module (if system supports it)
- _logger.Information($"Restored module: {moduleName}");
+ GeneralTracer.Info($"Restored module: {moduleName}");
}
catch (Exception ex)
{
- _logger.Warning($"Failed to restore module: {koFile}", ex);
+ GeneralTracer.Error($"Failed to restore module: {koFile}", ex);
}
}
@@ -169,14 +167,14 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
}
catch (Exception ex)
{
- _logger.Error("Failed to rollback driver", ex);
+ GeneralTracer.Error("Failed to rollback driver", ex);
return false;
}
}
private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, CancellationToken cancellationToken)
{
- _logger.Information($"Installing Linux driver: {driverInfo.FilePath}");
+ GeneralTracer.Info($"Installing Linux driver: {driverInfo.FilePath}");
var filePath = driverInfo.FilePath;
var extension = Path.GetExtension(filePath).ToLowerInvariant();
@@ -201,16 +199,16 @@ private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, Cancell
}
else
{
- _logger.Warning($"Unknown driver format: {extension}. Attempting generic installation.");
+ GeneralTracer.Warn($"Unknown driver format: {extension}. Attempting generic installation.");
// Try to detect and install generically
await InstallKernelModuleAsync(filePath, cancellationToken);
}
- _logger.Information("Driver installation completed successfully");
+ GeneralTracer.Info("Driver installation completed successfully");
}
catch (Exception ex)
{
- _logger.Error("Failed to install Linux driver", ex);
+ GeneralTracer.Error("Failed to install Linux driver", ex);
throw new DriverInstallationException(
$"Failed to install Linux driver: {ex.Message}", ex);
}
@@ -218,39 +216,39 @@ private async Task ExecuteDriverInstallationAsync(DriverInfo driverInfo, Cancell
private async Task InstallKernelModuleAsync(string modulePath, CancellationToken cancellationToken)
{
- _logger.Information($"Installing kernel module: {modulePath}");
+ GeneralTracer.Info($"Installing kernel module: {modulePath}");
var moduleName = Path.GetFileNameWithoutExtension(modulePath);
try
{
// Try to use insmod (direct installation)
- _logger.Information("Attempting to load module using insmod");
+ GeneralTracer.Info("Attempting to load module using insmod");
await ExecuteCommandAsync("insmod", modulePath, cancellationToken);
- _logger.Information("Module loaded successfully using insmod");
+ GeneralTracer.Info("Module loaded successfully using insmod");
}
catch
{
try
{
// Fallback to modprobe if insmod fails
- _logger.Information("Attempting to load module using modprobe");
+ GeneralTracer.Info("Attempting to load module using modprobe");
// Copy to modules directory first (may require permissions)
var kernelVersion = await GetKernelVersionAsync(cancellationToken);
var targetDir = $"/lib/modules/{kernelVersion}/extra";
- _logger.Information($"Target module directory: {targetDir}");
+ GeneralTracer.Info($"Target module directory: {targetDir}");
// Note: This would typically require root permissions
// In a real scenario, you'd use sudo or elevated permissions
await ExecuteCommandAsync("modprobe", moduleName, cancellationToken);
- _logger.Information("Module loaded successfully using modprobe");
+ GeneralTracer.Info("Module loaded successfully using modprobe");
}
catch (Exception ex)
{
- _logger.Error("Failed to load kernel module", ex);
+ GeneralTracer.Error("Failed to load kernel module", ex);
throw;
}
}
@@ -258,24 +256,24 @@ private async Task InstallKernelModuleAsync(string modulePath, CancellationToken
private async Task InstallDebPackageAsync(string packagePath, CancellationToken cancellationToken)
{
- _logger.Information($"Installing Debian package: {packagePath}");
+ GeneralTracer.Info($"Installing Debian package: {packagePath}");
try
{
// Use dpkg to install the package
await ExecuteCommandAsync("dpkg", $"-i {packagePath}", cancellationToken);
- _logger.Information("Debian package installed successfully");
+ GeneralTracer.Info("Debian package installed successfully");
}
catch (Exception ex)
{
- _logger.Error("Failed to install Debian package", ex);
+ GeneralTracer.Error("Failed to install Debian package", ex);
throw;
}
}
private async Task InstallRpmPackageAsync(string packagePath, CancellationToken cancellationToken)
{
- _logger.Information($"Installing RPM package: {packagePath}");
+ GeneralTracer.Info($"Installing RPM package: {packagePath}");
try
{
@@ -290,11 +288,11 @@ private async Task InstallRpmPackageAsync(string packagePath, CancellationToken
await ExecuteCommandAsync("dnf", $"install -y {packagePath}", cancellationToken);
}
- _logger.Information("RPM package installed successfully");
+ GeneralTracer.Info("RPM package installed successfully");
}
catch (Exception ex)
{
- _logger.Error("Failed to install RPM package", ex);
+ GeneralTracer.Error("Failed to install RPM package", ex);
throw;
}
}
@@ -337,7 +335,7 @@ private async Task ExecuteCommandAsync(string command, string arguments,
if (process.ExitCode != 0)
{
- _logger.Warning($"Command {command} {arguments} exited with code {process.ExitCode}. Error: {error}");
+ GeneralTracer.Warn($"Command {command} {arguments} exited with code {process.ExitCode}. Error: {error}");
throw new InvalidOperationException($"Command failed with exit code {process.ExitCode}: {error}");
}
@@ -365,11 +363,11 @@ public async Task> GetDriversFromDirectoryAsync(
try
{
- _logger.Information($"Reading driver information from directory: {directoryPath}");
+ GeneralTracer.Info($"Reading driver information from directory: {directoryPath}");
if (!Directory.Exists(directoryPath))
{
- _logger.Warning($"Directory not found: {directoryPath}");
+ GeneralTracer.Warn($"Directory not found: {directoryPath}");
return driverInfoList;
}
@@ -385,7 +383,7 @@ public async Task> GetDriversFromDirectoryAsync(
driverFiles = driverFiles.Concat(debFiles).Concat(rpmFiles).ToArray();
}
- _logger.Information($"Found {driverFiles.Length} driver files matching pattern: {pattern}");
+ GeneralTracer.Info($"Found {driverFiles.Length} driver files matching pattern: {pattern}");
foreach (var filePath in driverFiles)
{
@@ -398,20 +396,20 @@ public async Task> GetDriversFromDirectoryAsync(
if (driverInfo != null)
{
driverInfoList.Add(driverInfo);
- _logger.Information($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
+ GeneralTracer.Info($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
catch (Exception ex)
{
- _logger.Warning($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
}
}
- _logger.Information($"Successfully loaded {driverInfoList.Count} driver(s) from directory");
+ GeneralTracer.Info($"Successfully loaded {driverInfoList.Count} driver(s) from directory");
}
catch (Exception ex)
{
- _logger.Error($"Error reading drivers from directory: {directoryPath}", ex);
+ GeneralTracer.Error($"Error reading drivers from directory: {directoryPath}", ex);
}
return driverInfoList;
@@ -458,7 +456,7 @@ public async Task> GetDriversFromDirectoryAsync(
}
catch (Exception ex)
{
- _logger.Warning($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
return null;
}
}
@@ -503,7 +501,7 @@ private async Task ParseKernelModuleAsync(string koPath, DriverInfo driverInfo,
}
catch (Exception ex)
{
- _logger.Debug($"Could not get module info for: {koPath}", ex);
+ GeneralTracer.Debug($"Could not get module info for: {koPath} - {ex.Message}");
driverInfo.Version = "1.0.0";
}
}
@@ -542,7 +540,7 @@ private async Task ParseDebPackageAsync(string debPath, DriverInfo driverInfo, C
}
catch (Exception ex)
{
- _logger.Debug($"Could not get package info for: {debPath}", ex);
+ GeneralTracer.Debug($"Could not get package info for: {debPath} - {ex.Message}");
driverInfo.Version = "1.0.0";
}
}
@@ -589,7 +587,7 @@ private async Task ParseRpmPackageAsync(string rpmPath, DriverInfo driverInfo, C
}
catch (Exception ex)
{
- _logger.Debug($"Could not get package info for: {rpmPath}", ex);
+ GeneralTracer.Debug($"Could not get package info for: {rpmPath} - {ex.Message}");
driverInfo.Version = "1.0.0";
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
index 73209c4f..40f88f42 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverBackup.cs
@@ -1,6 +1,6 @@
using System.Runtime.Versioning;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
namespace GeneralUpdate.Drivelution.Windows.Implementation;
@@ -12,11 +12,8 @@ namespace GeneralUpdate.Drivelution.Windows.Implementation;
[SupportedOSPlatform("windows")]
public class WindowsDriverBackup : IDriverBackup
{
- private readonly IDrivelutionLogger _logger;
-
- public WindowsDriverBackup(IDrivelutionLogger logger)
+ public WindowsDriverBackup()
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
///
@@ -25,7 +22,7 @@ public async Task BackupAsync(
string backupPath,
CancellationToken cancellationToken = default)
{
- _logger.Information($"Backing up driver from {sourcePath} to {backupPath}");
+ GeneralTracer.Info($"Backing up driver from {sourcePath} to {backupPath}");
try
{
@@ -39,7 +36,7 @@ public async Task BackupAsync(
if (!string.IsNullOrEmpty(backupDir) && !Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
- _logger.Information($"Created backup directory: {backupDir}");
+ GeneralTracer.Info($"Created backup directory: {backupDir}");
}
// Add timestamp to backup filename to avoid conflicts
@@ -57,12 +54,12 @@ public async Task BackupAsync(
await sourceStream.CopyToAsync(destinationStream, cancellationToken);
}
- _logger.Information($"Driver backup completed successfully: {backupPathWithTimestamp}");
+ GeneralTracer.Info($"Driver backup completed successfully: {backupPathWithTimestamp}");
return true;
}
catch (Exception ex)
{
- _logger.Error("Failed to backup driver", ex);
+ GeneralTracer.Error("Failed to backup driver", ex);
throw new DriverBackupException($"Failed to backup driver: {ex.Message}", ex);
}
}
@@ -73,7 +70,7 @@ public async Task RestoreAsync(
string targetPath,
CancellationToken cancellationToken = default)
{
- _logger.Information($"Restoring driver from {backupPath} to {targetPath}");
+ GeneralTracer.Info($"Restoring driver from {backupPath} to {targetPath}");
try
{
@@ -87,7 +84,7 @@ public async Task RestoreAsync(
if (!string.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir))
{
Directory.CreateDirectory(targetDir);
- _logger.Information($"Created target directory: {targetDir}");
+ GeneralTracer.Info($"Created target directory: {targetDir}");
}
// Backup existing target file if it exists
@@ -95,7 +92,7 @@ public async Task RestoreAsync(
{
var tempBackup = $"{targetPath}.old";
File.Move(targetPath, tempBackup, true);
- _logger.Information($"Moved existing file to temporary backup: {tempBackup}");
+ GeneralTracer.Info($"Moved existing file to temporary backup: {tempBackup}");
}
// Copy backup file to target location
@@ -105,12 +102,12 @@ public async Task RestoreAsync(
await sourceStream.CopyToAsync(destinationStream, cancellationToken);
}
- _logger.Information("Driver restore completed successfully");
+ GeneralTracer.Info("Driver restore completed successfully");
return true;
}
catch (Exception ex)
{
- _logger.Error("Failed to restore driver", ex);
+ GeneralTracer.Error("Failed to restore driver", ex);
throw new DriverRollbackException($"Failed to restore driver: {ex.Message}", ex);
}
}
@@ -120,7 +117,7 @@ public async Task DeleteBackupAsync(
string backupPath,
CancellationToken cancellationToken = default)
{
- _logger.Information($"Deleting backup: {backupPath}");
+ GeneralTracer.Info($"Deleting backup: {backupPath}");
return await Task.Run(() =>
{
@@ -129,18 +126,18 @@ public async Task DeleteBackupAsync(
if (File.Exists(backupPath))
{
File.Delete(backupPath);
- _logger.Information("Backup deleted successfully");
+ GeneralTracer.Info("Backup deleted successfully");
return true;
}
else
{
- _logger.Warning($"Backup file not found: {backupPath}");
+ GeneralTracer.Warn($"Backup file not found: {backupPath}");
return false;
}
}
catch (Exception ex)
{
- _logger.Error("Failed to delete backup", ex);
+ GeneralTracer.Error("Failed to delete backup", ex);
return false;
}
}, cancellationToken);
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
index 27501d9e..d3cff48c 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsDriverValidator.cs
@@ -1,6 +1,6 @@
using System.Runtime.Versioning;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
@@ -15,11 +15,8 @@ namespace GeneralUpdate.Drivelution.Windows.Implementation;
[SupportedOSPlatform("windows")]
public class WindowsDriverValidator : IDriverValidator
{
- private readonly IDrivelutionLogger _logger;
-
- public WindowsDriverValidator(IDrivelutionLogger logger)
+ public WindowsDriverValidator()
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
///
@@ -29,7 +26,7 @@ public async Task ValidateIntegrityAsync(
string hashAlgorithm = "SHA256",
CancellationToken cancellationToken = default)
{
- _logger.Information($"Validating file integrity: {filePath}");
+ GeneralTracer.Info($"Validating file integrity: {filePath}");
try
{
@@ -37,18 +34,18 @@ public async Task ValidateIntegrityAsync(
if (isValid)
{
- _logger.Information("File integrity validation succeeded");
+ GeneralTracer.Info("File integrity validation succeeded");
}
else
{
- _logger.Warning("File integrity validation failed - hash mismatch");
+ GeneralTracer.Warn("File integrity validation failed - hash mismatch");
}
return isValid;
}
catch (Exception ex)
{
- _logger.Error("File integrity validation failed with exception", ex);
+ GeneralTracer.Error("File integrity validation failed with exception", ex);
throw new DriverValidationException(
$"Failed to validate file integrity: {ex.Message}",
"Integrity",
@@ -62,7 +59,7 @@ public async Task ValidateSignatureAsync(
IEnumerable trustedPublishers,
CancellationToken cancellationToken = default)
{
- _logger.Information($"Validating driver signature: {filePath}");
+ GeneralTracer.Info($"Validating driver signature: {filePath}");
try
{
@@ -70,18 +67,18 @@ public async Task ValidateSignatureAsync(
if (isValid)
{
- _logger.Information("Driver signature validation succeeded");
+ GeneralTracer.Info("Driver signature validation succeeded");
}
else
{
- _logger.Warning("Driver signature validation failed");
+ GeneralTracer.Warn("Driver signature validation failed");
}
return isValid;
}
catch (Exception ex)
{
- _logger.Error("Driver signature validation failed with exception", ex);
+ GeneralTracer.Error("Driver signature validation failed with exception", ex);
throw new DriverValidationException(
$"Failed to validate driver signature: {ex.Message}",
"Signature",
@@ -94,7 +91,7 @@ public async Task ValidateCompatibilityAsync(
DriverInfo driverInfo,
CancellationToken cancellationToken = default)
{
- _logger.Information($"Validating driver compatibility for: {driverInfo.Name}");
+ GeneralTracer.Info($"Validating driver compatibility for: {driverInfo.Name}");
try
{
@@ -102,13 +99,13 @@ public async Task ValidateCompatibilityAsync(
if (isCompatible)
{
- _logger.Information("Driver compatibility validation succeeded");
+ GeneralTracer.Info("Driver compatibility validation succeeded");
}
else
{
- _logger.Warning("Driver compatibility validation failed");
+ GeneralTracer.Warn("Driver compatibility validation failed");
var report = CompatibilityChecker.GetCompatibilityReport(driverInfo);
- _logger.Warning($"Compatibility report: Current OS={report.CurrentOS}, Target OS={report.TargetOS}, " +
+ GeneralTracer.Warn($"Compatibility report: Current OS={report.CurrentOS}, Target OS={report.TargetOS}, " +
$"Current Arch={report.CurrentArchitecture}, Target Arch={report.TargetArchitecture}");
}
@@ -116,7 +113,7 @@ public async Task ValidateCompatibilityAsync(
}
catch (Exception ex)
{
- _logger.Error("Driver compatibility validation failed with exception", ex);
+ GeneralTracer.Error("Driver compatibility validation failed with exception", ex);
throw new DriverValidationException(
$"Failed to validate driver compatibility: {ex.Message}",
"Compatibility",
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
index dce0b104..7ea82218 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
@@ -1,7 +1,7 @@
using System.Diagnostics;
using System.Runtime.Versioning;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Exceptions;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
@@ -16,13 +16,11 @@ namespace GeneralUpdate.Drivelution.Windows.Implementation;
[SupportedOSPlatform("windows")]
public class WindowsGeneralDrivelution : IGeneralDrivelution
{
- private readonly IDrivelutionLogger _logger;
private readonly IDriverValidator _validator;
private readonly IDriverBackup _backup;
- public WindowsGeneralDrivelution(IDrivelutionLogger logger, IDriverValidator validator, IDriverBackup backup)
+ public WindowsGeneralDrivelution(IDriverValidator validator, IDriverBackup backup)
{
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
_validator = validator ?? throw new ArgumentNullException(nameof(validator));
_backup = backup ?? throw new ArgumentNullException(nameof(backup));
}
@@ -41,12 +39,12 @@ public async Task UpdateAsync(
try
{
- _logger.Information($"Starting driver update for: {driverInfo.Name} v{driverInfo.Version}");
+ GeneralTracer.Info($"Starting driver update for: {driverInfo.Name} v{driverInfo.Version}");
result.StepLogs.Add($"[{DateTime.Now:HH:mm:ss}] Starting driver update");
// Step 1: Permission check
- _logger.Information("Checking permissions...");
+ GeneralTracer.Info("Checking permissions...");
result.StepLogs.Add($"[{DateTime.Now:HH:mm:ss}] Checking permissions");
if (!WindowsPermissionHelper.IsAdministrator())
@@ -77,7 +75,7 @@ public async Task UpdateAsync(
if (await BackupAsync(driverInfo, backupPath, cancellationToken))
{
result.BackupPath = backupPath;
- _logger.Information($"Backup created at: {backupPath}");
+ GeneralTracer.Info($"Backup created at: {backupPath}");
}
}
@@ -94,16 +92,16 @@ public async Task UpdateAsync(
bool verified = await VerifyDriverInstallationAsync(driverInfo, cancellationToken);
if (!verified)
{
- _logger.Warning("Driver installation verification failed");
+ GeneralTracer.Warn("Driver installation verification failed");
result.StepLogs.Add($"[{DateTime.Now:HH:mm:ss}] WARNING: Installation verification failed");
}
- _logger.Information("Driver installation verification completed");
+ GeneralTracer.Info("Driver installation verification completed");
// Step 6: Handle restart if needed
if (RestartHelper.IsRestartRequired(strategy.RestartMode))
{
result.StepLogs.Add($"[{DateTime.Now:HH:mm:ss}] System restart is required");
- _logger.Information("System restart is required for driver update");
+ GeneralTracer.Info("System restart is required for driver update");
}
result.Success = true;
@@ -111,11 +109,11 @@ public async Task UpdateAsync(
result.Message = "Driver update completed successfully";
result.StepLogs.Add($"[{DateTime.Now:HH:mm:ss}] Update completed successfully");
- _logger.Information("Driver update completed successfully");
+ GeneralTracer.Info("Driver update completed successfully");
}
catch (DriverPermissionException ex)
{
- _logger.Error("Permission denied during driver update", ex);
+ GeneralTracer.Error("Permission denied during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.PermissionDenied, false);
@@ -123,7 +121,7 @@ public async Task UpdateAsync(
}
catch (DriverValidationException ex)
{
- _logger.Error("Validation failed during driver update", ex);
+ GeneralTracer.Error("Validation failed during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.HashValidationFailed, false);
@@ -131,7 +129,7 @@ public async Task UpdateAsync(
}
catch (DriverInstallationException ex)
{
- _logger.Error("Installation failed during driver update", ex);
+ GeneralTracer.Error("Installation failed during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.InstallationFailed, ex.CanRetry);
@@ -151,7 +149,7 @@ public async Task UpdateAsync(
}
catch (Exception ex)
{
- _logger.Error("Unexpected error during driver update", ex);
+ GeneralTracer.Error("Unexpected error during driver update", ex);
result.Success = false;
result.Status = UpdateStatus.Failed;
result.Error = CreateErrorInfo(ex, ErrorType.Unknown, false);
@@ -160,7 +158,7 @@ public async Task UpdateAsync(
finally
{
result.EndTime = DateTime.UtcNow;
- _logger.Information($"Driver update process ended. Duration: {result.DurationMs}ms, Success: {result.Success}");
+ GeneralTracer.Info($"Driver update process ended. Duration: {result.DurationMs}ms, Success: {result.Success}");
}
return result;
@@ -169,14 +167,14 @@ public async Task UpdateAsync(
///
public async Task ValidateAsync(DriverInfo driverInfo, CancellationToken cancellationToken = default)
{
- _logger.Information($"Validating driver: {driverInfo.Name}");
+ GeneralTracer.Info($"Validating driver: {driverInfo.Name}");
try
{
// Validate file exists
if (!File.Exists(driverInfo.FilePath))
{
- _logger.Error($"Driver file not found: {driverInfo.FilePath}");
+ GeneralTracer.Error($"Driver file not found: {driverInfo.FilePath}");
return false;
}
@@ -215,7 +213,7 @@ public async Task ValidateAsync(DriverInfo driverInfo, CancellationToken c
}
catch (Exception ex)
{
- _logger.Error("Driver validation failed", ex);
+ GeneralTracer.Error("Driver validation failed", ex);
return false;
}
}
@@ -229,7 +227,7 @@ public async Task BackupAsync(DriverInfo driverInfo, string backupPath, Ca
}
catch (Exception ex)
{
- _logger.Error("Failed to backup driver", ex);
+ GeneralTracer.Error("Failed to backup driver", ex);
return false;
}
}
@@ -239,7 +237,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information($"Rolling back driver from backup: {backupPath}");
+ GeneralTracer.Info($"Rolling back driver from backup: {backupPath}");
// Implement rollback logic
// This involves:
@@ -248,7 +246,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
if (!Directory.Exists(backupPath))
{
- _logger.Error($"Backup directory not found: {backupPath}");
+ GeneralTracer.Error($"Backup directory not found: {backupPath}");
return false;
}
@@ -256,11 +254,11 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
var backupFiles = Directory.GetFiles(backupPath, "*.*", SearchOption.AllDirectories);
if (!backupFiles.Any())
{
- _logger.Warning($"No backup files found in: {backupPath}");
+ GeneralTracer.Warn($"No backup files found in: {backupPath}");
return false;
}
- _logger.Information($"Found {backupFiles.Length} backup files");
+ GeneralTracer.Info($"Found {backupFiles.Length} backup files");
// For INF-based drivers, try to reinstall the backed up version
var infFiles = backupFiles.Where(f => f.EndsWith(".inf", StringComparison.OrdinalIgnoreCase)).ToArray();
@@ -271,12 +269,12 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
{
try
{
- _logger.Information($"Attempting to restore driver from: {infFile}");
+ GeneralTracer.Info($"Attempting to restore driver from: {infFile}");
await InstallDriverUsingPnPUtilAsync(infFile, cancellationToken);
}
catch (Exception ex)
{
- _logger.Warning($"Failed to restore driver from: {infFile}", ex);
+ GeneralTracer.Error($"Failed to restore driver from: {infFile}", ex);
}
}
}
@@ -285,7 +283,7 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
}
catch (Exception ex)
{
- _logger.Error("Failed to rollback driver", ex);
+ GeneralTracer.Error("Failed to rollback driver", ex);
throw new DriverRollbackException($"Failed to rollback driver: {ex.Message}", ex);
}
}
@@ -299,7 +297,7 @@ private async Task ExecuteDriverInstallationAsync(
UpdateStrategy strategy,
CancellationToken cancellationToken)
{
- _logger.Information($"Executing driver installation: {driverInfo.FilePath}");
+ GeneralTracer.Info($"Executing driver installation: {driverInfo.FilePath}");
try
{
@@ -315,7 +313,7 @@ private async Task ExecuteDriverInstallationAsync(
}
catch (Exception ex)
{
- _logger.Error("Driver installation failed", ex);
+ GeneralTracer.Error("Driver installation failed", ex);
throw new DriverInstallationException($"Failed to install driver: {ex.Message}", ex);
}
}
@@ -326,7 +324,7 @@ private async Task ExecuteDriverInstallationAsync(
///
private async Task InstallDriverUsingPnPUtilAsync(string driverPath, CancellationToken cancellationToken)
{
- _logger.Information($"Installing driver using PnPUtil: {driverPath}");
+ GeneralTracer.Info($"Installing driver using PnPUtil: {driverPath}");
var startInfo = new ProcessStartInfo
{
@@ -346,11 +344,11 @@ private async Task InstallDriverUsingPnPUtilAsync(string driverPath, Cancellatio
await process.WaitForExitAsync(cancellationToken);
- _logger.Information($"PnPUtil output: {output}");
+ GeneralTracer.Info($"PnPUtil output: {output}");
if (process.ExitCode != 0)
{
- _logger.Error($"PnPUtil failed with exit code {process.ExitCode}. Error: {error}");
+ GeneralTracer.Error($"PnPUtil failed with exit code {process.ExitCode}. Error: {error}");
throw new DriverInstallationException(
$"PnPUtil failed with exit code {process.ExitCode}: {error}");
}
@@ -364,7 +362,7 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
{
try
{
- _logger.Information($"Verifying driver installation for: {driverInfo.FilePath}");
+ GeneralTracer.Info($"Verifying driver installation for: {driverInfo.FilePath}");
// Use PnPUtil to enumerate installed drivers and check if our driver is present
var processStartInfo = new ProcessStartInfo
@@ -380,7 +378,7 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
using var process = Process.Start(processStartInfo);
if (process == null)
{
- _logger.Warning("Failed to start PnPUtil for verification");
+ GeneralTracer.Warn("Failed to start PnPUtil for verification");
return false;
}
@@ -392,12 +390,12 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
bool isInstalled = output.Contains(driverFileName, StringComparison.OrdinalIgnoreCase) ||
output.Contains(Path.GetFileNameWithoutExtension(driverInfo.FilePath), StringComparison.OrdinalIgnoreCase);
- _logger.Information($"Driver verification result: {isInstalled}");
+ GeneralTracer.Info($"Driver verification result: {isInstalled}");
return isInstalled;
}
catch (Exception ex)
{
- _logger.Warning("Failed to verify driver installation", ex);
+ GeneralTracer.Error("Failed to verify driver installation", ex);
// Return true to not block the update if verification fails
return true;
}
@@ -422,7 +420,7 @@ private async Task TryRollbackAsync(string backupPath, CancellationToken c
}
catch (Exception ex)
{
- _logger.Error("Rollback failed", ex);
+ GeneralTracer.Error("Rollback failed", ex);
return false;
}
}
@@ -465,11 +463,11 @@ public async Task> GetDriversFromDirectoryAsync(
try
{
- _logger.Information($"Reading driver information from directory: {directoryPath}");
+ GeneralTracer.Info($"Reading driver information from directory: {directoryPath}");
if (!Directory.Exists(directoryPath))
{
- _logger.Warning($"Directory not found: {directoryPath}");
+ GeneralTracer.Warn($"Directory not found: {directoryPath}");
return driverInfoList;
}
@@ -477,7 +475,7 @@ public async Task> GetDriversFromDirectoryAsync(
var pattern = searchPattern ?? "*.inf";
var driverFiles = Directory.GetFiles(directoryPath, pattern, SearchOption.AllDirectories);
- _logger.Information($"Found {driverFiles.Length} driver files matching pattern: {pattern}");
+ GeneralTracer.Info($"Found {driverFiles.Length} driver files matching pattern: {pattern}");
foreach (var filePath in driverFiles)
{
@@ -490,20 +488,20 @@ public async Task> GetDriversFromDirectoryAsync(
if (driverInfo != null)
{
driverInfoList.Add(driverInfo);
- _logger.Information($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
+ GeneralTracer.Info($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
catch (Exception ex)
{
- _logger.Warning($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
}
}
- _logger.Information($"Successfully loaded {driverInfoList.Count} driver(s) from directory");
+ GeneralTracer.Info($"Successfully loaded {driverInfoList.Count} driver(s) from directory");
}
catch (Exception ex)
{
- _logger.Error($"Error reading drivers from directory: {directoryPath}", ex);
+ GeneralTracer.Error($"Error reading drivers from directory: {directoryPath}", ex);
}
return driverInfoList;
@@ -573,14 +571,14 @@ public async Task> GetDriversFromDirectoryAsync(
}
catch (Exception ex)
{
- _logger.Debug($"Could not get signature for file: {filePath}", ex);
+ GeneralTracer.Debug($"Could not get signature for file: {filePath} - {ex.Message}");
}
return driverInfo;
}
catch (Exception ex)
{
- _logger.Warning($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
return null;
}
}
@@ -645,7 +643,7 @@ private async Task ParseInfFileAsync(string infPath, DriverInfo driverInfo, Canc
}
catch (Exception ex)
{
- _logger.Debug($"Could not parse INF file: {infPath}", ex);
+ GeneralTracer.Debug($"Could not parse INF file: {infPath} - {ex.Message}");
}
}
}
From 8c44d97d43ad672ce85d3f91cb6f0da9b373ff4a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 16:35:00 +0000
Subject: [PATCH 10/15] Fix logging level consistency and remove unused
exception variables
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Implementation/LinuxGeneralDrivelution.cs | 12 ++++++------
.../Implementation/WindowsGeneralDrivelution.cs | 16 ++++++++--------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
index 960b28c7..3dfba576 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
@@ -157,9 +157,9 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
// Try to reload the backed-up module (if system supports it)
GeneralTracer.Info($"Restored module: {moduleName}");
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error($"Failed to restore module: {koFile}", ex);
+ GeneralTracer.Warn($"Failed to restore module: {koFile}");
}
}
@@ -399,9 +399,9 @@ public async Task> GetDriversFromDirectoryAsync(
GeneralTracer.Info($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
}
}
@@ -454,9 +454,9 @@ public async Task> GetDriversFromDirectoryAsync(
return driverInfo;
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
return null;
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
index 7ea82218..cf7e66b0 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
@@ -272,9 +272,9 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
GeneralTracer.Info($"Attempting to restore driver from: {infFile}");
await InstallDriverUsingPnPUtilAsync(infFile, cancellationToken);
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error($"Failed to restore driver from: {infFile}", ex);
+ GeneralTracer.Warn($"Failed to restore driver from: {infFile}");
}
}
}
@@ -393,9 +393,9 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
GeneralTracer.Info($"Driver verification result: {isInstalled}");
return isInstalled;
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error("Failed to verify driver installation", ex);
+ GeneralTracer.Warn("Failed to verify driver installation");
// Return true to not block the update if verification fails
return true;
}
@@ -491,9 +491,9 @@ public async Task> GetDriversFromDirectoryAsync(
GeneralTracer.Info($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
}
}
@@ -576,9 +576,9 @@ public async Task> GetDriversFromDirectoryAsync(
return driverInfo;
}
- catch (Exception ex)
+ catch (Exception)
{
- GeneralTracer.Error($"Failed to parse driver file: {filePath}", ex);
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
return null;
}
}
From 0029025b877fb516361292448edf9370a349f589 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 16:36:17 +0000
Subject: [PATCH 11/15] Add exception messages to warnings for better
troubleshooting
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Core/DriverUpdaterFactory.cs | 3 ++-
.../Implementation/LinuxGeneralDrivelution.cs | 12 ++++++------
.../Implementation/WindowsGeneralDrivelution.cs | 16 ++++++++--------
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index 120dc190..d334b7bc 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -24,7 +24,8 @@ public static class DrivelutionFactory
/// 当前平台不支持时抛出 / Thrown when current platform is not supported
public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
{
- // Use default logger if not provided (kept for backward compatibility but not used internally anymore)
+ // Note: Logger parameter is kept for backward compatibility with existing callers,
+ // but internally the implementation now uses GeneralTracer for logging
logger ??= CreateDefaultLogger(options);
// Detect platform and create appropriate implementation
diff --git a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
index 3dfba576..7c9a3188 100644
--- a/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Linux/Implementation/LinuxGeneralDrivelution.cs
@@ -157,9 +157,9 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
// Try to reload the backed-up module (if system supports it)
GeneralTracer.Info($"Restored module: {moduleName}");
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn($"Failed to restore module: {koFile}");
+ GeneralTracer.Warn($"Failed to restore module: {koFile} - {ex.Message}");
}
}
@@ -399,9 +399,9 @@ public async Task> GetDriversFromDirectoryAsync(
GeneralTracer.Info($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath} - {ex.Message}");
}
}
@@ -454,9 +454,9 @@ public async Task> GetDriversFromDirectoryAsync(
return driverInfo;
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath} - {ex.Message}");
return null;
}
}
diff --git a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
index cf7e66b0..bbcdc600 100644
--- a/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Windows/Implementation/WindowsGeneralDrivelution.cs
@@ -272,9 +272,9 @@ public async Task RollbackAsync(string backupPath, CancellationToken cance
GeneralTracer.Info($"Attempting to restore driver from: {infFile}");
await InstallDriverUsingPnPUtilAsync(infFile, cancellationToken);
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn($"Failed to restore driver from: {infFile}");
+ GeneralTracer.Warn($"Failed to restore driver from: {infFile} - {ex.Message}");
}
}
}
@@ -393,9 +393,9 @@ private async Task VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
GeneralTracer.Info($"Driver verification result: {isInstalled}");
return isInstalled;
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn("Failed to verify driver installation");
+ GeneralTracer.Warn($"Failed to verify driver installation - {ex.Message}");
// Return true to not block the update if verification fails
return true;
}
@@ -491,9 +491,9 @@ public async Task> GetDriversFromDirectoryAsync(
GeneralTracer.Info($"Parsed driver: {driverInfo.Name} v{driverInfo.Version}");
}
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath} - {ex.Message}");
}
}
@@ -576,9 +576,9 @@ public async Task> GetDriversFromDirectoryAsync(
return driverInfo;
}
- catch (Exception)
+ catch (Exception ex)
{
- GeneralTracer.Warn($"Failed to parse driver file: {filePath}");
+ GeneralTracer.Warn($"Failed to parse driver file: {filePath} - {ex.Message}");
return null;
}
}
From 8b1f43ed0ad7c162b7e1a379a09bd1e926f88ba1 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 16:37:31 +0000
Subject: [PATCH 12/15] Replace logger with GeneralTracer in factory and mark
logger parameter as obsolete
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Core/DriverUpdaterFactory.cs | 26 ++++++++-----------
1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index d334b7bc..34ba1b98 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
+using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
using GeneralUpdate.Drivelution.Abstractions.Events;
@@ -18,34 +19,31 @@ public static class DrivelutionFactory
/// 创建适合当前平台的驱动更新器
/// Creates a driver updater suitable for the current platform
///
- /// 日志记录器 / Logger
+ /// 日志记录器(已弃用,保留仅为向后兼容)/ Logger (deprecated, kept for backward compatibility only)
/// 配置选项(可选)/ Configuration options (optional)
/// 平台特定的驱动更新器实现 / Platform-specific driver updater implementation
/// 当前平台不支持时抛出 / Thrown when current platform is not supported
+ [Obsolete("Logger parameter is deprecated. The implementation now uses GeneralTracer for logging.", false)]
public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
{
- // Note: Logger parameter is kept for backward compatibility with existing callers,
- // but internally the implementation now uses GeneralTracer for logging
- logger ??= CreateDefaultLogger(options);
-
// Detect platform and create appropriate implementation
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
- logger.Information("Detected Windows platform, creating WindowsGeneralDrivelution");
+ GeneralTracer.Info("Detected Windows platform, creating WindowsGeneralDrivelution");
var validator = new WindowsDriverValidator();
var backup = new WindowsDriverBackup();
return new WindowsGeneralDrivelution(validator, backup);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- logger.Information("Detected Linux platform, creating LinuxGeneralDrivelution");
+ GeneralTracer.Info("Detected Linux platform, creating LinuxGeneralDrivelution");
var validator = new LinuxDriverValidator();
var backup = new LinuxDriverBackup();
return new LinuxGeneralDrivelution(validator, backup);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
- logger.Warning("MacOS platform detected but not yet implemented");
+ GeneralTracer.Warn("MacOS platform detected but not yet implemented");
throw new PlatformNotSupportedException(
"MacOS driver update is not yet implemented. " +
"This is a placeholder for future MacOS support. " +
@@ -54,7 +52,7 @@ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, Driv
else
{
var osDescription = RuntimeInformation.OSDescription;
- logger.Error($"Unsupported platform detected: {osDescription}");
+ GeneralTracer.Error($"Unsupported platform detected: {osDescription}");
throw new PlatformNotSupportedException(
$"Current platform '{osDescription}' is not supported. " +
"Supported platforms: Windows (8+), Linux (Ubuntu 18.04+, CentOS 7+, Debian 10+)");
@@ -65,12 +63,11 @@ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, Driv
/// 创建适合当前平台的驱动验证器
/// Creates a driver validator suitable for the current platform
///
- /// 日志记录器 / Logger
+ /// 日志记录器(已弃用,保留仅为向后兼容)/ Logger (deprecated, kept for backward compatibility only)
/// 平台特定的驱动验证器实现 / Platform-specific driver validator implementation
+ [Obsolete("Logger parameter is deprecated. The implementation now uses GeneralTracer for logging.", false)]
public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null)
{
- logger ??= CreateDefaultLogger();
-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return new WindowsDriverValidator();
@@ -93,12 +90,11 @@ public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null
/// 创建适合当前平台的驱动备份管理器
/// Creates a driver backup manager suitable for the current platform
///
- /// 日志记录器 / Logger
+ /// 日志记录器(已弃用,保留仅为向后兼容)/ Logger (deprecated, kept for backward compatibility only)
/// 平台特定的驱动备份实现 / Platform-specific driver backup implementation
+ [Obsolete("Logger parameter is deprecated. The implementation now uses GeneralTracer for logging.", false)]
public static IDriverBackup CreateBackup(IDrivelutionLogger? logger = null)
{
- logger ??= CreateDefaultLogger();
-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return new WindowsDriverBackup();
From 7d4ccb602e739d49ae55dbf98c6b596c705cdd1e Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 16:38:24 +0000
Subject: [PATCH 13/15] Improve obsolete attribute messages with migration
guidance
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Core/DriverUpdaterFactory.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index 34ba1b98..98081a8b 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -19,11 +19,11 @@ public static class DrivelutionFactory
/// 创建适合当前平台的驱动更新器
/// Creates a driver updater suitable for the current platform
///
- /// 日志记录器(已弃用,保留仅为向后兼容)/ Logger (deprecated, kept for backward compatibility only)
+ /// 日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)
/// 配置选项(可选)/ Configuration options (optional)
/// 平台特定的驱动更新器实现 / Platform-specific driver updater implementation
/// 当前平台不支持时抛出 / Thrown when current platform is not supported
- [Obsolete("Logger parameter is deprecated. The implementation now uses GeneralTracer for logging.", false)]
+ [Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call Create(null, options) or omit the logger parameter.", false)]
public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
{
// Detect platform and create appropriate implementation
@@ -63,9 +63,9 @@ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, Driv
/// 创建适合当前平台的驱动验证器
/// Creates a driver validator suitable for the current platform
///
- /// 日志记录器(已弃用,保留仅为向后兼容)/ Logger (deprecated, kept for backward compatibility only)
+ /// 日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)
/// 平台特定的驱动验证器实现 / Platform-specific driver validator implementation
- [Obsolete("Logger parameter is deprecated. The implementation now uses GeneralTracer for logging.", false)]
+ [Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call CreateValidator() without parameters.", false)]
public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -90,9 +90,9 @@ public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null
/// 创建适合当前平台的驱动备份管理器
/// Creates a driver backup manager suitable for the current platform
///
- /// 日志记录器(已弃用,保留仅为向后兼容)/ Logger (deprecated, kept for backward compatibility only)
+ /// 日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)
/// 平台特定的驱动备份实现 / Platform-specific driver backup implementation
- [Obsolete("Logger parameter is deprecated. The implementation now uses GeneralTracer for logging.", false)]
+ [Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call CreateBackup() without parameters.", false)]
public static IDriverBackup CreateBackup(IDrivelutionLogger? logger = null)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
From cfc28c7c145ca7eeb84b37eab3329e57fb8979f3 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 16:42:47 +0000
Subject: [PATCH 14/15] Replace IDrivelutionLogger with GeneralTracer for
consistent logging
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../Core/DriverUpdaterFactoryTests.cs | 70 +------------------
.../GeneralDrivelutionTests.cs | 37 ----------
.../Core/DriverUpdaterFactory.cs | 22 +-----
.../GeneralDrivelution.cs | 16 +----
4 files changed, 7 insertions(+), 138 deletions(-)
diff --git a/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs b/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs
index 9581a653..0ae1c236 100644
--- a/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs
+++ b/src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs
@@ -1,7 +1,6 @@
using GeneralUpdate.Drivelution.Core;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
-using GeneralUpdate.Drivelution.Abstractions.Events;
namespace DrivelutionTest.Core;
@@ -25,23 +24,6 @@ public void Create_WithoutParameters_ReturnsNonNullInstance()
Assert.IsAssignableFrom(updater);
}
- ///
- /// Tests that Create method accepts custom logger.
- ///
- [Fact]
- public void Create_WithCustomLogger_ReturnsInstance()
- {
- // Arrange
- var logger = new DrivelutionLogger();
-
- // Act
- var updater = DrivelutionFactory.Create(logger);
-
- // Assert
- Assert.NotNull(updater);
- Assert.IsAssignableFrom(updater);
- }
-
///
/// Tests that Create method accepts custom options.
///
@@ -55,7 +37,7 @@ public void Create_WithCustomOptions_ReturnsInstance()
};
// Act
- var updater = DrivelutionFactory.Create(null, options);
+ var updater = DrivelutionFactory.Create(options);
// Assert
Assert.NotNull(updater);
@@ -93,7 +75,7 @@ public void IsPlatformSupported_ReturnsBooleanValue()
/// Tests that CreateValidator returns a non-null instance.
///
[Fact]
- public void CreateValidator_WithoutLogger_ReturnsNonNullInstance()
+ public void CreateValidator_WithoutParameters_ReturnsNonNullInstance()
{
// Skip on MacOS and Unknown platforms
var platform = DrivelutionFactory.GetCurrentPlatform();
@@ -114,7 +96,7 @@ public void CreateValidator_WithoutLogger_ReturnsNonNullInstance()
/// Tests that CreateBackup returns a non-null instance.
///
[Fact]
- public void CreateBackup_WithoutLogger_ReturnsNonNullInstance()
+ public void CreateBackup_WithoutParameters_ReturnsNonNullInstance()
{
// Skip on MacOS and Unknown platforms
var platform = DrivelutionFactory.GetCurrentPlatform();
@@ -131,52 +113,6 @@ public void CreateBackup_WithoutLogger_ReturnsNonNullInstance()
Assert.IsAssignableFrom(backup);
}
- ///
- /// Tests that CreateValidator with custom logger works correctly.
- ///
- [Fact]
- public void CreateValidator_WithCustomLogger_ReturnsInstance()
- {
- // Skip on MacOS and Unknown platforms
- var platform = DrivelutionFactory.GetCurrentPlatform();
- if (platform == "MacOS" || platform == "Unknown")
- {
- return;
- }
-
- // Arrange
- var logger = new DrivelutionLogger();
-
- // Act
- var validator = DrivelutionFactory.CreateValidator(logger);
-
- // Assert
- Assert.NotNull(validator);
- }
-
- ///
- /// Tests that CreateBackup with custom logger works correctly.
- ///
- [Fact]
- public void CreateBackup_WithCustomLogger_ReturnsInstance()
- {
- // Skip on MacOS and Unknown platforms
- var platform = DrivelutionFactory.GetCurrentPlatform();
- if (platform == "MacOS" || platform == "Unknown")
- {
- return;
- }
-
- // Arrange
- var logger = new DrivelutionLogger();
-
- // Act
- var backup = DrivelutionFactory.CreateBackup(logger);
-
- // Assert
- Assert.NotNull(backup);
- }
-
///
/// Tests that Create throws PlatformNotSupportedException on unsupported platforms.
/// This test documents expected behavior but cannot be easily tested on supported platforms.
diff --git a/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs b/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs
index 03578631..f9a26f7d 100644
--- a/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs
+++ b/src/c#/DrivelutionTest/GeneralDrivelutionTests.cs
@@ -1,7 +1,6 @@
using GeneralUpdate.Drivelution;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
-using GeneralUpdate.Drivelution.Abstractions.Events;
namespace DrivelutionTest;
@@ -43,42 +42,6 @@ public void Create_WithOptions_ReturnsNonNullInstance()
Assert.NotNull(updater);
}
- ///
- /// Tests that Create method with custom logger returns a non-null instance.
- ///
- [Fact]
- public void Create_WithCustomLogger_ReturnsNonNullInstance()
- {
- // Arrange
- var logger = new DrivelutionLogger();
-
- // Act
- var updater = GeneralDrivelution.Create(logger);
-
- // Assert
- Assert.NotNull(updater);
- }
-
- ///
- /// Tests that Create method with custom logger and options returns instance.
- ///
- [Fact]
- public void Create_WithCustomLoggerAndOptions_ReturnsInstance()
- {
- // Arrange
- var logger = new DrivelutionLogger();
- var options = new DrivelutionOptions
- {
- DefaultBackupPath = "./backups"
- };
-
- // Act
- var updater = GeneralDrivelution.Create(logger, options);
-
- // Assert
- Assert.NotNull(updater);
- }
-
///
/// Tests that GetPlatformInfo returns valid platform information.
///
diff --git a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
index 98081a8b..7fb9a998 100644
--- a/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
+++ b/src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs
@@ -2,7 +2,6 @@
using GeneralUpdate.Common.Shared;
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Windows.Implementation;
using GeneralUpdate.Drivelution.Linux.Implementation;
using GeneralUpdate.Drivelution.MacOS.Implementation;
@@ -19,12 +18,10 @@ public static class DrivelutionFactory
/// 创建适合当前平台的驱动更新器
/// Creates a driver updater suitable for the current platform
///
- /// 日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)
/// 配置选项(可选)/ Configuration options (optional)
/// 平台特定的驱动更新器实现 / Platform-specific driver updater implementation
/// 当前平台不支持时抛出 / Thrown when current platform is not supported
- [Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call Create(null, options) or omit the logger parameter.", false)]
- public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
+ public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
{
// Detect platform and create appropriate implementation
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -63,10 +60,8 @@ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, Driv
/// 创建适合当前平台的驱动验证器
/// Creates a driver validator suitable for the current platform
///
- /// 日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)
/// 平台特定的驱动验证器实现 / Platform-specific driver validator implementation
- [Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call CreateValidator() without parameters.", false)]
- public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null)
+ public static IDriverValidator CreateValidator()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
@@ -90,10 +85,8 @@ public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null
/// 创建适合当前平台的驱动备份管理器
/// Creates a driver backup manager suitable for the current platform
///
- /// 日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)
/// 平台特定的驱动备份实现 / Platform-specific driver backup implementation
- [Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call CreateBackup() without parameters.", false)]
- public static IDriverBackup CreateBackup(IDrivelutionLogger? logger = null)
+ public static IDriverBackup CreateBackup()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
@@ -141,13 +134,4 @@ public static bool IsPlatformSupported()
RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
// MacOS is planned but not yet implemented
}
-
- ///
- /// 创建默认日志记录器
- /// Creates a default logger
- ///
- private static IDrivelutionLogger CreateDefaultLogger(DrivelutionOptions? options = null)
- {
- return Logging.LoggerConfigurator.ConfigureLogger(options);
- }
}
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
index b8920e3b..4db4c8e0 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
@@ -1,8 +1,6 @@
using GeneralUpdate.Drivelution.Abstractions;
using GeneralUpdate.Drivelution.Abstractions.Configuration;
-using GeneralUpdate.Drivelution.Abstractions.Events;
using GeneralUpdate.Drivelution.Abstractions.Models;
-using GeneralUpdate.Drivelution.Core.Logging;
using GeneralUpdate.Drivelution.Core.Utilities;
namespace GeneralUpdate.Drivelution;
@@ -33,19 +31,7 @@ public static class GeneralDrivelution
/// Thrown when platform is not supported
public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
{
- var logger = LoggerConfigurator.ConfigureLogger(options);
- return Core.DrivelutionFactory.Create(logger, options);
- }
-
- ///
- /// Creates a driver updater instance (with custom logger)
- ///
- /// Custom logger
- /// Configuration options (optional)
- /// Platform-adapted driver updater
- public static IGeneralDrivelution Create(IDrivelutionLogger logger, DrivelutionOptions? options = null)
- {
- return Core.DrivelutionFactory.Create(logger, options);
+ return Core.DrivelutionFactory.Create(options);
}
///
From 06e9425e209360e5501a52f84da0ed7e93ddc79b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 12 Feb 2026 09:10:10 +0000
Subject: [PATCH 15/15] Replace GeneralUpdate.Common project reference with
file linking in Drivelution
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
---
.../GeneralUpdate.Drivelution.csproj | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
index 85d060dd..e0ed518d 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
@@ -12,8 +12,11 @@
full
+
-
+
+
+