Add MSGH008 return type validation for MethodBodyGenerator#92
Merged
dex3r merged 1 commit intofeature/metehod_templatefrom Mar 25, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix WrongReturnType tests to ensure they pass
Add MSGH008 return type validation for MethodBodyGenerator
Mar 25, 2026
dex3r
approved these changes
Mar 25, 2026
Report MSGH008 diagnostic when a [MethodBodyGenerator] method's return type is neither IMethodBodyGenerator (fluent pattern) nor the exact return type of the target partial method (simple pattern). The diagnostic location highlights only the return type keyword in the method declaration. Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com> Agent-Logs-Url: https://github.com/dex3r/EasySourceGenerators/sessions/8515330e-e7a2-438c-8d6a-d6c01baa8bbc
0f95181 to
c4fdc7b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes missing reporting of the already-defined MSGH008 diagnostic by adding return-type validation for [MethodBodyGenerator] methods during generation target collection, ensuring invalid generator return types are rejected early and highlighted precisely at the return-type syntax.
Changes:
- Validate generator method return type after resolving the target partial method.
- Report MSGH008 when the generator return type is neither
IMethodBodyGenerator(fluent pattern) nor the target partial method’s return type (simple pattern). - Use the generator method’s return type syntax location so the diagnostic highlights only the return type token.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
[MethodBodyGenerator]methods with invalid return types were silently accepted. The defined MSGH008 diagnostic was never reported.GeneratesMethodGenerationTargetCollector.Collect()after partial method resolution: generator return type must be eitherIMethodBodyGenerator(fluent pattern) or match the target partial method's return type (simple pattern)generatorMethod.ReturnType.GetLocation()to highlight exactly the return type tokenAll 3
WrongReturnTypetests now pass. Full suite green with no regressions.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.