Skip to content

Conversation

@StefH
Copy link
Collaborator

@StefH StefH commented May 12, 2025

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the MethodFinder’s TryFindAggregateMethod to better support array types by enhancing method lookup and adding new tests to validate aggregate Sum behavior on arrays and IEnumerable instances.

  • Updated test files to use file-scoped namespaces and new array initializer syntax.
  • Added comprehensive tests for Sum aggregate calls with array and IEnumerable inputs.
  • Updated TypeHelper and MethodFinder to correctly handle array types via a new TryGetAsEnumerable method and caching mechanism.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/System.Linq.Dynamic.Core.Tests/QueryableTests.Sum.cs Replaced block-scoped namespace with file-scoped namespace.
test/System.Linq.Dynamic.Core.Tests/Parser/ExpressionParserTests.Sum.cs Added new tests for Sum aggregate with array and IEnumerable predicate inputs.
test/System.Linq.Dynamic.Core.Tests/ExpressionTests.cs Removed duplicate Sum tests to streamline test coverage.
test/System.Linq.Dynamic.Core.Tests/ExpressionTests.Sum.cs Introduced new Sum tests using updated C# array initializer syntax.
src/System.Linq.Dynamic.Core/Parser/TypeHelper.cs Added TryGetAsEnumerable method to detect enumerable types for arrays.
src/System.Linq.Dynamic.Core/Parser/SupportedMethods/MethodFinder.cs Updated aggregate method lookup to utilize cached methods and support array types.
Comments suppressed due to low confidence (1)

src/System.Linq.Dynamic.Core/Parser/SupportedMethods/MethodFinder.cs:56

  • Directly indexing _cachedMethods with 'callType' may throw a KeyNotFoundException if the callType is not Enumerable or Queryable. Consider using TryGetValue or checking key existence before using the cached methods.
var nonGenericMethodsByName = _cachedMethods[callType].Where(m => m.Name == methodName).ToArray();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants