test: harden composer generator coverage#481
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
731aa6e to
2ff3c98
Compare
There was a problem hiding this comment.
Pull request overview
This PR hardens the Composer source-generator’s coverage by adding additional Roslyn-based tests, and aligns the Composer attribute/docs with updated async-generation configuration semantics.
Changes:
- Added new Composer generator tests covering explicit async-disable diagnostics, deterministic ordering with ignored steps, struct async terminals without CancellationToken, and invalid “next” signatures.
- Changed
ComposerAttribute.GenerateAsyncfrombool?tobooland updated its inline documentation. - Reformatted/updated the Composer generator documentation, including the
GenerateAsyncattribute table entry.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/PatternKit.Generators.Tests/ComposerGeneratorTests.cs | Adds new coverage scenarios for async enablement, ordering/ignore behavior, struct async terminal shape, and invalid signatures. |
| src/PatternKit.Generators.Abstractions/Composer/ComposerAttribute.cs | Updates async-generation configuration surface (GenerateAsync) and XML docs. |
| docs/generators/composer.md | Updates Composer generator documentation formatting and GenerateAsync attribute documentation. |
Comments suppressed due to low confidence (4)
docs/generators/composer.md:93
- The async step signature shown here implies
CancellationTokenis required, but the generator accepts async steps with only(TIn input, Func<TIn, ValueTask<TOut>> next)(no warning/diagnostic is emitted when the token is omitted). The docs should reflect thatCancellationTokenis optional.
### Async Steps
```csharp
ValueTask<TOut> StepNameAsync(TIn input, Func<TIn, ValueTask<TOut>> next, CancellationToken ct)
input: The pipeline input (notinfor async)next: Async delegate to call the next stepct: CancellationToken for cooperative cancellation
**docs/generators/composer.md:107**
* The async terminal signature shown here implies `CancellationToken` is required, but the generator accepts async terminals with only a single input parameter (and does not warn/diagnose when `CancellationToken` is omitted). The docs should reflect the optional token.
Async Terminal
ValueTask<TOut> TerminalNameAsync(TIn input, CancellationToken ct)**docs/generators/composer.md:210**
* PKCOM009 is documented as "Async method missing CancellationToken parameter", but the current generator only reports PKCOM009 when a CancellationToken-like parameter is present with the wrong type (it does not warn when the token is omitted). Update the description to match the actual behavior.
| PKCOM008 | Error | Async step detected but async generation disabled |
| PKCOM009 | Warning | Async method missing CancellationToken parameter |
**docs/generators/composer.md:5**
* This markdown file appears to have been committed with CRLF line endings (visible as `\r` in the rendered diff/tool output), which violates the repo-wide `.editorconfig` setting `end_of_line = lf`. Please normalize this file back to LF-only to avoid churn and formatting/tooling issues.
Composer Generator
Overview
The Composer Generator creates deterministic pipeline compositions from ordered step methods. It eliminates boilerplate by automatically generating Invoke and InvokeAsync methods that compose your pipeline steps in order, wrapping each step around the next until reaching a terminal handler.
</details>
---
💡 <a href="/JerrettDavis/PatternKit/new/main?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
| /// Gets or sets whether to generate async methods. | ||
| /// When null (default), async generation is inferred from the presence of async steps or terminal. | ||
| /// Note: Nullable bool in attributes is non-standard but supported by C#. | ||
| /// Set to true/false explicitly to control async generation, or leave unset for inference. | ||
| /// When omitted, async generation is inferred from the presence of async steps or terminal. | ||
| /// Set to true/false explicitly to control async generation. | ||
| /// </summary> | ||
| public bool? GenerateAsync { get; set; } | ||
| public bool GenerateAsync { get; set; } |
| /// <summary> | ||
| /// Gets or sets whether to generate async methods. | ||
| /// When null (default), async generation is inferred from the presence of async steps or terminal. | ||
| /// Note: Nullable bool in attributes is non-standard but supported by C#. | ||
| /// Set to true/false explicitly to control async generation, or leave unset for inference. | ||
| /// When omitted, async generation is inferred from the presence of async steps or terminal. | ||
| /// Set to true/false explicitly to control async generation. | ||
| /// </summary> |
| var comp = RoslynTestHelpers.CreateCompilation(source, nameof(InvalidStep_WithFunctionPointerNext_ReportsDiagnostic)); | ||
| var gen = new ComposerGenerator(); |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
Code Coverage |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #481 +/- ##
==========================================
+ Coverage 97.39% 97.50% +0.11%
==========================================
Files 579 579
Lines 47161 47161
Branches 3070 5138 +2068
==========================================
+ Hits 45931 45983 +52
+ Misses 1230 1178 -52
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Test Results 12 files 12 suites 11m 5s ⏱️ Results for commit 2ff3c98. |
No description provided.