fix: forward template cancellation tokens#468
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Updates the Template source generator to correctly forward CancellationToken to synchronous hooks/steps when an async wrapper (ExecuteAsync) is generated, and adds TinyBDD scenarios to cover the new emission paths and a missing-context diagnostic (per #413 coverage goals).
Changes:
- Forward
CancellationTokento sync template hooks/steps inside the generated async wrapper when the target member declares aCancellationTokenparameter. - Add generator tests ensuring forwarding occurs across before/step/after/on-error paths.
- Add generator test coverage for a step method that lacks a required context parameter (PKTMP004).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/PatternKit.Generators/TemplateGenerator.cs |
Updates async wrapper emission to pass ct to sync hooks/steps when applicable. |
test/PatternKit.Generators.Tests/TemplateGeneratorTests.cs |
Adds TinyBDD scenarios covering cancellation token forwarding and missing-context diagnostics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var hasCt = hook.Method.Parameters.Any(IsCancellationToken); | ||
| var args = hasCt ? "ctx, ct" : "ctx"; | ||
| sb.AppendLine($" {hook.Method.Name}({args});"); |
Test Results 12 files 12 suites 10m 48s ⏱️ Results for commit 92984d5. ♻️ This comment has been updated with latest results. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #468 +/- ##
==========================================
+ Coverage 97.03% 97.17% +0.13%
==========================================
Files 579 579
Lines 47168 47180 +12
Branches 3088 6768 +3680
==========================================
+ Hits 45768 45845 +77
+ Misses 1400 1335 -65
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:
|
🔍 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. |
4c7dbbd to
92984d5
Compare
Code Coverage |
Refs #413.
Summary
Validation