Enforce MSGH007 for simple generators with parameters and finish SimpleMethodWithParameter test#82
Merged
dex3r merged 2 commits intobugfix/simple_method_with_parameterfrom Mar 9, 2026
Conversation
Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Finish SimpleMethodWithParameterTests_Test and modify generators
Enforce MSGH007 for simple generators with parameters and finish SimpleMethodWithParameter test
Mar 7, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enforces that “simple pattern” [GeneratesMethod] generators (compile-time executors) cannot declare runtime parameters, and completes the previously unfinished test case to validate both the diagnostic (MSGH007) and its source location span.
Changes:
- Added a validation step in the simple-pattern generation path to emit
MSGH007when a generator method declares one or more parameters, and to skip generation for that invalid group. - Implemented signature-scoped diagnostic location computation (start of method declaration through the end of the parameter list).
- Finished
SimpleMethodWithParameterTests_Testto assertMSGH007is emitted and that the highlighted span includes the signature but not the method body.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| EasySourceGenerators.Generators/GeneratesMethodGenerationPipeline.cs | Adds simple-pattern parameter validation and signature-scoped diagnostic locations for MSGH007. |
| EasySourceGenerators.GeneratorTests/SimpleMethodWithParameter.cs | Completes the test to verify MSGH007 emission and correct diagnostic span targeting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dex3r
added a commit
that referenced
this pull request
Mar 9, 2026
* Added SimpleMethodWithParameterTest * WIP * Enforce MSGH007 for simple generators with parameters and finish SimpleMethodWithParameter test (#82) * Initial plan * Add MSGH007 validation for simple generators with parameters Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com> --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com>
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.
Simple
[GeneratesMethod]generators are compile-time executors and must not accept runtime parameters, but this path was not validated and the existing test was unfinished. This PR completes the test and adds a dedicated validation path that emitsMSGH007on the generator method signature (not method body).Completed coverage for the unfinished scenario
SimpleMethodWithParameterTests_Testto assert:MSGH007is emitted.Added simple-pattern parameter validation in generation pipeline
GeneratesMethodGenerationPipeline, for non-switch and non-fluent groups:CannotUseRuntimeParameterForCompileTimeGeneratorError(MSGH007),Diagnostic location is now signature-scoped
method start -> end of parameter list) so errors target declaration signature rather than body content.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.