-
Notifications
You must be signed in to change notification settings - Fork 647
Strong typing improvements on the persistence seam #7436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ly defaults for actually used persistences at a deterministic time
4b94517 to
0a09a06
Compare
0a09a06 to
4e712b9
Compare
This reverts commit 4198d29.
b807ce1 to
2182440
Compare
andreasohlund
approved these changes
Oct 17, 2025
|
Demonstration of the adoption for SQL Persistence Particular/NServiceBus.Persistence.Sql#1822 |
|
NHibernate Particular/NServiceBus.NHibernate#1327 |
This was referenced Oct 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of refactoring the entire persistence seam, we have tried to keep the seam as close as possible to the existing assumptions but introduced slightly more type safety. All persistence implementations are geared towards using Features (even our public documentation shows that). These refactorings further strengthen the relationship between the storage type and the features for now until we fundamentally redesign the seam.
This also gets rid of the weird triple creation of the persistence implementation that made the code difficult to understand and led to downstreams like SqlPersistence having to guard certain defaults against multiple invocations.
Another angle of this PR is to reduce the usage of
EnableFeatureByDefaultthat was mostly only used for the persistence seam integration.Persistence definition usages have been refactored throughout the acceptance tests and core APIs to require an explicit factory interface, streamlining how persistence definitions are registered and instantiated. This also gets rid of reflection usage when we new up persistences. It also modernizes test code by using more concise syntax and updates the API surface for persistence extension methods. These changes improve type safety, consistency, and maintainability of persistence configuration in NServiceBus.
Persistence Definition Factory Refactor
IPersistenceDefinitionFactory<T>interface, and expose a staticCreate()method for instantiation, replacing previous patterns. This affects files such asAcceptanceTestingPersistence.cs, test persistence definitions, and the public API for learning persistence. [1] [2] [3] [4] [5]API and Type Signature Updates
UsePersistence<T>andPersistenceExtensions<T>APIs now require the persistence type to implement bothPersistenceDefinitionandIPersistenceDefinitionFactory<T>, improving type safety.Test Code Modernization
Feature and Storage Registration Improvements
Minor Cleanups
usingstatements and redundant code are removed across several test files for clarity. [1] [2]These changes collectively ensure that persistence configuration is more robust, maintainable, and aligned with modern C# practices.