Skip to content

Adds AOT support to mocha#9505

Open
PascalSenn wants to merge 13 commits intomainfrom
pse/make-mocha-aot-compatible
Open

Adds AOT support to mocha#9505
PascalSenn wants to merge 13 commits intomainfrom
pse/make-mocha-aot-compatible

Conversation

@PascalSenn
Copy link
Copy Markdown
Member

Summary of the changes (Less than 80 chars)

  • Detail 1
  • Detail 2

Closes #bugnumber (in this specific format)

Copilot AI review requested due to automatic review settings April 6, 2026 20:46
@github-actions github-actions bot added the 📚 documentation This issue is about working on our documentation. label Apr 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds AOT-friendly messaging/mediator support by introducing source-generated JSON serialization registrations, new AOT diagnostics, and module metadata to improve cross-project type discovery.

Changes:

  • Adds AOT-oriented diagnostics (MO0015/16/18/20) and call-site/module-import inspection in analyzers.
  • Introduces strict “explicit message types only” mode and source-generated serializer/saga-state serializer configuration hooks.
  • Updates public APIs and documentation, plus adds an end-to-end AOT example solution.

Reviewed changes

Copilot reviewed 139 out of 139 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
website/src/docs/mocha/v1/diagnostics.md Documents new AOT/call-site diagnostics.
src/Mocha/test/Mocha.Tests/Scheduling/MessageBusSchedulingExtensionsTests.cs Updates test bus to new generic send APIs.
src/Mocha/test/Mocha.Tests/Middlewares/Receive/ReceiveDeadLetterMiddlewareTests.cs Updates stub options with new strict-mode flag.
src/Mocha/test/Mocha.Sagas.TestHelpers/TestMessageBus.cs Updates test helper bus to new generic send APIs.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/WarmUpGeneratorTests.Generate_WarmUpMethod_WithAllHandlerTypes_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/QueryHandlerGeneratorTests.Generate_QueryHandler_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/QueryHandlerGeneratorTests.Generate_MultipleQueryHandlers_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/PartialClassHandlerTests.Generate_PartialVoidCommandHandler_AcrossFiles_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/PartialClassHandlerTests.Generate_PartialQueryHandler_AcrossFiles_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/PartialClassHandlerTests.Generate_PartialClassHandler_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/NotificationHandlerGeneratorTests.Generate_SingleNotificationHandler_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/NotificationHandlerGeneratorTests.Generate_MultipleHandlersForSameNotification_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/NestedHandlerTests.Generate_NestedClassHandler_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/ModuleNameHelperTests.Generate_NullAssemblyName_UsesAssemblyDefault_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/ModuleNameHelperTests.Generate_AssemblyNameWithHyphen_UsesLastSegmentSanitized_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MixedHandlerGeneratorTests.Generate_HandlersInDifferentNamespaces_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MixedHandlerGeneratorTests.Generate_AllHandlerTypes_MatchesSnapshot.md Snapshot updates for new module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingRequestHandlerGeneratorTests.Generate_SendHandler_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingRequestHandlerGeneratorTests.Generate_RequestResponseHandler_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingMultiInterfaceTests.Generate_HandlerWithBatchAndEvent_RegistersAsBatch_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingModuleTests.Generate_ExplicitModuleName_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingModuleTests.Generate_DefaultModuleName_UsesAssemblyName_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingMixedHandlerTests.Generate_AllHandlerKinds_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingEventHandlerGeneratorTests.Generate_SingleEventHandler_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingEventHandlerGeneratorTests.Generate_MultipleEventHandlers_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingDiagnosticTests.MO0011_DuplicateRequestHandler_ReportsError.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingConsumerGeneratorTests.Generate_SingleConsumer_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MessagingBatchHandlerGeneratorTests.Generate_BatchEventHandler_MatchesSnapshot.md Snapshot updates for new messaging module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MediatorModuleTests.Generate_ModuleFile_ContainsHandlerRegistrations.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MediatorModuleTests.Generate_DottedAssemblyName_UsesLastSegment.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/MediatorModuleTests.Generate_DefaultAssemblyName_PrefixesWithLastSegment.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/KnownTypeSymbolsTests.Generate_WithAllHandlerTypes_AllSymbolsResolved_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/KnownTypeSymbolsTests.Generate_CommandVoidResolution_ICommandInterface_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/KnownTypeSymbolsTests.Generate_CommandOfTResolution_ICommandGeneric_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/InternalHandlerTests.Generate_InternalHandler_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/GenericHandlerTests.Generate_OpenGenericCommand_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/GenericHandlerTests.Generate_MultipleHandlersSameNamespace_DeterministicOrder_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/ExplicitModuleNameTests.Generate_ModuleWithOnlyName_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/DiagnosticTests.NoWarning_SingleHandlerInterface_NoDiagnostic.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/DiagnosticTests.NoWarning_CommandWithHandler_NoDiagnostic.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/DiagnosticTests.MO0004_OpenGenericQuery_ReportsInfo.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/DiagnosticTests.MO0004_OpenGenericCommand_ReportsInfo.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/DiagnosticTests.MO0002_VoidCommandWithTwoHandlers_ReportsError.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/DiagnosticTests.MO0002_CommandWithTwoHandlers_ReportsError.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/CommandHandlerGeneratorTests.Generate_VoidCommandHandler_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/CommandHandlerGeneratorTests.Generate_MultipleCommandHandlers_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/test/Mocha.Analyzers.Tests/snapshots/CommandHandlerGeneratorTests.Generate_CommandWithResponseHandler_MatchesSnapshot.md Snapshot updates for new mediator module info attribute output.
src/Mocha/src/Mocha/Serialization/MessageTypeRegistry.cs Adds strict “explicit registration only” behavior.
src/Mocha/src/Mocha/Serialization/JsonMessageSerializerFactory.cs Adds strict-mode enforcement for missing JsonTypeInfo.
src/Mocha/src/Mocha/Serialization/JsonMessageSerializer.cs Makes serializer public for generated code usage.
src/Mocha/src/Mocha/Serialization/HeadersConverter.cs Changes header serialization behavior for unsupported types.
src/Mocha/src/Mocha/Sagas/State/Serialization/JsonSagaStateSerializerFactory.cs Adds strict-mode enforcement for saga-state JsonTypeInfo.
src/Mocha/src/Mocha/Sagas/SagaEventListener.cs Exposes saga instance for AOT-safe traversal.
src/Mocha/src/Mocha/Sagas/Saga.Initialization.cs Allows source-generated saga serializer injection.
src/Mocha/src/Mocha/Sagas/Saga.cs Adds internal prebuilt serializer hook.
src/Mocha/src/Mocha/Observability/Configuration/InstrumentationBusExtensions.cs Adds trimming annotations for listener registration.
src/Mocha/src/Mocha/Mocha.csproj Marks Mocha project as AOT compatible.
src/Mocha/src/Mocha/Middlewares/DefaultMessageBus.cs Updates send/schedule send methods to generics.
src/Mocha/src/Mocha/MessageTypes/MessageType.cs Adds AOT path for enclosed types and trimming suppressions.
src/Mocha/src/Mocha/MessageTypes/Configurations/MessageTypeConfiguration.cs Adds EnclosedTypes to support generator precomputation.
src/Mocha/src/Mocha/IMessageBus.cs Updates send/schedule send API to generics.
src/Mocha/src/Mocha/Extensions/TypesExtensions.cs Adds trimming suppression for interface inspection.
src/Mocha/src/Mocha/Extensions/IMessageBusHostBuilderExtensions.cs Adds source-generated configuration extension hooks.
src/Mocha/src/Mocha/Descriptions/MessagingVisitor.cs Removes reflection-based saga extraction.
src/Mocha/src/Mocha/Configuration/MessagingSagaConfiguration.cs New prebuilt saga configuration DTO for generator.
src/Mocha/src/Mocha/Configuration/MessagingMessageConfiguration.cs New prebuilt message configuration DTO for generator.
src/Mocha/src/Mocha/Builder/SagaRegistration.cs Adds optional prebuilt saga serializer in registrations.
src/Mocha/src/Mocha/Builder/Options/MessagingOptions.cs Adds RequireExplicitMessageTypes option.
src/Mocha/src/Mocha/Builder/Options/IReadOnlyMessagingOptions.cs Exposes RequireExplicitMessageTypes in read-only options.
src/Mocha/src/Mocha/Builder/MessageBusBuilder.cs Adds generator-driven message/saga configuration paths.
src/Mocha/src/Mocha/Abstractions/IMessageBusBuilder.cs Adds generator-driven configuration API surface.
src/Mocha/src/Mocha.Mediator/Mocha.Mediator.csproj Marks mediator project as AOT compatible.
src/Mocha/src/Mocha.Mediator/MediatorMiddlewareFactoryContextExtensions.cs Adds trimming suppression for interface inspection.
src/Mocha/src/Mocha.Mediator/Descriptors/MediatorHandlerDescriptor.cs Adds AOT annotations around reflection handler detection.
src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorHostBuilderHandlerExtensions.cs Adds trimming annotations for handler registration.
src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorHostBuilderExtensions.cs Adds trimming annotations for diagnostic listener registration.
src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorBuilderInstrumentationExtensions.cs Adds trimming annotations for diagnostic listener registration.
src/Mocha/src/Mocha.Mediator/DependencyInjection/MediatorBuilder.cs Refactors reflection pipeline build + adds AOT annotations.
src/Mocha/src/Mocha.Mediator.Abstractions/Mocha.Mediator.Abstractions.csproj Marks mediator abstractions as AOT compatible.
src/Mocha/src/Mocha.Mediator.Abstractions/MediatorModuleInfoAttribute.cs New attribute for cross-module mediator type discovery.
src/Mocha/src/Mocha.Analyzers/SyntaxConstants.cs Adds constants for JsonContext/module-info/call-site analysis.
src/Mocha/src/Mocha.Analyzers/Models/SagaInfo.cs Includes saga state type name for AOT serializer generation.
src/Mocha/src/Mocha.Analyzers/Models/MessagingModuleInfo.cs Captures optional JsonContext type name.
src/Mocha/src/Mocha.Analyzers/Models/MessagingHandlerInfo.cs Captures message type hierarchy for enclosed types.
src/Mocha/src/Mocha.Analyzers/Models/JsonSerializableTypeInfo.cs New model for JsonSerializable-discovered types.
src/Mocha/src/Mocha.Analyzers/Models/JsonContextInfo.cs New model to avoid Compilation flowing through incremental outputs.
src/Mocha/src/Mocha.Analyzers/Models/ImportedModuleTypesInfo.cs New model for referenced-module imported message types.
src/Mocha/src/Mocha.Analyzers/Models/ContextOnlyMessageInfo.cs New model for context-only message types needing serializers.
src/Mocha/src/Mocha.Analyzers/Models/CallSiteMessageTypeInfo.cs New model for call-site-discovered message types.
src/Mocha/src/Mocha.Analyzers/Models/CallSiteKind.cs Enumerates call-site kinds for diagnostics.
src/Mocha/src/Mocha.Analyzers/Mocha.Analyzers.csproj Packs buildTransitive props.
src/Mocha/src/Mocha.Analyzers/MessagingGenerator.cs Adds call-site/module import + JsonContext extraction + AOT diagnostics.
src/Mocha/src/Mocha.Analyzers/MediatorGenerator.cs Adds call-site “no handler found” diagnostic (MO0020).
src/Mocha/src/Mocha.Analyzers/KnownTypeSymbols.cs Adds known symbols for IMessageBus/ISender/IPublisher.
src/Mocha/src/Mocha.Analyzers/Inspectors/SagaInspector.cs Extracts saga state type for AOT serializer generation.
src/Mocha/src/Mocha.Analyzers/Inspectors/MessagingModuleInspector.cs Reads JsonContext named argument from MessagingModule attribute.
src/Mocha/src/Mocha.Analyzers/Inspectors/MessagingHandlerInspector.cs Captures message type hierarchy for enclosed types.
src/Mocha/src/Mocha.Analyzers/Inspectors/ImportedModuleTypeInspector.cs New inspector for imported module message types via attributes.
src/Mocha/src/Mocha.Analyzers/Inspectors/CallSiteMessageTypeInspector.cs New inspector for dispatch call sites across bus/mediator.
src/Mocha/src/Mocha.Analyzers/Generators/MessagingDependencyInjectionGenerator.cs Emits AOT registrations and module info for messaging.
src/Mocha/src/Mocha.Analyzers/Generators/DependencyInjectionGenerator.cs Emits mediator module info attribute.
src/Mocha/src/Mocha.Analyzers/Filters/InvocationModuleFilter.cs New syntactic filter for module registration invocations.
src/Mocha/src/Mocha.Analyzers/Filters/InvocationCallSiteFilter.cs New syntactic filter for dispatch call sites.
src/Mocha/src/Mocha.Analyzers/FileBuilders/MessagingDependencyInjectionFileBuilder.cs Emits messaging module info + AOT config/serializer registrations.
src/Mocha/src/Mocha.Analyzers/FileBuilders/DependencyInjectionFileBuilder.cs Emits mediator module info attribute.
src/Mocha/src/Mocha.Analyzers/Errors.cs Adds new diagnostics descriptors MO0015/16/18/20.
src/Mocha/src/Mocha.Analyzers/buildTransitive/Mocha.Analyzers.props Exposes PublishAot/IsAotCompatible to analyzers.
src/Mocha/src/Mocha.Analyzers/AnalyzerReleases.Unshipped.md Documents new diagnostics.
src/Mocha/src/Mocha.Abstractions/Mocha.Abstractions.csproj Marks abstractions project as AOT compatible.
src/Mocha/src/Mocha.Abstractions/MessagingModuleInfoAttribute.cs New attribute for cross-module messaging type discovery.
src/Mocha/src/Mocha.Abstractions/MessagingModuleAttribute.cs Adds JsonContext property for AOT JSON context selection.
src/Mocha/src/.gitignore Ignores Generated output directory.
src/Mocha/examples/AotExample/docker-compose.yml Adds RabbitMQ compose for AOT example.
src/Mocha/examples/AotExample/Directory.Build.props Sets TFM for the AOT example solution.
src/Mocha/examples/AotExample/AotExample.slnx Adds AOT example solution definition.
src/Mocha/examples/AotExample/AotExample.OrderService/Properties/launchSettings.json Launch profile for AOT OrderService.
src/Mocha/examples/AotExample/AotExample.OrderService/Program.cs AOT example OrderService composition and module attributes.
src/Mocha/examples/AotExample/AotExample.OrderService/OrderSimulatorWorker.cs Demonstrates mediator + bus dispatch for AOT scenario.
src/Mocha/examples/AotExample/AotExample.OrderService/Handlers/PlaceOrderCommandHandler.cs Example command handler.
src/Mocha/examples/AotExample/AotExample.OrderService/Handlers/OrderStatusChangedHandler.cs Example notification handler.
src/Mocha/examples/AotExample/AotExample.OrderService/Handlers/OrderShippedHandler.cs Example event handler + mediator publish.
src/Mocha/examples/AotExample/AotExample.OrderService/Handlers/GetOrderStatusQueryHandler.cs Example query handler.
src/Mocha/examples/AotExample/AotExample.OrderService/Handlers/CheckInventoryRequestHandler.cs Example request/response handler.
src/Mocha/examples/AotExample/AotExample.OrderService/AotExample.OrderService.csproj AOT-enabled service project wiring analyzers.
src/Mocha/examples/AotExample/AotExample.FulfillmentService/Properties/launchSettings.json Launch profile for AOT FulfillmentService.
src/Mocha/examples/AotExample/AotExample.FulfillmentService/Program.cs AOT example FulfillmentService composition and module attribute.
src/Mocha/examples/AotExample/AotExample.FulfillmentService/Handlers/OrderPlacedHandler.cs Example consumer performing bus request/publish.
src/Mocha/examples/AotExample/AotExample.FulfillmentService/AotExample.FulfillmentService.csproj AOT-enabled service project wiring analyzers.
src/Mocha/examples/AotExample/AotExample.Contracts/Requests/CheckInventoryResponse.cs Example contract type for bus request/response.
src/Mocha/examples/AotExample/AotExample.Contracts/Requests/CheckInventoryRequest.cs Example contract type for bus request.
src/Mocha/examples/AotExample/AotExample.Contracts/Queries/GetOrderStatusResponse.cs Example contract type for mediator response.
src/Mocha/examples/AotExample/AotExample.Contracts/Queries/GetOrderStatusQuery.cs Example contract type for mediator query.
src/Mocha/examples/AotExample/AotExample.Contracts/Notifications/OrderStatusChangedNotification.cs Example contract type for mediator notifications.
src/Mocha/examples/AotExample/AotExample.Contracts/Events/OrderShippedEvent.cs Example event contract.
src/Mocha/examples/AotExample/AotExample.Contracts/Events/OrderPlacedEvent.cs Example event contract.
src/Mocha/examples/AotExample/AotExample.Contracts/Commands/PlaceOrderCommand.cs Example command + result contract.
src/Mocha/examples/AotExample/AotExample.Contracts/AssemblyInfo.cs Declares MessagingModule + JsonContext for contracts module.
src/Mocha/examples/AotExample/AotExample.Contracts/AotExampleJsonContext.cs Source-gen JSON context for AOT serialization.
src/Mocha/examples/AotExample/AotExample.Contracts/AotExample.Contracts.csproj Contracts project referencing analyzers for generation.

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

Comment on lines +38 to +58
// Collect all unique message types for the [MediatorModuleInfo] attribute.
var allMessageTypeNames = new HashSet<string>(StringComparer.Ordinal);

foreach (var handler in handlers)
{
allMessageTypeNames.Add(handler.MessageTypeName);

if (handler.ResponseTypeName is not null)
{
allMessageTypeNames.Add(handler.ResponseTypeName);
}
}

foreach (var handler in notificationHandlers)
{
allMessageTypeNames.Add(handler.NotificationTypeName);
}

var sortedMessageTypeNames = allMessageTypeNames
.OrderBy(t => t, StringComparer.Ordinal)
.ToList();
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

The [MediatorModuleInfo(MessageTypes = ...)] list is built from HandlerInfo.MessageTypeName/ResponseTypeName without filtering out open-generic/type-parameter cases. In the open-generic diagnostics snapshots this produces entries like typeof(T) / typeof(GenericQuery<T>), which will not bind in the generated non-generic Add* method and can break consumer builds. Filter out any message/response types that contain type parameters (or otherwise cannot be expressed as a valid typeof(...) in this context) before emitting the attribute.

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +100
// Collect all unique message types for the [MessagingModuleInfo] attribute.
var allMessageTypeNames = new HashSet<string>(StringComparer.Ordinal);

foreach (var handler in handlers)
{
allMessageTypeNames.Add(handler.MessageTypeName);

if (handler.ResponseTypeName is not null)
{
allMessageTypeNames.Add(handler.ResponseTypeName);
}
}

foreach (var contextOnly in contextOnlyTypes)
{
allMessageTypeNames.Add(contextOnly.MessageTypeName);
}

var sortedMessageTypeNames = allMessageTypeNames
.OrderBy(t => t, StringComparer.Ordinal)
.ToList();

using var builder = new MessagingDependencyInjectionFileBuilder(moduleName, assemblyName);

builder.WriteHeader();
builder.WriteBeginNamespace();
builder.WriteBeginClass();
builder.WriteBeginRegistrationMethod();
builder.WriteBeginRegistrationMethod(sortedMessageTypeNames);

Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

Similarly, the [MessagingModuleInfo(MessageTypes = ...)] list includes handler message/response types verbatim. For open-generic handlers this can generate typeof(T) / typeof(Foo<T>) entries that are not resolvable in the generated non-generic registration method, causing compilation failures for consumers. Filter out any message/response types that contain type parameters (or otherwise cannot be used in a typeof(...) expression here) before calling WriteBeginRegistrationMethod.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (02c3e09) to head (95292ee).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9505   +/-   ##
============================
============================

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ mocha

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants