Skip to content

Comments

Scan all solution projects by default#32

Merged
Dreamescaper merged 2 commits intomainfrom
scan-all-projects-from-sln
May 24, 2025
Merged

Scan all solution projects by default#32
Dreamescaper merged 2 commits intomainfrom
scan-all-projects-from-sln

Conversation

@Dreamescaper
Copy link
Owner

@Dreamescaper Dreamescaper commented May 20, 2025

Related to #31 .
Alternative suggestion to #28 .

@Dreamescaper Dreamescaper marked this pull request as ready for review May 20, 2025 19:29
@Dreamescaper Dreamescaper requested a review from Copilot May 20, 2025 19:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
}

foreach (var type in GetTypesFromAssembly(assembly))
foreach (var type in assemblies.SelectMany(GetTypesFromAssembly))
Copy link

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
@Dreamescaper Dreamescaper merged commit 94b5379 into main May 24, 2025
1 check passed
@Dreamescaper Dreamescaper deleted the scan-all-projects-from-sln branch May 24, 2025 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant