Skip to content

Conversation

@Dreamescaper
Copy link
Owner

No description provided.

@Dreamescaper Dreamescaper requested a review from Copilot August 11, 2025 21:08

This comment was marked as outdated.

@Dreamescaper Dreamescaper requested a review from Copilot August 19, 2025 11:11
@Dreamescaper Dreamescaper marked this pull request as ready for review August 19, 2025 11:11
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 PR extends the CustomHandler functionality to allow invoking static methods from matched types in addition to generic methods in the current type. The implementation adds support for detecting whether a custom handler should be a method in the current class or a static method in matched types.

  • Added CustomHandlerType enum to distinguish between method types (current class method vs. type method)
  • Updated attribute parsing to detect and handle both custom handler types
  • Modified code generation to invoke static methods on matched types when appropriate

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
version.json Bumps version from 2.2 to 2.3
ServiceRegistrationModel.cs Adds CustomHandlerType and TypeName properties to CustomHandlerModel
AttributeModel.cs Adds CustomHandlerType enum and updates attribute parsing logic
GenerateAttributeInfo.cs Updates documentation comments for better clarity
DiagnosticDescriptors.cs Removes unused CustomHandlerMethodNotFound diagnostic
DependencyInjectionGenerator.cs Updates code generation to handle both handler types
DependencyInjectionGenerator.ParseMethodModel.cs Modifies validation logic for custom handlers
DependencyInjectionGenerator.FindServicesToRegister.cs Updates custom handler creation with new properties
DependencyInjectionGenerator.FilterTypes.cs Allows static types for TypeMethod custom handlers
CustomHandlerTests.cs Adds comprehensive tests for static method handlers
README.md Updates documentation to reflect new CustomHandler capabilities

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (customHandlerMethod.TypeParameters.Length > 1
&& customHandlerMethod.TypeParameters.Length != attribute.AssignableToTypeParametersCount + 1)
if (customHandlerMethod != null)
{
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The validation logic only applies to Method type custom handlers but doesn't validate TypeMethod handlers. Consider adding validation for static methods in target types to ensure they exist and have correct signatures.

Copilot uses AI. Check for mistakes.
@Dreamescaper Dreamescaper merged commit 9fadc54 into main Aug 19, 2025
1 check passed
@Dreamescaper Dreamescaper deleted the allow-custom-handler-to-invoke-static-methods-from-type branch August 19, 2025 11:38
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.

2 participants