Skip to content

Commit cfc28c7

Browse files
CopilotJusterZhu
andcommitted
Replace IDrivelutionLogger with GeneralTracer for consistent logging
Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
1 parent 7d4ccb6 commit cfc28c7

File tree

4 files changed

+7
-138
lines changed

4 files changed

+7
-138
lines changed

src/c#/DrivelutionTest/Core/DriverUpdaterFactoryTests.cs

Lines changed: 3 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GeneralUpdate.Drivelution.Core;
22
using GeneralUpdate.Drivelution.Abstractions;
33
using GeneralUpdate.Drivelution.Abstractions.Configuration;
4-
using GeneralUpdate.Drivelution.Abstractions.Events;
54

65
namespace DrivelutionTest.Core;
76

@@ -25,23 +24,6 @@ public void Create_WithoutParameters_ReturnsNonNullInstance()
2524
Assert.IsAssignableFrom<IGeneralDrivelution>(updater);
2625
}
2726

28-
/// <summary>
29-
/// Tests that Create method accepts custom logger.
30-
/// </summary>
31-
[Fact]
32-
public void Create_WithCustomLogger_ReturnsInstance()
33-
{
34-
// Arrange
35-
var logger = new DrivelutionLogger();
36-
37-
// Act
38-
var updater = DrivelutionFactory.Create(logger);
39-
40-
// Assert
41-
Assert.NotNull(updater);
42-
Assert.IsAssignableFrom<IGeneralDrivelution>(updater);
43-
}
44-
4527
/// <summary>
4628
/// Tests that Create method accepts custom options.
4729
/// </summary>
@@ -55,7 +37,7 @@ public void Create_WithCustomOptions_ReturnsInstance()
5537
};
5638

5739
// Act
58-
var updater = DrivelutionFactory.Create(null, options);
40+
var updater = DrivelutionFactory.Create(options);
5941

6042
// Assert
6143
Assert.NotNull(updater);
@@ -93,7 +75,7 @@ public void IsPlatformSupported_ReturnsBooleanValue()
9375
/// Tests that CreateValidator returns a non-null instance.
9476
/// </summary>
9577
[Fact]
96-
public void CreateValidator_WithoutLogger_ReturnsNonNullInstance()
78+
public void CreateValidator_WithoutParameters_ReturnsNonNullInstance()
9779
{
9880
// Skip on MacOS and Unknown platforms
9981
var platform = DrivelutionFactory.GetCurrentPlatform();
@@ -114,7 +96,7 @@ public void CreateValidator_WithoutLogger_ReturnsNonNullInstance()
11496
/// Tests that CreateBackup returns a non-null instance.
11597
/// </summary>
11698
[Fact]
117-
public void CreateBackup_WithoutLogger_ReturnsNonNullInstance()
99+
public void CreateBackup_WithoutParameters_ReturnsNonNullInstance()
118100
{
119101
// Skip on MacOS and Unknown platforms
120102
var platform = DrivelutionFactory.GetCurrentPlatform();
@@ -131,52 +113,6 @@ public void CreateBackup_WithoutLogger_ReturnsNonNullInstance()
131113
Assert.IsAssignableFrom<IDriverBackup>(backup);
132114
}
133115

134-
/// <summary>
135-
/// Tests that CreateValidator with custom logger works correctly.
136-
/// </summary>
137-
[Fact]
138-
public void CreateValidator_WithCustomLogger_ReturnsInstance()
139-
{
140-
// Skip on MacOS and Unknown platforms
141-
var platform = DrivelutionFactory.GetCurrentPlatform();
142-
if (platform == "MacOS" || platform == "Unknown")
143-
{
144-
return;
145-
}
146-
147-
// Arrange
148-
var logger = new DrivelutionLogger();
149-
150-
// Act
151-
var validator = DrivelutionFactory.CreateValidator(logger);
152-
153-
// Assert
154-
Assert.NotNull(validator);
155-
}
156-
157-
/// <summary>
158-
/// Tests that CreateBackup with custom logger works correctly.
159-
/// </summary>
160-
[Fact]
161-
public void CreateBackup_WithCustomLogger_ReturnsInstance()
162-
{
163-
// Skip on MacOS and Unknown platforms
164-
var platform = DrivelutionFactory.GetCurrentPlatform();
165-
if (platform == "MacOS" || platform == "Unknown")
166-
{
167-
return;
168-
}
169-
170-
// Arrange
171-
var logger = new DrivelutionLogger();
172-
173-
// Act
174-
var backup = DrivelutionFactory.CreateBackup(logger);
175-
176-
// Assert
177-
Assert.NotNull(backup);
178-
}
179-
180116
/// <summary>
181117
/// Tests that Create throws PlatformNotSupportedException on unsupported platforms.
182118
/// This test documents expected behavior but cannot be easily tested on supported platforms.

src/c#/DrivelutionTest/GeneralDrivelutionTests.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GeneralUpdate.Drivelution;
22
using GeneralUpdate.Drivelution.Abstractions.Models;
33
using GeneralUpdate.Drivelution.Abstractions.Configuration;
4-
using GeneralUpdate.Drivelution.Abstractions.Events;
54

65
namespace DrivelutionTest;
76

@@ -43,42 +42,6 @@ public void Create_WithOptions_ReturnsNonNullInstance()
4342
Assert.NotNull(updater);
4443
}
4544

46-
/// <summary>
47-
/// Tests that Create method with custom logger returns a non-null instance.
48-
/// </summary>
49-
[Fact]
50-
public void Create_WithCustomLogger_ReturnsNonNullInstance()
51-
{
52-
// Arrange
53-
var logger = new DrivelutionLogger();
54-
55-
// Act
56-
var updater = GeneralDrivelution.Create(logger);
57-
58-
// Assert
59-
Assert.NotNull(updater);
60-
}
61-
62-
/// <summary>
63-
/// Tests that Create method with custom logger and options returns instance.
64-
/// </summary>
65-
[Fact]
66-
public void Create_WithCustomLoggerAndOptions_ReturnsInstance()
67-
{
68-
// Arrange
69-
var logger = new DrivelutionLogger();
70-
var options = new DrivelutionOptions
71-
{
72-
DefaultBackupPath = "./backups"
73-
};
74-
75-
// Act
76-
var updater = GeneralDrivelution.Create(logger, options);
77-
78-
// Assert
79-
Assert.NotNull(updater);
80-
}
81-
8245
/// <summary>
8346
/// Tests that GetPlatformInfo returns valid platform information.
8447
/// </summary>

src/c#/GeneralUpdate.Drivelution/Core/DriverUpdaterFactory.cs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using GeneralUpdate.Common.Shared;
33
using GeneralUpdate.Drivelution.Abstractions;
44
using GeneralUpdate.Drivelution.Abstractions.Configuration;
5-
using GeneralUpdate.Drivelution.Abstractions.Events;
65
using GeneralUpdate.Drivelution.Windows.Implementation;
76
using GeneralUpdate.Drivelution.Linux.Implementation;
87
using GeneralUpdate.Drivelution.MacOS.Implementation;
@@ -19,12 +18,10 @@ public static class DrivelutionFactory
1918
/// 创建适合当前平台的驱动更新器
2019
/// Creates a driver updater suitable for the current platform
2120
/// </summary>
22-
/// <param name="logger">日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)</param>
2321
/// <param name="options">配置选项(可选)/ Configuration options (optional)</param>
2422
/// <returns>平台特定的驱动更新器实现 / Platform-specific driver updater implementation</returns>
2523
/// <exception cref="PlatformNotSupportedException">当前平台不支持时抛出 / Thrown when current platform is not supported</exception>
26-
[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)]
27-
public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, DrivelutionOptions? options = null)
24+
public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
2825
{
2926
// Detect platform and create appropriate implementation
3027
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -63,10 +60,8 @@ public static IGeneralDrivelution Create(IDrivelutionLogger? logger = null, Driv
6360
/// 创建适合当前平台的驱动验证器
6461
/// Creates a driver validator suitable for the current platform
6562
/// </summary>
66-
/// <param name="logger">日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)</param>
6763
/// <returns>平台特定的驱动验证器实现 / Platform-specific driver validator implementation</returns>
68-
[Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call CreateValidator() without parameters.", false)]
69-
public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null)
64+
public static IDriverValidator CreateValidator()
7065
{
7166
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
7267
{
@@ -90,10 +85,8 @@ public static IDriverValidator CreateValidator(IDrivelutionLogger? logger = null
9085
/// 创建适合当前平台的驱动备份管理器
9186
/// Creates a driver backup manager suitable for the current platform
9287
/// </summary>
93-
/// <param name="logger">日志记录器(已废弃,内部使用GeneralTracer)/ Logger (deprecated, uses GeneralTracer internally)</param>
9488
/// <returns>平台特定的驱动备份实现 / Platform-specific driver backup implementation</returns>
95-
[Obsolete("Logger parameter is deprecated and will be ignored. The implementation now uses GeneralTracer for logging. Call CreateBackup() without parameters.", false)]
96-
public static IDriverBackup CreateBackup(IDrivelutionLogger? logger = null)
89+
public static IDriverBackup CreateBackup()
9790
{
9891
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
9992
{
@@ -141,13 +134,4 @@ public static bool IsPlatformSupported()
141134
RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
142135
// MacOS is planned but not yet implemented
143136
}
144-
145-
/// <summary>
146-
/// 创建默认日志记录器
147-
/// Creates a default logger
148-
/// </summary>
149-
private static IDrivelutionLogger CreateDefaultLogger(DrivelutionOptions? options = null)
150-
{
151-
return Logging.LoggerConfigurator.ConfigureLogger(options);
152-
}
153137
}

src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using GeneralUpdate.Drivelution.Abstractions;
22
using GeneralUpdate.Drivelution.Abstractions.Configuration;
3-
using GeneralUpdate.Drivelution.Abstractions.Events;
43
using GeneralUpdate.Drivelution.Abstractions.Models;
5-
using GeneralUpdate.Drivelution.Core.Logging;
64
using GeneralUpdate.Drivelution.Core.Utilities;
75

86
namespace GeneralUpdate.Drivelution;
@@ -33,19 +31,7 @@ public static class GeneralDrivelution
3331
/// <exception cref="PlatformNotSupportedException">Thrown when platform is not supported</exception>
3432
public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
3533
{
36-
var logger = LoggerConfigurator.ConfigureLogger(options);
37-
return Core.DrivelutionFactory.Create(logger, options);
38-
}
39-
40-
/// <summary>
41-
/// Creates a driver updater instance (with custom logger)
42-
/// </summary>
43-
/// <param name="logger">Custom logger</param>
44-
/// <param name="options">Configuration options (optional)</param>
45-
/// <returns>Platform-adapted driver updater</returns>
46-
public static IGeneralDrivelution Create(IDrivelutionLogger logger, DrivelutionOptions? options = null)
47-
{
48-
return Core.DrivelutionFactory.Create(logger, options);
34+
return Core.DrivelutionFactory.Create(options);
4935
}
5036

5137
/// <summary>

0 commit comments

Comments
 (0)