Skip to content

Commit 8d696b4

Browse files
committed
Remove Generic Handler Support
- leaving tests for future implementation behavior.
2 parents fb30902 + f2f0fe2 commit 8d696b4

File tree

3 files changed

+35
-227
lines changed

3 files changed

+35
-227
lines changed

src/MediatR/MicrosoftExtensionsDI/MediatrServiceConfiguration.cs

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class MediatRServiceConfiguration
1515
/// Optional filter for types to register. Default value is a function returning true.
1616
/// </summary>
1717
public Func<Type, bool> TypeEvaluator { get; set; } = t => true;
18-
18+
1919
/// <summary>
2020
/// Mediator implementation type to register. Default is <see cref="Mediator"/>
2121
/// </summary>
@@ -69,31 +69,6 @@ public class MediatRServiceConfiguration
6969
/// </summary>
7070
public bool AutoRegisterRequestProcessors { get; set; }
7171

72-
/// <summary>
73-
/// Configure the maximum number of type parameters that a generic request handler can have. To Disable this constraint, set the value to 0.
74-
/// </summary>
75-
public int MaxGenericTypeParameters { get; set; } = 10;
76-
77-
/// <summary>
78-
/// Configure the maximum number of types that can close a generic request type parameter constraint. To Disable this constraint, set the value to 0.
79-
/// </summary>
80-
public int MaxTypesClosing { get; set; } = 100;
81-
82-
/// <summary>
83-
/// Configure the Maximum Amount of Generic RequestHandler Types MediatR will try to register. To Disable this constraint, set the value to 0.
84-
/// </summary>
85-
public int MaxGenericTypeRegistrations { get; set; } = 125000;
86-
87-
/// <summary>
88-
/// Configure the Timeout in Milliseconds that the GenericHandler Registration Process will exit with error. To Disable this constraint, set the value to 0.
89-
/// </summary>
90-
public int RegistrationTimeout { get; set; } = 15000;
91-
92-
/// <summary>
93-
/// Flag that controlls whether MediatR will attempt to register handlers that containg generic type parameters.
94-
/// </summary>
95-
public bool RegisterGenericHandlers { get; set; } = false;
96-
9772
/// <summary>
9873
/// Register various handlers from assembly containing given type
9974
/// </summary>
@@ -231,7 +206,7 @@ public MediatRServiceConfiguration AddOpenBehavior(Type openBehaviorType, Servic
231206
/// <returns>This</returns>
232207
public MediatRServiceConfiguration AddStreamBehavior<TServiceType, TImplementationType>(ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
233208
=> AddStreamBehavior(typeof(TServiceType), typeof(TImplementationType), serviceLifetime);
234-
209+
235210
/// <summary>
236211
/// Register a closed stream behavior type
237212
/// </summary>
@@ -245,7 +220,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type serviceType, Type impl
245220

246221
return this;
247222
}
248-
223+
249224
/// <summary>
250225
/// Register a closed stream behavior type against all <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> implementations
251226
/// </summary>
@@ -254,7 +229,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type serviceType, Type impl
254229
/// <returns>This</returns>
255230
public MediatRServiceConfiguration AddStreamBehavior<TImplementationType>(ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
256231
=> AddStreamBehavior(typeof(TImplementationType), serviceLifetime);
257-
232+
258233
/// <summary>
259234
/// Register a closed stream behavior type against all <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> implementations
260235
/// </summary>
@@ -277,7 +252,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type implementationType, Se
277252

278253
return this;
279254
}
280-
255+
281256
/// <summary>
282257
/// Registers an open stream behavior type against the <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> open generic interface type
283258
/// </summary>
@@ -316,7 +291,7 @@ public MediatRServiceConfiguration AddOpenStreamBehavior(Type openBehaviorType,
316291
/// <returns>This</returns>
317292
public MediatRServiceConfiguration AddRequestPreProcessor<TServiceType, TImplementationType>(ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
318293
=> AddRequestPreProcessor(typeof(TServiceType), typeof(TImplementationType), serviceLifetime);
319-
294+
320295
/// <summary>
321296
/// Register a closed request pre processor type
322297
/// </summary>
@@ -360,10 +335,10 @@ public MediatRServiceConfiguration AddRequestPreProcessor(Type implementationTyp
360335
{
361336
RequestPreProcessorsToRegister.Add(new ServiceDescriptor(implementedPreProcessorType, implementationType, serviceLifetime));
362337
}
363-
338+
364339
return this;
365340
}
366-
341+
367342
/// <summary>
368343
/// Registers an open request pre processor type against the <see cref="IRequestPreProcessor{TRequest}"/> open generic interface type
369344
/// </summary>
@@ -392,7 +367,7 @@ public MediatRServiceConfiguration AddOpenRequestPreProcessor(Type openBehaviorT
392367

393368
return this;
394369
}
395-
370+
396371
/// <summary>
397372
/// Register a closed request post processor type
398373
/// </summary>
@@ -402,7 +377,7 @@ public MediatRServiceConfiguration AddOpenRequestPreProcessor(Type openBehaviorT
402377
/// <returns>This</returns>
403378
public MediatRServiceConfiguration AddRequestPostProcessor<TServiceType, TImplementationType>(ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
404379
=> AddRequestPostProcessor(typeof(TServiceType), typeof(TImplementationType), serviceLifetime);
405-
380+
406381
/// <summary>
407382
/// Register a closed request post processor type
408383
/// </summary>
@@ -416,7 +391,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type serviceType, Typ
416391

417392
return this;
418393
}
419-
394+
420395
/// <summary>
421396
/// Register a closed request post processor type against all <see cref="IRequestPostProcessor{TRequest,TResponse}"/> implementations
422397
/// </summary>
@@ -425,7 +400,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type serviceType, Typ
425400
/// <returns>This</returns>
426401
public MediatRServiceConfiguration AddRequestPostProcessor<TImplementationType>(ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
427402
=> AddRequestPostProcessor(typeof(TImplementationType), serviceLifetime);
428-
403+
429404
/// <summary>
430405
/// Register a closed request post processor type against all <see cref="IRequestPostProcessor{TRequest,TResponse}"/> implementations
431406
/// </summary>
@@ -447,7 +422,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type implementationTy
447422
}
448423
return this;
449424
}
450-
425+
451426
/// <summary>
452427
/// Registers an open request post processor type against the <see cref="IRequestPostProcessor{TRequest,TResponse}"/> open generic interface type
453428
/// </summary>

src/MediatR/MicrosoftExtensionsDI/ServiceCollectionExtensions.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,31 @@ public static class ServiceCollectionExtensions
2323
/// <param name="services">Service collection</param>
2424
/// <param name="configuration">The action used to configure the options</param>
2525
/// <returns>Service collection</returns>
26-
public static IServiceCollection AddMediatR(this IServiceCollection services,
26+
public static IServiceCollection AddMediatR(this IServiceCollection services,
2727
Action<MediatRServiceConfiguration> configuration)
2828
{
2929
var serviceConfig = new MediatRServiceConfiguration();
3030

3131
configuration.Invoke(serviceConfig);
3232

3333
return services.AddMediatR(serviceConfig);
34-
}
35-
34+
}
35+
3636
/// <summary>
3737
/// Registers handlers and mediator types from the specified assemblies
3838
/// </summary>
3939
/// <param name="services">Service collection</param>
4040
/// <param name="configuration">Configuration options</param>
4141
/// <returns>Service collection</returns>
42-
public static IServiceCollection AddMediatR(this IServiceCollection services,
42+
public static IServiceCollection AddMediatR(this IServiceCollection services,
4343
MediatRServiceConfiguration configuration)
4444
{
4545
if (!configuration.AssembliesToRegister.Any())
4646
{
4747
throw new ArgumentException("No assemblies found to scan. Supply at least one assembly to scan for handlers.");
4848
}
4949

50-
ServiceRegistrar.SetGenericRequestHandlerRegistrationLimitations(configuration);
51-
52-
ServiceRegistrar.AddMediatRClassesWithTimeout(services, configuration);
50+
ServiceRegistrar.AddMediatRClasses(services, configuration);
5351

5452
ServiceRegistrar.AddRequiredServices(services, configuration);
5553

0 commit comments

Comments
 (0)