feat: add backplane topology generator#223
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 44s ⏱️ Results for commit 6bdf17a. |
🔍 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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #223 +/- ##
==========================================
+ Coverage 91.68% 96.57% +4.89%
==========================================
Files 267 269 +2
Lines 25277 25546 +269
Branches 3457 3514 +57
==========================================
+ Hits 23174 24670 +1496
+ Misses 923 876 -47
+ Partials 1180 0 -1180
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:
|
Code Coverage |
There was a problem hiding this comment.
Pull request overview
Adds a new messaging source generator to produce strongly-typed request/reply + publish/subscribe backplane topology wiring from declarative attributes, and updates the messaging backplane facade example + documentation/catalogs to reflect generated coverage for Request-Reply and Publish-Subscribe.
Changes:
- Introduces
[GenerateBackplaneTopology],[BackplaneRequestReply], and[BackplaneSubscription]attributes plusBackplaneTopologyGeneratorand newPKBT00xdiagnostics. - Migrates the messaging backplane facade demo to use generated topology, and updates DI/example catalog integration surfaces accordingly.
- Updates docs and pattern coverage catalogs/tests to show generated paths for Request-Reply and Publish-Subscribe.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Generators.Tests/BackplaneTopologyGeneratorTests.cs | Adds generator tests for basic generation and a subset of diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Adds attribute target/default/guard coverage for the new attributes. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Removes tracked “generated gap” entries for Request-Reply and Publish-Subscribe. |
| test/PatternKit.Examples.Tests/Messaging/BackplaneFacadeDemoTests.cs | Adds coverage for generated topology wiring and IServiceCollection importability. |
| src/PatternKit.Generators/Messaging/BackplaneTopologyGenerator.cs | New incremental generator implementing topology emission + diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Documents new PKBT001–PKBT005 diagnostics. |
| src/PatternKit.Generators.Abstractions/Messaging/BackplaneTopologyAttributes.cs | Adds the new generator attributes (abstractions package). |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Updates pattern catalog entries to include generated topology files and remove tracked gap link. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Marks the messaging backplane facade example as SourceGenerator-integrated and updates tags. |
| src/PatternKit.Examples/Messaging/BackplaneFacadeDemo.cs | Switches demo host wiring from fluent to generated topology; exposes services used by tests/topology. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Updates DI registration to include SourceGenerator integration surface. |
| docs/patterns/messaging/enterprise-generators.md | Mentions backplane topology generation and adds PKBT diagnostics to the list. |
| docs/guides/pattern-coverage.md | Updates Request-Reply and Publish-Subscribe coverage to “Backplane topology generator”. |
| docs/generators/messaging.md | Documents generated backplane topology and updates generator count/list. |
| docs/generators/index.md | Adds backplane topology to generator index and quick reference. |
| docs/examples/messaging-backplane-facade.md | Updates example to show generated topology usage and adds DI import mention. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var configureMethodName = GetNamedString(attribute, "ConfigureMethodName") ?? "Configure"; | ||
| var hostBuilderTypeName = GetNamedType(attribute, "HostBuilderType") | ||
| ?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) | ||
| ?? "global::PatternKit.Examples.Messaging.BackplaneHostBuilder"; | ||
| context.AddSource($"{type.Name}.BackplaneTopology.g.cs", SourceText.From( | ||
| GenerateSource(type, servicesType, hostBuilderTypeName, requests, subscriptions, configureMethodName), | ||
| Encoding.UTF8)); |
| if (requestType is null || responseType is null || string.IsNullOrWhiteSpace(endpointName) || string.IsNullOrWhiteSpace(handlerName)) | ||
| return false; | ||
|
|
||
| var handler = servicesType.GetMembers(handlerName!).OfType<IMethodSymbol>().FirstOrDefault(); | ||
| if (handler is null || !IsRequestHandler(handler, requestType, responseType)) | ||
| return false; | ||
|
|
| sb.AppendLine(); | ||
| foreach (var group in requests.GroupBy(static r => r.EndpointName).OrderBy(static g => g.Key, System.StringComparer.Ordinal)) | ||
| { | ||
| sb.Append(" builder.ReceiveEndpoint(\"").Append(Escape(group.Key)).AppendLine("\", endpoint =>"); | ||
| sb.AppendLine(" {"); | ||
| foreach (var request in group.OrderBy(static r => r.HandlerMethodName, System.StringComparer.Ordinal)) |
| [Scenario("Reports diagnostic for non-partial backplane topology")] | ||
| [Fact] | ||
| public void ReportsDiagnosticForNonPartialBackplaneTopology() | ||
| { | ||
| var source = """ | ||
| using PatternKit.Generators.Messaging; | ||
|
|
||
| namespace PatternKit.Examples.Messaging; | ||
|
|
||
| public sealed class OrderServices { } | ||
|
|
||
| [GenerateBackplaneTopology(typeof(OrderServices))] | ||
| public static class OrderBackplane; | ||
| """; | ||
|
|
||
| var comp = CreateCompilation(source, nameof(ReportsDiagnosticForNonPartialBackplaneTopology)); | ||
| var gen = new BackplaneTopologyGenerator(); | ||
| _ = RoslynTestHelpers.Run(comp, gen, out var run, out _); | ||
|
|
||
| var diagnostic = ScenarioExpect.Single(run.Results.SelectMany(result => result.Diagnostics)); | ||
| ScenarioExpect.Equal("PKBT001", diagnostic.Id); | ||
| } |
Summary
Closes #214
Validation
Note: focused local test builds are blocked on this machine by the existing Roslyn compiler/analyzer mismatch (CS9057/CS1705); PR CI should be authoritative.