Add AssemblyNameFilter to allow to scan multiple assemblies#34
Merged
Dreamescaper merged 4 commits intomainfrom May 31, 2025
Merged
Add AssemblyNameFilter to allow to scan multiple assemblies#34Dreamescaper merged 4 commits intomainfrom
Dreamescaper merged 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds a new AssemblyNameFilter option to the GenerateServiceRegistrations attribute, allowing users to limit which assemblies are scanned by wildcard patterns.
- Introduces
AssemblyNameFiltertoAttributeModeland the source generator attribute class. - Implements
GetAssembliesToScanto apply wildcard (and, per docs, comma-separated) filters. - Updates README and tests to demonstrate filtering by assembly name.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ServiceScan.SourceGenerator/Model/AttributeModel.cs | Added AssemblyNameFilter parameter and trimming logic. |
| ServiceScan.SourceGenerator/GenerateAttributeSource.cs | Defined new AssemblyNameFilter property with XML docs. |
| ServiceScan.SourceGenerator/DependencyInjectionGenerator.FilterTypes.cs | Factored out GetAssembliesToScan and applied name filters. |
| ServiceScan.SourceGenerator.Tests/AddServicesTests.cs | Renamed test and added usage example for AssemblyNameFilter. |
| README.md | Documented the AssemblyNameFilter option in the attribute reference. |
Comments suppressed due to low confidence (4)
README.md:143
- Documentation claims support for comma-separated filters, but the code never splits on commas. Either implement comma-splitting logic in
GetAssembliesToScanor update the docs to remove that claim.
| **AssemblyNameFilter** | Set this value to filter scanned assemblies by assembly name. It allows to apply an attribute to multiple assemblies. For example, this allows to scan all assemblies from your solution. You can use '*' wildcards. You can also use ',' to separate multiple filters. *Be careful to include limited amount of assemblies, as it can affect build and editor performance.* |
README.md:143
- [nitpick] Escaping the wildcard character with a backslash (
\*) may render incorrectly in markdown. Consider wrapping*in backticks or using a code span instead of a backslash.
| **AssemblyNameFilter** | Set this value to filter scanned assemblies by assembly name. It allows to apply an attribute to multiple assemblies. For example, this allows to scan all assemblies from your solution. You can use '*' wildcards. You can also use ',' to separate multiple filters. *Be careful to include limited amount of assemblies, as it can affect build and editor performance.* |
ServiceScan.SourceGenerator.Tests/AddServicesTests.cs:63
- [nitpick] The test name is quite long and repetitive. Consider renaming to
AddServicesWithAssemblyNameFilterfor clarity and brevity.
public void AddServicesFromReferencedAssembliesByAssemblyNameFilter()
ServiceScan.SourceGenerator.Tests/AddServicesTests.cs:62
- There are no tests covering multiple comma-separated filters. Consider adding a test case to verify that comma-separated patterns are both parsed and applied correctly.
[Fact]
ServiceScan.SourceGenerator/DependencyInjectionGenerator.FilterTypes.cs
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for filtering scanned assemblies by name (AssemblyNameFilter) and enforces exclusivity with the existing FromAssemblyOf option.
- Introduce
AssemblyNameFilterinAttributeModel, generator, tests, and docs - Add diagnostic and runtime check to forbid using both
FromAssemblyOfandAssemblyNameFilter - Refactor type‐filtering logic into
GetAssembliesToScanto apply name‐based patterns
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| ServiceScan.SourceGenerator/Model/AttributeModel.cs | Added AssemblyNameFilter property and null/whitespace handling |
| ServiceScan.SourceGenerator/GenerateAttributeSource.cs | Documented new AssemblyNameFilter attribute and updated default behavior comment |
| ServiceScan.SourceGenerator/DiagnosticDescriptors.cs | Introduced CantUseBothFromAssemblyOfAndAssemblyNameFilter diagnostic |
| ServiceScan.SourceGenerator/DependencyInjectionGenerator.ParseMethodModel.cs | Enforce exclusivity of FromAssemblyOf vs AssemblyNameFilter in parsing |
| ServiceScan.SourceGenerator/DependencyInjectionGenerator.FilterTypes.cs | Extracted GetAssembliesToScan method to apply the new filter or fallback logic |
| ServiceScan.SourceGenerator.Tests/AddServicesTests.cs | Updated test to use AssemblyNameFilter scenario |
| README.md | Updated table with new AssemblyNameFilter description and revised default for FromAssemblyOf |
Comments suppressed due to low confidence (1)
ServiceScan.SourceGenerator.Tests/AddServicesTests.cs:86
- Add tests covering multiple patterns in
AssemblyNameFilter(e.g. comma-separated values) to verify the implementation supports all documented scenarios.
var attribute = """[GenerateServiceRegistrations(AssignableTo = typeof(Core.IService), Lifetime = ServiceLifetime.Scoped, AssemblyNameFilter="MyProduct.*")]""";
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.
#31
Adds a new AssemblyNameFilter option to the GenerateServiceRegistrations attribute, allowing users to scan multiple assemblies, and limit which assemblies are scanned by wildcard patterns.