Mark generated source as auto-generated and suppress warnings in .g.cs output#51
Merged
Merged
Conversation
Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Suppress common warnings in generated code files
Mark generated source as auto-generated and suppress warnings in Mar 4, 2026
.g.cs output
dex3r
approved these changes
Mar 4, 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
Updates the GeneratesMethod source generator output to be clearly identified as generated code and to suppress compiler warnings in emitted .g.cs files, improving build signal quality and traceability of generated artifacts.
Changes:
- Adds a standard generated-file preamble (
// <auto-generated/>, generator + target method attribution, and#pragma warning disable) to generated method sources. - Extends the test helper to support reading raw generated output vs. preamble-stripped output for stable existing assertions.
- Adds a targeted test asserting the generated preamble exists in produced output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| EasySourceGenerators.Tests/GeneratedCodeTestHelper.cs | Adds raw read + preamble stripping to keep existing exact generated-code assertions stable. |
| EasySourceGenerators.Tests/BoolSwitchKeyTests.cs | Adds an assertion-focused test validating the new generated-file preamble. |
| EasySourceGenerators.Generators/GeneratesMethodPatternSourceBuilder.cs | Emits auto-generated marker, attribution, and warning suppression at the top of generated sources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dex3r
approved these changes
Mar 4, 2026
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.
Generated
.g.csfiles were emitted without an auto-generated marker and could surface compiler warnings from generated code. This updates emitted source to include standard generated-file metadata and warning suppression, plus attribution to the generator and target method.Generated file preamble
// <auto-generated/>#pragma warning disableGeneratesMethodPatternSourceBuilder.AppendNamespaceAndTypeHeader(...)so it applies consistently across simple, switch, and fluent generation paths.Generator attribution in output
EasySourceGenerators.Generators.GeneratesMethodGeneratorGetBoolLabel)Tests updated with focused coverage
GeneratedCodeTestHelperwith:ReadGeneratedCodeRaw(...)for header-level assertionsReadGeneratedCode(...)to keep existing exact-content tests stable.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.