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

Added static modifier for lambdas where applicable in Mediatr project. #801

Merged
merged 1 commit into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/MediatR/Internal/HandlersOrderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public static IList<object> Prioritize<TRequest>(IList<object> 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<ObjectDetails> RemoveOverridden(IList<ObjectDetails> handlersData)
Expand All @@ -45,6 +45,6 @@ private static IEnumerable<ObjectDetails> RemoveOverridden(IList<ObjectDetails>
}
}

return handlersData.Where(w => !w.IsOverridden);
return handlersData.Where(static w => !w.IsOverridden);
}
}
2 changes: 1 addition & 1 deletion src/MediatR/Mediator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public IAsyncEnumerable<TResponse> CreateStream<TResponse>(IStreamRequest<TRespo
{
var requestInterfaceType = requestTypeKey
.GetInterfaces()
.FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IStreamRequest<>));
.FirstOrDefault(static i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IStreamRequest<>));
var isValidRequest = requestInterfaceType != null;

if (!isValidRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe

var actionsForException = exceptionTypes
.SelectMany(exceptionType => 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)
Expand Down
6 changes: 3 additions & 3 deletions src/MediatR/Pipeline/RequestExceptionProcessorBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe

var handlersForException = exceptionTypes
.SelectMany(exceptionType => 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)
Expand Down
2 changes: 1 addition & 1 deletion src/MediatR/Wrappers/NotificationHandlerWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override Task Handle(INotification notification, ServiceFactory serviceFa
{
var handlers = serviceFactory
.GetInstances<INotificationHandler<TNotification>>()
.Select(x => new Func<INotification, CancellationToken, Task>((theNotification, theToken) => x.Handle((TNotification)theNotification, theToken)));
.Select(static x => new Func<INotification, CancellationToken, Task>((theNotification, theToken) => x.Handle((TNotification)theNotification, theToken)));

return publish(handlers, notification, cancellationToken);
}
Expand Down