Scan all solution projects by default#32
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request updates the dependency injection generator to scan all solution projects by default and adds a new test verifying this behavior.
- Changed the assembly resolution logic to include all solution assemblies when assemblyOfType is null
- Added a new test to confirm that services from referenced compilations are registered correctly
- Updated the test compilation overload to support referenced compilations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ServiceScan.SourceGenerator/DependencyInjectionGenerator.FilterTypes.cs | Updated assembly scanning logic to use all solution assemblies and refactored type retrieval |
| ServiceScan.SourceGenerator.Tests/AddServicesTests.cs | Added a new test to verify service registration from referenced compilations and updated compilation helper overload |
|
|
||
| var assemblies = assemblyOfType is not null | ||
| ? [assemblyOfType.ContainingAssembly] | ||
| : GetSolutionAssemblies(compilation); |
There was a problem hiding this comment.
Consider adding a comment to explain that GetSolutionAssemblies returns all solution assemblies when assemblyOfType is null, providing context on why scanning all referenced compilations is desired.
| } | ||
|
|
||
| foreach (var type in GetTypesFromAssembly(assembly)) | ||
| foreach (var type in assemblies.SelectMany(GetTypesFromAssembly)) |
There was a problem hiding this comment.
[nitpick] Review the potential performance impact when scanning all solution assemblies. If the number of referenced compilations is large, consider filtering to include only assembly types that are relevant for dependency injection.
Related to #31 .
Alternative suggestion to #28 .