Skip to content

Commit 6ff9cb9

Browse files
Lower the amout of public classes
1 parent 6cddb9a commit 6ff9cb9

32 files changed

+123
-180
lines changed

nexus/Program.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Nexus.Config;
88
using Nexus.External.Apis.FileSystem;
99
using Nexus.External.Apis.ProcessManagement;
10+
using Nexus.External.Apis.ServiceManagement;
1011
using Nexus.Logging;
1112
using Nexus.Startup;
1213

@@ -35,9 +36,10 @@ public static async Task<int> Main(string[] args)
3536
var settings = new Settings();
3637
var filesystem = new FileSystem();
3738
var processManager = new ProcessManager();
39+
var serviceController = new ServiceControllerWrapper();
3840

3941
// Use hosted service for ALL command types
40-
var host = CreateHostBuilder(cmd, filesystem, processManager, settings).Build();
42+
var host = CreateHostBuilder(cmd, filesystem, processManager, serviceController, settings).Build();
4143
await host.RunAsync();
4244

4345
return 0;
@@ -59,10 +61,11 @@ public static async Task<int> Main(string[] args)
5961
/// <param name="cmd">Command line context.</param>
6062
/// <param name="fileSystem">The file system abstraction.</param>
6163
/// <param name="processManager">The process manager abstraction.</param>
64+
/// <param name="serviceController">Service controller abstraction.</param>
6265
/// <param name="settings">The product settings.</param>
6366
/// <returns>Configured host builder.</returns>
6467
[SupportedOSPlatform("windows")]
65-
internal static IHostBuilder CreateHostBuilder(CommandLineContext cmd, IFileSystem fileSystem, IProcessManager processManager, ISettings settings)
68+
internal static IHostBuilder CreateHostBuilder(CommandLineContext cmd, IFileSystem fileSystem, IProcessManager processManager, IServiceController serviceController, ISettings settings)
6669
{
6770
var builder = Host.CreateDefaultBuilder(cmd.Args)
6871
.ConfigureLogging((context, logging) => logging.AddNexusLogging(
@@ -75,7 +78,7 @@ internal static IHostBuilder CreateHostBuilder(CommandLineContext cmd, IFileSyst
7578

7679
// Register ONLY the main hosted service (no others)
7780
var ununsedHost = services.AddHostedService(sp =>
78-
new MainHostedService(cmd, fileSystem, processManager, settings));
81+
new MainHostedService(cmd, fileSystem, processManager, serviceController, settings));
7982
});
8083

8184
// Configure Windows Service support if in service mode

nexus/Startup/MainHostedService.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Nexus.Config;
77
using Nexus.External.Apis.FileSystem;
88
using Nexus.External.Apis.ProcessManagement;
9+
using Nexus.External.Apis.ServiceManagement;
910
using Nexus.Protocol;
1011
using Nexus.Setup;
1112

@@ -33,10 +34,11 @@ internal class MainHostedService : IHostedService
3334
/// <param name="commandLineContext">Command line context.</param>
3435
/// <param name="fileSystem">The file system abstraction.</param>
3536
/// <param name="processManager">The process manager abstraction.</param>
37+
/// <param name="serviceController">Service controller abstraction.</param>
3638
/// <param name="settings">The product settings.</param>
3739
public MainHostedService(
38-
CommandLineContext commandLineContext, IFileSystem fileSystem, IProcessManager processManager, ISettings settings)
39-
: this(commandLineContext, new ProtocolServer(fileSystem, processManager, settings), new ProductInstallation(settings), fileSystem, processManager, settings)
40+
CommandLineContext commandLineContext, IFileSystem fileSystem, IProcessManager processManager, IServiceController serviceController, ISettings settings)
41+
: this(commandLineContext, new ProtocolServer(fileSystem, processManager, settings), new ProductInstallation(fileSystem, processManager, serviceController, settings), fileSystem, processManager, settings)
4042
{
4143
}
4244

nexus_engine/nexus_engine/DebugEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public async Task<string> CreateSessionAsync(string dumpFilePath, string? symbol
139139

140140
try
141141
{
142-
var preprocessor = new CommandPreprocessor(m_FileSystem, m_Settings);
142+
var preprocessor = new CommandPreprocessor(m_FileSystem, m_ProcessManager, m_Settings);
143143
var session = new DebugSession(sessionId, dumpFilePath, symbolPath, m_Settings, m_FileSystem, m_ProcessManager, m_BatchProcessor, preprocessor);
144144

145145
// Subscribe to session events

nexus_engine/nexus_engine/Preprocessing/CommandPreprocessor.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Nexus.Config;
55
using Nexus.External.Apis.FileSystem;
6+
using Nexus.External.Apis.ProcessManagement;
67

78
namespace Nexus.Engine.Preprocessing;
89

@@ -16,7 +17,7 @@ internal partial class CommandPreprocessor
1617
/// <summary>
1718
/// Path handler for WSL to Windows path conversion.
1819
/// </summary>
19-
private readonly PathHandler m_PathHandler = new();
20+
private readonly PathHandler m_PathHandler;
2021

2122
/// <summary>
2223
/// File system abstraction for directory operations.
@@ -34,11 +35,13 @@ internal partial class CommandPreprocessor
3435
/// Initializes a new instance of the <see cref="CommandPreprocessor"/> class.
3536
/// </summary>
3637
/// <param name="fileSystem">The file system abstraction for directory operations.</param>
38+
/// <param name="processManager">The process manager.</param>
3739
/// <param name="settings">The product settings.</param>
38-
public CommandPreprocessor(IFileSystem fileSystem, ISettings settings)
40+
public CommandPreprocessor(IFileSystem fileSystem, IProcessManager processManager, ISettings settings)
3941
{
4042
m_FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
4143
m_Settings = settings;
44+
m_PathHandler = new PathHandler(processManager);
4245
}
4346

4447
/// <summary>

nexus_engine/nexus_engine/Preprocessing/PathHandler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Collections.Concurrent;
22
using System.Text.RegularExpressions;
33

4+
using Nexus.External.Apis.ProcessManagement;
5+
46
namespace Nexus.Engine.Preprocessing;
57

68
/// <summary>
@@ -19,9 +21,10 @@ internal partial class PathHandler
1921
/// <summary>
2022
/// Initializes a new instance of the <see cref="PathHandler"/> class.
2123
/// </summary>
22-
public PathHandler()
24+
/// <param name="processManager">The process manager.</param>
25+
public PathHandler(IProcessManager processManager)
2326
{
24-
m_WslConverter = new WslPathConverter();
27+
m_WslConverter = new WslPathConverter(processManager);
2528
}
2629

2730
/// <summary>

nexus_engine/nexus_engine/Preprocessing/WslPathConverter.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,11 @@ internal partial class WslPathConverter
1313
private const int WslHelperTimeoutMs = 2000;
1414
private readonly IProcessManager m_ProcessManager;
1515

16-
/// <summary>
17-
/// Initializes a new instance of the <see cref="WslPathConverter"/> class.
18-
/// </summary>
19-
public WslPathConverter()
20-
: this(new ProcessManager())
21-
{
22-
}
23-
2416
/// <summary>
2517
/// Initializes a new instance of the <see cref="WslPathConverter"/> class.
2618
/// </summary>
2719
/// <param name="processManager">The process manager for executing wsl.exe.</param>
28-
internal WslPathConverter(IProcessManager processManager)
20+
public WslPathConverter(IProcessManager processManager)
2921
{
3022
m_ProcessManager = processManager ?? throw new ArgumentNullException(nameof(processManager));
3123
}

nexus_engine/nexus_engine_extensions/Core/Executor.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,14 @@ internal class Executor
2828
// Compiled regex to strip ANSI escape sequences from process output
2929
private static readonly Regex AnsiRegex = new("\x1B\\[[0-9;]*[A-Za-z]", RegexOptions.Compiled);
3030

31-
/// <summary>
32-
/// Initializes a new instance of the <see cref="Executor"/> class with default dependencies.
33-
/// </summary>
34-
/// <param name="manager">The extension manager.</param>
35-
/// <param name="tokenValidator">The token validator.</param>
36-
/// <param name="settings">The product settings.</param>
37-
public Executor(Manager manager, TokenValidator tokenValidator, ISettings settings)
38-
: this(
39-
manager,
40-
tokenValidator,
41-
new ProcessManager(),
42-
settings)
43-
{
44-
}
45-
4631
/// <summary>
4732
/// Initializes a new instance of the <see cref="Executor"/> class with injected dependencies.
4833
/// </summary>
4934
/// <param name="manager">The extension manager.</param>
5035
/// <param name="tokenValidator">The token validator.</param>
5136
/// <param name="processManager">The process manager.</param>
5237
/// <param name="settings">The product settings.</param>
53-
internal Executor(
38+
public Executor(
5439
Manager manager,
5540
TokenValidator tokenValidator,
5641
IProcessManager processManager,

nexus_engine/nexus_engine_extensions/Core/Manager.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,14 @@ internal class Manager : IDisposable
2424
private int m_Version = 0;
2525
private bool m_Disposed;
2626

27-
/// <summary>
28-
/// Initializes a new instance of the <see cref="Manager"/> class with default dependencies.
29-
/// </summary>
30-
/// <param name="settings">The product settings.</param>
31-
/// <exception cref="ArgumentNullException">Thrown when logger is null.</exception>
32-
/// <exception cref="ArgumentException">Thrown when extensionsPath is null or empty.</exception>
33-
public Manager(ISettings settings)
34-
: this(new FileSystem(), settings)
35-
{
36-
}
37-
3827
/// <summary>
3928
/// Initializes a new instance of the <see cref="Manager"/> class with specified dependencies.
4029
/// </summary>
4130
/// <param name="fileSystem">The file system abstraction.</param>
4231
/// <param name="settings">The product settings.</param>
4332
/// <exception cref="ArgumentNullException">Thrown when fileSystem is null.</exception>
4433
/// <exception cref="ArgumentException">Thrown when extensionsPath is null or empty.</exception>
45-
internal Manager(IFileSystem fileSystem, ISettings settings)
34+
public Manager(IFileSystem fileSystem, ISettings settings)
4635
{
4736
m_FileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
4837
m_Logger = LogManager.GetCurrentClassLogger();

nexus_setup/Core/ServiceInstaller.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,13 @@ internal class ServiceInstaller : IServiceInstaller
2222
private readonly IProcessManager m_ProcessManager;
2323
private readonly IServiceController m_ServiceController;
2424

25-
/// <summary>
26-
/// Initializes a new instance of the <see cref="ServiceInstaller"/> class.
27-
/// </summary>
28-
public ServiceInstaller()
29-
: this(new FileSystem(), new ProcessManager(), new ServiceControllerWrapper())
30-
{
31-
}
32-
3325
/// <summary>
3426
/// Initializes a new instance of the <see cref="ServiceInstaller"/> class.
3527
/// </summary>
3628
/// <param name="fileSystem">File system abstraction.</param>
3729
/// <param name="processManager">Process manager abstraction.</param>
3830
/// <param name="serviceController">Service controller abstraction.</param>
39-
internal ServiceInstaller(
31+
public ServiceInstaller(
4032
IFileSystem fileSystem,
4133
IProcessManager processManager,
4234
IServiceController serviceController)

nexus_setup/Core/ServiceUpdater.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,13 @@ internal class ServiceUpdater
2424
private readonly IServiceController m_ServiceController;
2525
private readonly DirectoryCopyUtility m_DirectoryCopyUtility;
2626

27-
/// <summary>
28-
/// Initializes a new instance of the <see cref="ServiceUpdater"/> class.
29-
/// </summary>
30-
public ServiceUpdater()
31-
: this(new FileSystem(), new ProcessManager(), new ServiceControllerWrapper())
32-
{
33-
}
34-
3527
/// <summary>
3628
/// Initializes a new instance of the <see cref="ServiceUpdater"/> class.
3729
/// </summary>
3830
/// <param name="fileSystem">File system abstraction.</param>
3931
/// <param name="processManager">Process manager abstraction.</param>
4032
/// <param name="serviceController">Service controller abstraction.</param>
41-
internal ServiceUpdater(IFileSystem fileSystem, IProcessManager processManager, IServiceController serviceController)
33+
public ServiceUpdater(IFileSystem fileSystem, IProcessManager processManager, IServiceController serviceController)
4234
{
4335
m_Logger = LogManager.GetCurrentClassLogger();
4436

0 commit comments

Comments
 (0)