Skip to content
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

AddOpenBehavior(type) now supports stream behaviors without duplicate registrations #860

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

asimmon
Copy link
Contributor

@asimmon asimmon commented Feb 23, 2023

What's changed:

  • MediatRServiceConfiguration.AddOpenBehavior(type) assumed that the type parameter implemented IPipelineBehavior<,>. It now supports IStreamPipelineBehavior<,> and throws an InvalidOperationException the type parameter is not actually an open behavior. Added multiple tests.

  • TryAddTransientExact was replaced by the built-in IServiceCollection.TryAddEnumerable that does the exact same thing, i.e. skip a registration if there's already a service descriptor that exactly match the service type AND implementation type. Modified an existing test to prove that everything behaves as before.

  • MediatRServiceConfiguration.BehaviorsToRegister consumption now use TryAddEnumerable too. Covered by the modified test from the previous point.

  • Apply the 11.x to 12.x migration guide in test classes: several test open behaviors were not using the right generic constraint, which is now TRequest : notnull.

@asimmon asimmon changed the title AddOpenBehavior now supports stream behaviors without duplicate registrations AddOpenBehavior(type) now supports stream behaviors without duplicate registrations Feb 23, 2023
@jbogard jbogard merged commit 89025ea into jbogard:master Feb 28, 2023
@asimmon asimmon deleted the stream-open-behaviors branch February 28, 2023 21:34
@asimmon
Copy link
Contributor Author

asimmon commented May 2, 2023

Hi @jbogard would you consider releasing these changes in a new patch?

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.

2 participants