@@ -45,25 +45,28 @@ public MethodFinder(ParsingConfig parsingConfig, IExpressionHelper expressionHel
4545 _expressionHelper = Check . NotNull ( expressionHelper ) ;
4646 }
4747
48- public bool TryFindAverageMethod ( Type callType , Type parameterType , [ NotNullWhen ( true ) ] out MethodInfo ? averageMethod )
48+ public bool TryFindAggregateMethod ( Type callType , string methodName , Type parameterType , [ NotNullWhen ( true ) ] out MethodInfo ? aggregateMethod )
4949 {
50- averageMethod = callType
50+ aggregateMethod = callType
5151 . GetMethods ( )
52- . Where ( m => m is { Name : nameof ( Enumerable . Average ) , IsGenericMethodDefinition : false } )
52+ . Where ( m => m . Name == methodName && ! m . IsGenericMethodDefinition )
5353 . SelectMany ( m => m . GetParameters ( ) , ( m , p ) => new { Method = m , Parameter = p } )
5454 . Where ( x => x . Parameter . ParameterType == parameterType )
5555 . Select ( x => x . Method )
5656 . FirstOrDefault ( ) ;
5757
58- return averageMethod != null ;
58+ return aggregateMethod != null ;
5959 }
6060
61- public void CheckAggregateMethodAndTryUpdateArgsToMatchMethodArgs ( string methodName , ref Expression [ ] args )
61+ public bool CheckAggregateMethodAndTryUpdateArgsToMatchMethodArgs ( string methodName , ref Expression [ ] args )
6262 {
6363 if ( methodName is nameof ( IAggregateSignatures . Average ) or nameof ( IAggregateSignatures . Sum ) )
6464 {
6565 ContainsMethod ( typeof ( IAggregateSignatures ) , methodName , false , null , ref args ) ;
66+ return true ;
6667 }
68+
69+ return false ;
6770 }
6871
6972 public bool ContainsMethod ( Type type , string methodName , bool staticAccess = true )
0 commit comments