Skip to content

test: harden memento generator coverage#467

Merged
JerrettDavis merged 1 commit into
mainfrom
coverage/harden-generator-gaps-413-c
May 31, 2026
Merged

test: harden memento generator coverage#467
JerrettDavis merged 1 commit into
mainfrom
coverage/harden-generator-gaps-413-c

Conversation

@JerrettDavis

@JerrettDavis JerrettDavis commented May 31, 2026

Copy link
Copy Markdown
Owner

Refs #413.

Summary

  • add TinyBDD scenarios for explicit memento capture strategies, read-only state, and record restore fallback shapes
  • fix empty mementos so they do not emit invalid private parameterless struct constructors
  • fix record restore fallback to call an available public constructor before object initialization
  • add a decorator inaccessible property diagnostic scenario

Validation

  • 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
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj --configuration Release -p:TestTfmsInParallel=false --no-restore
  • dotnet test test\PatternKit.Examples.Tests\PatternKit.Examples.Tests.csproj --configuration Release -p:TestTfmsInParallel=false --no-restore
  • dotnet test test\PatternKit.Hosting.Extensions.Tests\PatternKit.Hosting.Extensions.Tests.csproj --configuration Release -p:TestTfmsInParallel=false --no-restore

Note: dotnet test PatternKit.slnx --configuration Release -p:TestTfmsInParallel=false --no-restore timed out locally after 10 minutes before returning a failure summary.

Copilot AI review requested due to automatic review settings May 31, 2026 03:34
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens MementoGenerator coverage by adding TinyBDD scenarios that exercise explicit capture strategies, read-only state, empty/record fallbacks, and ignored primary-constructor parameters, while fixing two emission bugs (invalid private parameterless struct constructor for empty mementos and missing constructor arguments on record restore fallback). Also adds a scenario covering the PKDEC004 inaccessible-property diagnostic in DecoratorGenerator.

Changes:

  • Skip emitting the private memento struct constructor when there are no captured members.
  • For record restore fallback, invoke the smallest public constructor with default! arguments before the object initializer.
  • Add MementoGenerator/DecoratorGenerator test scenarios for the newly exercised branches and a missing diagnostic.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/PatternKit.Generators/MementoGenerator.cs Guards the empty-member constructor and introduces AppendRecordFallbackConstructor for record fallback restore.
test/PatternKit.Generators.Tests/MementoGeneratorTests.cs Adds scenarios for explicit strategies, record-without-primary-ctor, read-only members, empty record, and ignored primary-ctor member.
test/PatternKit.Generators.Tests/DecoratorGeneratorTests.cs Adds a scenario asserting PKDEC004 fires for private protected abstract properties while public members still generate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +493 to +509
private static void AppendRecordFallbackConstructor(StringBuilder sb, TypeInfo typeInfo)
{
var fallbackCtor = typeInfo.TypeSymbol.Constructors
.Where(c => !c.IsStatic && c.DeclaredAccessibility == Accessibility.Public)
.OrderBy(c => c.Parameters.Length)
.FirstOrDefault();

if (fallbackCtor is null || fallbackCtor.Parameters.Length == 0)
{
sb.AppendLine("()");
return;
}

sb.Append("(");
sb.Append(string.Join(", ", fallbackCtor.Parameters.Select(_ => "default!")));
sb.AppendLine(")");
}
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    12 files      12 suites   11m 0s ⏱️
 3 979 tests  3 979 ✅ 0 💤 0 ❌
12 368 runs  12 368 ✅ 0 💤 0 ❌

Results for commit 4abaf37.

@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.14%. Comparing base (3ea974d) to head (4abaf37).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #467      +/-   ##
==========================================
+ Coverage   97.00%   97.14%   +0.14%     
==========================================
  Files         579      579              
  Lines       47156    47168      +12     
  Branches     3089     6762    +3673     
==========================================
+ Hits        45743    45823      +80     
+ Misses       1413     1345      -68     
Flag Coverage Δ
unittests 97.14% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/31/2026 - 03:42:18
  Coverage date: 05/31/2026 - 03:39:33 - 05/31/2026 - 03:42:06
  Parser: MultiReport (12x Cobertura)
  Assemblies: 5
  Classes: 1715
  Files: 579
  Line coverage: 97%
  Covered lines: 45765
  Uncovered lines: 1403
  Coverable lines: 47168
  Total lines: 100729
  Branch coverage: 82.8% (14290 of 17248)
  Covered branches: 14290
  Total branches: 17248
  Method coverage: 97.2% (8967 of 9224)
  Full method coverage: 91.2% (8416 of 9224)
  Covered methods: 8967
  Fully covered methods: 8416
  Total methods: 9224

PatternKit.Core                                                                                                       96%
  PatternKit.Application.ActivityTracking.ActivityGateState                                                          100%
  PatternKit.Application.ActivityTracking.ActivityLease                                                              100%
  PatternKit.Application.ActivityTracking.ActivityRecord                                                             100%
  PatternKit.Application.ActivityTracking.ActivityTracker                                                            100%
  PatternKit.Application.Aggregates.AggregateCommandHandler<T1, T2, T3>                                              100%
  PatternKit.Application.Aggregates.AggregateCommandResult<T>                                                        100%
  PatternKit.Application.Aggregates.AggregateRoot<T1, T2>                                                            100%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                 90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                      100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                           85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                          95.4%
  PatternKit.Application.BoundedContexts.BoundedContextAdapter                                                       100%
  PatternKit.Application.BoundedContexts.BoundedContextCapability                                                   83.3%
  PatternKit.Application.BoundedContexts.BoundedContextDescriptor                                                   95.4%
  PatternKit.Application.ContextMaps.ContextMapDescriptor                                                           96.8%
  PatternKit.Application.ContextMaps.ContextMapRelationship                                                          100%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                             94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                  90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                            84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                      95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                      100%
  PatternKit.Application.DomainServices.DomainServiceOperation<T1, T2>                                               100%
  PatternKit.Application.DomainServices.DomainServiceRegistry<T1, T2>                                                100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.EventualConsistency.EventualConsistencyEvaluation<T>                                       92.3%
  PatternKit.Application.EventualConsistency.EventualConsistencyMonitor<T>                                          97.2%
  PatternKit.Application.EventualConsistency.EventualConsistencyMonitorState<T>                                      100%
  PatternKit.Application.EventualConsistency.EventualConsistencyWatermarks<T>                                       96.7%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                       87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                         100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                         96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                             100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                           92.8%
  PatternKit.Application.ManualTaskGates.ManualTaskGate<T>                                                          98.5%
  PatternKit.Application.ManualTaskGates.ManualTaskGateState<T>                                                      100%
  PatternKit.Application.ManualTaskGates.ManualTaskRecord<T>                                                        96.9%

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@JerrettDavis JerrettDavis merged commit b4c0e50 into main May 31, 2026
14 checks passed
@JerrettDavis JerrettDavis deleted the coverage/harden-generator-gaps-413-c branch May 31, 2026 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants