Feature Modules Refactoring and API Improvements#16
Merged
Conversation
Refactored the feature module system to use `IHostApplicationBuilder` instead of `WebApplicationBuilder` for improved compatibility with modern ASP.NET Core applications. Simplified module discovery and registration by moving logic from `ModuleUtilities` to `IHostApplicationBuilderExtensions`. Removed the `ModuleContext` and `ModuleUtilities` classes as they are no longer needed. Updated `.editorconfig` to adjust diagnostic rule severities. Incremented the `VersionPrefix` in the project file to `1.4.0`. Improved logging to include module version information during registration.
The `ModuleInfo` property in the `FeatureModule` class was updated from a nullable type (`IModuleInfo?`) to a non-nullable type (`IModuleInfo`). This change enforces stricter type safety by ensuring that the property always contains a valid `IModuleInfo` instance. The property is initialized with a `FeatureModuleInfo` instance, guaranteeing it is never `null`.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the feature modules infrastructure to consolidate module types and simplify the API. The main changes include merging IWebFeatureModule into IFeatureModule, removing the ModuleContext class, and renaming the extension class from WebApplicationBuilderExtensions to IHostApplicationBuilderExtensions.
- Unified module interfaces:
IWebFeatureModulenow extendsIFeatureModuleinstead of being a separate parallel interface - Changed
RegisterModulesignature to useIHostApplicationBuilderdirectly instead of a customModuleContext - Made
ModuleInfoproperty non-nullable with a default version fallback
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ModuleUtilities.cs | Deleted - functionality moved inline to IHostApplicationBuilderExtensions.cs |
| ModuleContext.cs | Deleted - replaced with direct use of IHostApplicationBuilder |
| Infinity.Toolkit.FeatureModules.csproj | Version bump from 1.3.0 to 1.4.0 |
| IModuleInfo.cs | Added default version "1.0.0" when version is null |
| IHostApplicationBuilderExtensions.cs | Renamed class, changed extension methods to accept IHostApplicationBuilder, consolidated module discovery logic, unified module registration |
| IFeatureModule.cs | Changed ModuleInfo to non-nullable, updated RegisterModule signature, made IWebFeatureModule extend IFeatureModule |
| FeatureModule.cs | Updated to match new interface signatures |
| Infinity.Toolkit.Azure.csproj | Version bump from 1.0.1 to 1.0.2 |
| ConfigurationBuilderExtensions.cs | Improved error handling with early validation and better warning messages |
| FeatureModulesSample/FeatureModule.cs | Removed unnecessary RegisterModule override |
| .editorconfig | Disabled CS1587 diagnostic |
Comments suppressed due to low confidence (1)
src/Infinity.Toolkit.FeatureModules/IHostApplicationBuilderExtensions.cs:100
- This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant refactoring and improvements to the feature modules infrastructure, focusing on simplifying module registration, improving type safety, and modernizing extension points. The changes also include minor updates to diagnostics configuration and versioning.
Feature Modules Refactoring and API Improvements:
ModuleInfo, enforce non-nullableIModuleInfo, and change the module registration pattern from returning aModuleContextto a void method that takes anIHostApplicationBuilder. This simplifies module implementation and aligns with modern DI patterns. (src/Infinity.Toolkit.FeatureModules/IFeatureModule.cs,src/Infinity.Toolkit.FeatureModules/FeatureModule.cs,src/Infinity.Toolkit.FeatureModules/IModuleInfo.cs,samples/FeatureModulesSample/FeatureModule.cs, [1] [2] [3] [4] [5] [6] [7]ModuleContextrecord and theModuleUtilitieshelper, consolidating module discovery and registration logic into the newIHostApplicationBuilderExtensionsclass. (src/Infinity.Toolkit.FeatureModules/ModuleContext.cs,src/Infinity.Toolkit.FeatureModules/ModuleUtilities.cs, [1] [2]WebApplicationBuilderExtensionstoIHostApplicationBuilderExtensions, updating all related methods to useIHostApplicationBuilderinstead ofWebApplicationBuilder. This provides greater flexibility and compatibility with generic hosting scenarios. (src/Infinity.Toolkit.FeatureModules/IHostApplicationBuilderExtensions.cs, [1] [2] [3] [4] [5] [6]src/Infinity.Toolkit.FeatureModules/IHostApplicationBuilderExtensions.cs, src/Infinity.Toolkit.FeatureModules/IHostApplicationBuilderExtensions.csL63-R118)Azure App Configuration Improvements:
src/Infinity.Toolkit.Azure/Configuration/ConfigurationBuilderExtensions.cs, [1] [2]Diagnostics and Versioning:
.editorconfigto suppress CS1587 warnings and incremented the version numbers for both the Azure and FeatureModules packages. (.editorconfig,src/Infinity.Toolkit.Azure/Infinity.Toolkit.Azure.csproj,src/Infinity.Toolkit.FeatureModules/Infinity.Toolkit.FeatureModules.csproj, [1] [2] [3]