From 205172da9987ddb6db4ad83bd0a15ef7dad5f629 Mon Sep 17 00:00:00 2001 From: Anders Kloborg Date: Tue, 15 Nov 2022 22:30:19 +0100 Subject: [PATCH] added static modifier where applicable in Mediatr project. --- src/MediatR/Internal/HandlersOrderer.cs | 6 +++--- src/MediatR/Mediator.cs | 2 +- .../Pipeline/RequestExceptionActionProcessorBehavior.cs | 6 +++--- src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs | 6 +++--- src/MediatR/Wrappers/NotificationHandlerWrapper.cs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/MediatR/Internal/HandlersOrderer.cs b/src/MediatR/Internal/HandlersOrderer.cs index bab63b33..d9d7b2df 100644 --- a/src/MediatR/Internal/HandlersOrderer.cs +++ b/src/MediatR/Internal/HandlersOrderer.cs @@ -15,12 +15,12 @@ public static IList Prioritize(IList handlers, TReques } var requestObjectDetails = new ObjectDetails(request); - var handlerObjectsDetails = handlers.Select(s => new ObjectDetails(s)).ToList(); + var handlerObjectsDetails = handlers.Select(static s => new ObjectDetails(s)).ToList(); var uniqueHandlers = RemoveOverridden(handlerObjectsDetails).ToArray(); Array.Sort(uniqueHandlers, requestObjectDetails); - return uniqueHandlers.Select(s => s.Value).ToList(); + return uniqueHandlers.Select(static s => s.Value).ToList(); } private static IEnumerable RemoveOverridden(IList handlersData) @@ -45,6 +45,6 @@ private static IEnumerable RemoveOverridden(IList } } - return handlersData.Where(w => !w.IsOverridden); + return handlersData.Where(static w => !w.IsOverridden); } } \ No newline at end of file diff --git a/src/MediatR/Mediator.cs b/src/MediatR/Mediator.cs index c6a639b6..974aff0c 100644 --- a/src/MediatR/Mediator.cs +++ b/src/MediatR/Mediator.cs @@ -148,7 +148,7 @@ public IAsyncEnumerable CreateStream(IStreamRequest i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IStreamRequest<>)); + .FirstOrDefault(static i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IStreamRequest<>)); var isValidRequest = requestInterfaceType != null; if (!isValidRequest) diff --git a/src/MediatR/Pipeline/RequestExceptionActionProcessorBehavior.cs b/src/MediatR/Pipeline/RequestExceptionActionProcessorBehavior.cs index 3d77d462..702be133 100644 --- a/src/MediatR/Pipeline/RequestExceptionActionProcessorBehavior.cs +++ b/src/MediatR/Pipeline/RequestExceptionActionProcessorBehavior.cs @@ -35,9 +35,9 @@ public async Task Handle(TRequest request, RequestHandlerDelegate GetActionsForException(exceptionType, request)) - .GroupBy(actionForException => actionForException.Action.GetType()) - .Select(actionForException => actionForException.First()) - .Select(actionForException => (MethodInfo: GetMethodInfoForAction(actionForException.ExceptionType), actionForException.Action)) + .GroupBy(static actionForException => actionForException.Action.GetType()) + .Select(static actionForException => actionForException.First()) + .Select(static actionForException => (MethodInfo: GetMethodInfoForAction(actionForException.ExceptionType), actionForException.Action)) .ToList(); foreach (var actionForException in actionsForException) diff --git a/src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs b/src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs index 0bf84b25..a63dbe5f 100644 --- a/src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs +++ b/src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs @@ -37,9 +37,9 @@ public async Task Handle(TRequest request, RequestHandlerDelegate GetHandlersForException(exceptionType, request)) - .GroupBy(handlerForException => handlerForException.Handler.GetType()) - .Select(handlerForException => handlerForException.First()) - .Select(handlerForException => (MethodInfo: GetMethodInfoForHandler(handlerForException.ExceptionType), handlerForException.Handler)) + .GroupBy(static handlerForException => handlerForException.Handler.GetType()) + .Select(static handlerForException => handlerForException.First()) + .Select(static handlerForException => (MethodInfo: GetMethodInfoForHandler(handlerForException.ExceptionType), handlerForException.Handler)) .ToList(); foreach (var handlerForException in handlersForException) diff --git a/src/MediatR/Wrappers/NotificationHandlerWrapper.cs b/src/MediatR/Wrappers/NotificationHandlerWrapper.cs index 0a1a970b..c8981730 100644 --- a/src/MediatR/Wrappers/NotificationHandlerWrapper.cs +++ b/src/MediatR/Wrappers/NotificationHandlerWrapper.cs @@ -22,7 +22,7 @@ public override Task Handle(INotification notification, ServiceFactory serviceFa { var handlers = serviceFactory .GetInstances>() - .Select(x => new Func((theNotification, theToken) => x.Handle((TNotification)theNotification, theToken))); + .Select(static x => new Func((theNotification, theToken) => x.Handle((TNotification)theNotification, theToken))); return publish(handlers, notification, cancellationToken); }