test: harden generator edge coverage#465
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
This PR strengthens PatternKit’s source-generator test coverage (per #413) and fixes two generator edge-case emissions: default literal formatting in DecoratorGenerator and ValueTask<T> projector helper signatures in BuilderGenerator (avoiding nested ValueTask<ValueTask<T>>).
Changes:
- Added TinyBDD scenarios covering additional generator diagnostics/emission branches for Proxy, Decorator, Composer, and Builder generators.
- Updated
DecoratorGenerator.FormatDefaultValueto preserve float/double/decimal default literals (with suffixes) in generated signatures. - Updated
BuilderGeneratorstate-projection builder-method helper emission soValueTask<T>projectors don’t produce nestedValueTaskreturn types; simplifiedIsValueTaskdetection.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Generators.Tests/ProxyGeneratorTests.cs | Adds coverage for string/numeric/char default literal formatting branches in proxy generation. |
| test/PatternKit.Generators.Tests/DecoratorGeneratorTests.cs | Adds coverage asserting decorator generation preserves primitive/string/enum-cast default literals. |
| test/PatternKit.Generators.Tests/ComposerGeneratorTests.cs | Adds a diagnostic scenario for invalid step “next” parameter type. |
| test/PatternKit.Generators.Tests/BuilderGeneratorTests.cs | Adds diagnostic coverage and a regression test for ValueTask<T> projector build helper paths. |
| src/PatternKit.Generators/DecoratorGenerator.cs | Adjusts default literal formatting for float/double/decimal optional parameters. |
| src/PatternKit.Generators/Builders/BuilderGenerator.cs | Fixes async helper return types for ValueTask<T> projectors and updates IsValueTask detection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var value = param.ExplicitDefaultValue; | ||
| return value switch | ||
| { | ||
| float f => f.ToString(System.Globalization.CultureInfo.InvariantCulture) + "f", | ||
| double d => d.ToString(System.Globalization.CultureInfo.InvariantCulture) + "d", | ||
| decimal m => m.ToString(System.Globalization.CultureInfo.InvariantCulture) + "m", | ||
| _ => Microsoft.CodeAnalysis.CSharp.SymbolDisplay.FormatPrimitive(value, quoteStrings: true, useHexadecimalNumbers: false) | ||
| ?? "default" | ||
| }; |
Code Coverage |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #465 +/- ##
==========================================
+ Coverage 96.95% 97.11% +0.16%
==========================================
Files 579 579
Lines 47147 47156 +9
Branches 3095 6210 +3115
==========================================
+ Hits 45711 45796 +85
+ Misses 1436 1360 -76
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 12m 8s ⏱️ Results for commit 1032d61. |
🔍 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. |
Refs #413.
Summary
ValueTask<T>projectors so helpers do not return nestedValueTask<ValueTask<T>>Validation
dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj --configuration Release -p:TestTfmsInParallel=false --filter "FullyQualifiedName~ProxyGeneratorTests|FullyQualifiedName~DecoratorGeneratorTests|FullyQualifiedName~ComposerGeneratorTests|FullyQualifiedName~BuilderGeneratorTests"dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj --configuration Release -p:TestTfmsInParallel=false --collect:"XPlat Code Coverage" --results-directory TestResults-generators-current -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura