Skip to content

Comments

Fix return type diagnostic conditions#30

Merged
Dreamescaper merged 2 commits intomainfrom
fix-return-type-diagnostic
May 19, 2025
Merged

Fix return type diagnostic conditions#30
Dreamescaper merged 2 commits intomainfrom
fix-return-type-diagnostic

Conversation

@Dreamescaper
Copy link
Owner

No description provided.

@Dreamescaper Dreamescaper requested a review from Copilot May 19, 2025 11:13
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 updates the return-type validation for CustomHandler methods by broadening the condition and aligning the diagnostic message.

  • Refactored the diagnostic message to reference the “first parameter” instead of “‘this’ parameter”
  • Removed the extension-method-only guard in the return-type check
  • Aligned the generator logic to always validate non-void return types against the first parameter

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
ServiceScan.SourceGenerator/DiagnosticDescriptors.cs Updated the WrongReturnTypeForCustomHandler message to refer to “first parameter type.”
ServiceScan.SourceGenerator/DependencyInjectionGenerator.ParseMethodModel.cs Removed the method.IsExtensionMethod check so the return-type diagnostic applies universally.
Comments suppressed due to low confidence (3)

ServiceScan.SourceGenerator/DiagnosticDescriptors.cs:58

  • [nitpick] The diagnostic message could be more precise by saying “type of its first parameter,” for example: "Method with CustomHandler must return void or the type of its first parameter".
"Method with CustomHandler must return void or first parameter type",

ServiceScan.SourceGenerator/DependencyInjectionGenerator.ParseMethodModel.cs:87

  • Add unit tests for CustomHandler methods to verify behavior both when they are extension methods and when they are not, ensuring the new return-type logic works as intended.
if (!method.ReturnsVoid &&

ServiceScan.SourceGenerator/DependencyInjectionGenerator.ParseMethodModel.cs:87

  • Dropping the IsExtensionMethod guard makes this check fire on all methods, which may incorrectly flag non-extension CustomHandler methods. Consider scoping it back to extension methods or explicitly attributed handlers.
if (!method.ReturnsVoid &&

@Dreamescaper Dreamescaper merged commit 2006025 into main May 19, 2025
1 check passed
@Dreamescaper Dreamescaper deleted the fix-return-type-diagnostic branch May 19, 2025 11:16
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