Skip to content

Support opt-in assembly entry point generation for assemblies without handlers #7748

Description

@danielmarbach

Today, when an assembly does not contain any handlers marked with the [Handler] attribute, the assembly cannot be used with:

endpointConfiguration.Handlers.MyAssembly.AddAll()

This behavior is currently by design.

The source generator only generates assembly entry points for assemblies that contain handlers. If entry points were generated for every assembly referencing NServiceBus, this would also include assemblies such as message contracts or shared infrastructure libraries, creating significant noise and additional generated artifacts with little value.

The downside of the current approach is that an assembly cannot participate in AddAll() registration until it contains at least one handler. This makes certain composition root or modular configuration scenarios awkward, particularly when teams want to wire up endpoint features, registrations, or conventions before handlers are introduced into the assembly.

One possible approach would be to support this as an explicit opt-in model. For example, an additional assembly-level attribute could instruct the source generator to generate the required assembly entry point even when no handlers are present.

Example (illustrative only):

[assembly: GenerateHandlerAssemblyEntryPoint]

Additional information

This issue is intentionally not a commitment to implementing such functionality.

The purpose of the issue is to gather feedback from users about:

  • Whether this limitation is causing friction in real-world scenarios
  • What composition root or modularization patterns are affected
  • Whether an explicit opt-in model would be useful
  • Whether there are alternative approaches that would better address the problem

Feedback and concrete use cases would help evaluate whether the additional complexity and generated artifacts are justified.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions