From b00c9f18527042a81fb1ee5c31059d3c7de9dd49 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Mon, 29 Dec 2025 18:39:05 +0000 Subject: [PATCH 1/2] chore: Add .worktrees/ to .gitignore for parallel development MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 88f3ca33fc..6a72d69cea 100644 --- a/.gitignore +++ b/.gitignore @@ -399,4 +399,4 @@ FodyWeavers.xsd requirements .claude/settings.local.json -nul \ No newline at end of file +nul.worktrees/ From e3166c3b469f822eb7b9140fbdd292925012f631 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Tue, 30 Dec 2025 02:40:58 +0000 Subject: [PATCH 2/2] refactor: Split IPipelineHookContext into focused interfaces for ISP compliance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split the monolithic IPipelineHookContext (27+ members) into focused sub-interfaces to comply with the Interface Segregation Principle (ISP): - IPipelineServices: DI and configuration (ServiceProvider, Get, Configuration, PipelineOptions) - IPipelineLogging: Logging functionality (Logger) - IPipelineTools: Command execution and tools (Command, Powershell, Bash, Http, Downloader, Installer) - IPipelineEncoding: Serialization and encoding (Json, Xml, Yaml, Hex, Base64, Hasher) - IPipelineFileSystem: File operations (FileSystem, Zip, Checksum) - IPipelineEnvironment: Environment and build detection (Environment, BuildSystemDetector) IPipelineHookContext now inherits from all sub-interfaces, maintaining full backwards compatibility while allowing consumers to depend on only the subset of functionality they need. Fixes #1454 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../Context/IPipelineEncoding.cs | 46 ++++ .../Context/IPipelineEnvironment.cs | 30 +++ .../Context/IPipelineFileSystem.cs | 31 +++ .../Context/IPipelineHookContext.cs | 204 ++---------------- .../Context/IPipelineLogging.cs | 20 ++ .../Context/IPipelineServices.cs | 43 ++++ .../Context/IPipelineTools.cs | 56 +++++ 7 files changed, 238 insertions(+), 192 deletions(-) create mode 100644 src/ModularPipelines/Context/IPipelineEncoding.cs create mode 100644 src/ModularPipelines/Context/IPipelineEnvironment.cs create mode 100644 src/ModularPipelines/Context/IPipelineFileSystem.cs create mode 100644 src/ModularPipelines/Context/IPipelineLogging.cs create mode 100644 src/ModularPipelines/Context/IPipelineServices.cs create mode 100644 src/ModularPipelines/Context/IPipelineTools.cs diff --git a/src/ModularPipelines/Context/IPipelineEncoding.cs b/src/ModularPipelines/Context/IPipelineEncoding.cs new file mode 100644 index 0000000000..9441b55b51 --- /dev/null +++ b/src/ModularPipelines/Context/IPipelineEncoding.cs @@ -0,0 +1,46 @@ +using ModularPipelines.Helpers; + +namespace ModularPipelines.Context; + +/// +/// Provides access to serialization and encoding helpers. +/// +/// +/// This interface groups JSON, XML, YAML serialization and encoding helpers (Hex, Base64, Hasher) +/// for better Interface Segregation. +/// +public interface IPipelineEncoding +{ + /// + /// Gets helpers for converting JSON. + /// + IJson Json { get; } + + /// + /// Gets helpers for convering XML. + /// + IXml Xml { get; } + + /// + /// Gets helpers for convering YAML. + /// + IYaml Yaml { get; } + + /// + /// Gets helpers for converting to and from hex strings. + /// + IHex Hex { get; } + + /// + /// Gets helpers for converting to and from Base64 strings. + /// + IBase64 Base64 { get; } + + /// + /// Gets helpers for hashing data. + /// + /// + /// Supports MD5, SHA1, SHA256, SHA512 hashing algorithms. + /// + IHasher Hasher { get; } +} diff --git a/src/ModularPipelines/Context/IPipelineEnvironment.cs b/src/ModularPipelines/Context/IPipelineEnvironment.cs new file mode 100644 index 0000000000..97f4194a03 --- /dev/null +++ b/src/ModularPipelines/Context/IPipelineEnvironment.cs @@ -0,0 +1,30 @@ +using ModularPipelines.Engine; +using ModularPipelines.Helpers; + +namespace ModularPipelines.Context; + +/// +/// Provides access to environment and build system detection. +/// +/// +/// This interface groups environment context and build system detection helpers +/// for better Interface Segregation. +/// +public interface IPipelineEnvironment +{ + /// + /// Gets helpers for getting information about the current environment. + /// + /// + /// Provides access to OS info, environment variables, working directory, etc. + /// + IEnvironmentContext Environment { get; } + + /// + /// Gets helpers for detecting the current build system. + /// + /// + /// Detects GitHub Actions, Azure DevOps, Jenkins, GitLab CI, etc. + /// + IBuildSystemDetector BuildSystemDetector { get; } +} diff --git a/src/ModularPipelines/Context/IPipelineFileSystem.cs b/src/ModularPipelines/Context/IPipelineFileSystem.cs new file mode 100644 index 0000000000..6e29e171b4 --- /dev/null +++ b/src/ModularPipelines/Context/IPipelineFileSystem.cs @@ -0,0 +1,31 @@ +using ModularPipelines.Helpers; + +namespace ModularPipelines.Context; + +/// +/// Provides access to file system operations. +/// +/// +/// This interface groups file system, zip, and checksum helpers +/// for better Interface Segregation. +/// +public interface IPipelineFileSystem +{ + /// + /// Gets helpers for interacting with the filesystem. + /// + /// + /// Provides file/directory operations with logging and error handling. + /// + IFileSystemContext FileSystem { get; } + + /// + /// Gets helpers for zipping and unzipping files and directories. + /// + IZip Zip { get; } + + /// + /// Gets helpers for checking the Checksum of a file. + /// + IChecksum Checksum { get; } +} diff --git a/src/ModularPipelines/Context/IPipelineHookContext.cs b/src/ModularPipelines/Context/IPipelineHookContext.cs index 8665e05320..c99ce7f4b4 100644 --- a/src/ModularPipelines/Context/IPipelineHookContext.cs +++ b/src/ModularPipelines/Context/IPipelineHookContext.cs @@ -23,199 +23,19 @@ namespace ModularPipelines.Context; /// Extension Pattern: /// Tool integrations (ModularPipelines.Git, ModularPipelines.Docker, etc.) add extension methods /// like context.Git() and context.Docker() that provide strongly-typed APIs for those tools. +/// +/// Interface Segregation: +/// This interface inherits from focused sub-interfaces (IPipelineServices, IPipelineLogging, etc.) +/// allowing consumers to depend on only the subset of functionality they need. /// -public interface IPipelineHookContext +public interface IPipelineHookContext : + IPipelineServices, + IPipelineLogging, + IPipelineTools, + IPipelineEncoding, + IPipelineFileSystem, + IPipelineEnvironment { - #region DependencyInjection - - /// - /// Gets the service provider orchestrating DI within the pipeline. - /// - /// - /// Use the generic Get<T>() method instead of accessing ServiceProvider directly - /// when possible for better type safety. - /// - public IServiceProvider ServiceProvider { get; } - - /// - /// Helper method for retrieving services from the Service Provider. - /// - /// Type to retrieve. - /// The service instance, or null if not registered. - public T? Get(); - - #endregion - - #region Configuration - - /// - /// Gets the configuration powering the pipeline. - /// - /// - /// Configuration is loaded from appsettings.json, environment variables, user secrets, and command line. - /// - public IConfiguration Configuration { get; } - - /// - /// Gets the pipeline's options. - /// - public IOptions PipelineOptions { get; } - - #endregion - - #region Logging - - /// - /// Gets the logger to be used from the pipeline. - /// - /// - /// This logger is module-scoped and will include the module name in log output. - /// - public IModuleLogger Logger { get; } - - #endregion - - #region EnvironmentHelpers - - /// - /// Gets helpers for getting information about the current environment. - /// - /// - /// Provides access to OS info, environment variables, working directory, etc. - /// - public IEnvironmentContext Environment { get; } - - /// - /// Gets helpers for detecting the current build system. - /// - /// - /// Detects GitHub Actions, Azure DevOps, Jenkins, GitLab CI, etc. - /// - public IBuildSystemDetector BuildSystemDetector { get; } - - #endregion - - #region FileSystemHelpers - - /// - /// Gets helpers for interacting with the filesystem. - /// - /// - /// Provides file/directory operations with logging and error handling. - /// - public IFileSystemContext FileSystem { get; } - - /// - /// Gets helpers for zipping and unzipping files and directories. - /// - public IZip Zip { get; } - - /// - /// Gets helpers for checking the Checksum of a file. - /// - IChecksum Checksum { get; } - - #endregion - - #region CommandExecution - - /// - /// Gets helpers for running commands. - /// - /// - /// Provides cross-platform command execution with output capture and logging. - /// - public ICommand Command { get; } - - /// - /// Gets helpers for running powershell. - /// - public IPowershell Powershell { get; } - - /// - /// Gets helpers for executing bash commands. - /// - public IBash Bash { get; } - - #endregion - - #region Serialization - - /// - /// Gets helpers for converting JSON. - /// - public IJson Json { get; } - - /// - /// Gets helpers for convering XML. - /// - public IXml Xml { get; } - - /// - /// Gets helpers for convering YAML. - /// - public IYaml Yaml { get; } - - #endregion - - #region Encoding - - /// - /// Gets helpers for converting to and from hex strings. - /// - public IHex Hex { get; } - - /// - /// Gets helpers for converting to and from Base64 strings. - /// - public IBase64 Base64 { get; } - - #endregion - - #region Security - - /// - /// Gets helpers for hashing data. - /// - /// - /// Supports MD5, SHA1, SHA256, SHA512 hashing algorithms. - /// - public IHasher Hasher { get; } - - #endregion - - #region NetworkHelpers - - /// - /// Gets helpers for sending HTTP requests. - /// - /// - /// Provides a configured HttpClient with retry policies and logging. - /// - public IHttp Http { get; } - - /// - /// Gets helpers for downloading data from the web. - /// - /// - /// Includes progress tracking and verification helpers. - /// - public IDownloader Downloader { get; } - - #endregion - - #region Installation - - /// - /// Gets helpers for installing applications. - /// - /// - /// Supports package managers like Chocolatey, apt, brew, etc. - /// - public IInstaller Installer { get; } - - #endregion - #region Internal /// @@ -240,4 +60,4 @@ public interface IPipelineHookContext internal EngineCancellationToken EngineCancellationToken { get; } #endregion -} \ No newline at end of file +} diff --git a/src/ModularPipelines/Context/IPipelineLogging.cs b/src/ModularPipelines/Context/IPipelineLogging.cs new file mode 100644 index 0000000000..883cf64f2d --- /dev/null +++ b/src/ModularPipelines/Context/IPipelineLogging.cs @@ -0,0 +1,20 @@ +using ModularPipelines.Logging; + +namespace ModularPipelines.Context; + +/// +/// Provides access to logging functionality. +/// +/// +/// This interface groups logging-related members for better Interface Segregation. +/// +public interface IPipelineLogging +{ + /// + /// Gets the logger to be used from the pipeline. + /// + /// + /// This logger is module-scoped and will include the module name in log output. + /// + IModuleLogger Logger { get; } +} diff --git a/src/ModularPipelines/Context/IPipelineServices.cs b/src/ModularPipelines/Context/IPipelineServices.cs new file mode 100644 index 0000000000..5fd70978c8 --- /dev/null +++ b/src/ModularPipelines/Context/IPipelineServices.cs @@ -0,0 +1,43 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Options; +using ModularPipelines.Options; + +namespace ModularPipelines.Context; + +/// +/// Provides access to dependency injection and configuration services. +/// +/// +/// This interface groups DI and configuration-related members for better Interface Segregation. +/// +public interface IPipelineServices +{ + /// + /// Gets the service provider orchestrating DI within the pipeline. + /// + /// + /// Use the generic Get<T>() method instead of accessing ServiceProvider directly + /// when possible for better type safety. + /// + IServiceProvider ServiceProvider { get; } + + /// + /// Helper method for retrieving services from the Service Provider. + /// + /// Type to retrieve. + /// The service instance, or null if not registered. + T? Get(); + + /// + /// Gets the configuration powering the pipeline. + /// + /// + /// Configuration is loaded from appsettings.json, environment variables, user secrets, and command line. + /// + IConfiguration Configuration { get; } + + /// + /// Gets the pipeline's options. + /// + IOptions PipelineOptions { get; } +} diff --git a/src/ModularPipelines/Context/IPipelineTools.cs b/src/ModularPipelines/Context/IPipelineTools.cs new file mode 100644 index 0000000000..697f02a0f8 --- /dev/null +++ b/src/ModularPipelines/Context/IPipelineTools.cs @@ -0,0 +1,56 @@ +using ModularPipelines.Helpers; +using ModularPipelines.Http; + +namespace ModularPipelines.Context; + +/// +/// Provides access to command execution and tool helpers. +/// +/// +/// This interface groups command execution, HTTP, download, and installation helpers +/// for better Interface Segregation. +/// +public interface IPipelineTools +{ + /// + /// Gets helpers for running commands. + /// + /// + /// Provides cross-platform command execution with output capture and logging. + /// + ICommand Command { get; } + + /// + /// Gets helpers for running powershell. + /// + IPowershell Powershell { get; } + + /// + /// Gets helpers for executing bash commands. + /// + IBash Bash { get; } + + /// + /// Gets helpers for sending HTTP requests. + /// + /// + /// Provides a configured HttpClient with retry policies and logging. + /// + IHttp Http { get; } + + /// + /// Gets helpers for downloading data from the web. + /// + /// + /// Includes progress tracking and verification helpers. + /// + IDownloader Downloader { get; } + + /// + /// Gets helpers for installing applications. + /// + /// + /// Supports package managers like Chocolatey, apt, brew, etc. + /// + IInstaller Installer { get; } +}