feat: add mailbox generator#221
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 18s ⏱️ Results for commit 2803300. ♻️ This comment has been updated with latest results. |
🔍 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. |
There was a problem hiding this comment.
Pull request overview
Adds an attribute-driven, source-generated path for the Messaging Mailbox pattern, including generator diagnostics, tests, a DI-importable example, and documentation/catalog updates to close issue #209.
Changes:
- Introduces
[GenerateMailbox]plus handler/error/event attributes and an incrementalMailboxGeneratorthat emits strongly typed mailbox factories with diagnostics (PKMB001-PKMB005). - Adds generator tests and expands example/tests to cover fluent vs generated parity and
IServiceCollectionimportability. - Updates docs and production-readiness catalogs to reflect Mailbox generator coverage and adds a dedicated “Generated Mailbox” example page.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Generators.Tests/MailboxGeneratorTests.cs | Adds end-to-end generator tests (happy path + diagnostics). |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Extends attribute coverage tests to include new mailbox attributes/defaults. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Removes the “mailbox generator gap” assertion now that #209 is addressed. |
| test/PatternKit.Examples.Tests/Messaging/MailboxExampleTests.cs | Adds parity coverage for fluent vs generated mailbox and validates DI import surface. |
| src/PatternKit.Generators/Messaging/MailboxGenerator.cs | New incremental generator emitting mailbox factories and diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new analyzer diagnostic IDs for the mailbox generator. |
| src/PatternKit.Generators.Abstractions/Messaging/MailboxAttributes.cs | Adds [GenerateMailbox], [MailboxHandler], [MailboxErrorHandler], [MailboxEventSink] attributes. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Updates pattern catalog entry to include generator/docs/example paths for Mailbox. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds “Generated Mailbox” descriptor to the example catalog. |
| src/PatternKit.Examples/Messaging/MailboxExample.cs | Adds generated mailbox path alongside fluent path and introduces MailboxExampleRunner. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Adds AddGeneratedMailboxExample() DI registration and exported example record. |
| docs/patterns/messaging/mailbox.md | Documents generated mailbox usage and links to generator attributes. |
| docs/patterns/messaging/enterprise-generators.md | Updates messaging generator overview to include mailbox generation + diagnostics listing. |
| docs/guides/pattern-coverage.md | Marks Mailbox as covered by the messaging generator (no longer tracked gap). |
| docs/generators/messaging.md | Adds “Generated Mailbox” section and updates generator count/diagnostics table. |
| docs/generators/index.md | Adds Mailbox to the generators index and quick reference. |
| docs/examples/toc.yml | Adds “Generated Mailbox” to examples TOC. |
| docs/examples/index.md | Adds “Generated Mailbox” entry to the examples landing page. |
| docs/examples/generated-mailbox.md | New example page documenting fluent vs generated mailbox + DI import. |
| docs/examples/enterprise-messaging-workflows.md | Updates workflows doc to include generated mailbox path and links. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var eventSinks = GetMarkedMethods(type, "PatternKit.Generators.Messaging.MailboxEventSinkAttribute"); | ||
| if (errorHandlers.Count > 1 || eventSinks.Count > 1) | ||
| { | ||
| context.ReportDiagnostic(Diagnostic.Create(InvalidOptionalHandler, node.Identifier.GetLocation(), type.Name)); |
| var backpressure = GetNamedString(attribute, "BackpressurePolicy") ?? "Wait"; | ||
| if (!TryNormalizeBackpressure(backpressure, out var normalizedBackpressure)) | ||
| { | ||
| context.ReportDiagnostic(Diagnostic.Create(InvalidConfiguration, node.Identifier.GetLocation(), $"unsupported backpressure policy '{backpressure}'")); | ||
| return; |
| private static readonly DiagnosticDescriptor MissingHandler = new( | ||
| "PKMB002", | ||
| "Mailbox handler is missing", | ||
| "Type '{0}' is marked with [GenerateMailbox] but must declare exactly one [MailboxHandler] method", | ||
| "PatternKit.Generators.Messaging", | ||
| DiagnosticSeverity.Error, | ||
| true); |
77869b6 to
2803300
Compare
Code Coverage |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #221 +/- ##
==========================================
+ Coverage 91.83% 96.60% +4.77%
==========================================
Files 263 265 +2
Lines 24842 25051 +209
Branches 3390 3425 +35
==========================================
+ Hits 22813 24201 +1388
+ Misses 894 850 -44
+ Partials 1135 0 -1135
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:
|
Summary
Validation
Local broader test builds remain blocked by this machine's Roslyn 5.0/5.3 mismatch for generator assemblies; CI validates with the repository toolchain.
Closes #209