Skip to content

Conversation

@danielmarbach
Copy link
Contributor

@danielmarbach danielmarbach commented Jan 7, 2026

Relates to the changes introduced in

Particular/NServiceBus#7439
Particular/NServiceBus#7445
Particular/NServiceBus#7428
Particular/NServiceBus#7516
Particular/NServiceBus.CustomChecks#635

This pull request updates the NServiceBus v10 upgrade documentation to clarify how infrastructure components (such as handlers, sagas, behaviors, installers, and custom checks) are registered and resolved. The documentation now emphasizes that these components are no longer registered in the service collection, aligning NServiceBus with modern .NET architectural practices and principles such as the Dependency Inversion Principle and the Hollywood Principle. The changes explain the rationale, impact, required code adjustments, and benefits for users upgrading to v10.

Service registration and architectural changes:

  • Infrastructure components (handlers, sagas, behaviors, installers, custom checks) are no longer registered in the service collection, preventing accidental dependency on framework internals and discouraging the Service Locator anti-pattern.
  • Documentation explains that dependency injection for handler dependencies continues to work, but direct resolution of handlers/sagas from IServiceProvider is no longer possible.
  • Guidance is provided for refactoring code that previously resolved infrastructure types directly, recommending extraction of business logic into proper application services.

Benefits and alignment with .NET practices:

  • The change maintains a clean separation between framework and application layers, mirroring established patterns in ASP.NET Core, Blazor, and Minimal APIs.
  • Fewer service registrations result in faster validation, fewer false positives

@danielmarbach danielmarbach marked this pull request as ready for review January 7, 2026 16:15
danielmarbach and others added 6 commits January 8, 2026 11:39
Added guidance on refactoring code to improve separation of concerns and dependency injection practices in NServiceBus.
Co-authored-by: David Boike <david.boike@gmail.com>
Co-authored-by: Andreas Öhlund <andreas.ohlund@particular.net>
@danielmarbach danielmarbach force-pushed the upgrade-dependency-registration branch from f5ec9ff to 83a1099 Compare January 8, 2026 11:16
@danielmarbach danielmarbach merged commit a72add2 into master Jan 8, 2026
4 checks passed
@danielmarbach danielmarbach deleted the upgrade-dependency-registration branch January 8, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants