Skip to content

Conversation

@StefH
Copy link
Collaborator

@StefH StefH commented Oct 25, 2025

No description provided.

@StefH StefH requested a review from Copilot October 25, 2025 08:45
@StefH StefH self-assigned this Oct 25, 2025
@StefH StefH added the bug label Oct 25, 2025
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 handling of arithmetic operations between Enum types and integers in the dynamic LINQ parser. Previously, enums were treated as Int64 for type compatibility checks, which caused incorrect behavior when adding enums and integers.

Key Changes:

  • Changed enum type compatibility from TypeCode.Int64 to TypeCode.Int32 to match C#'s actual enum underlying type behavior
  • Updated decimal conversion logic to properly handle nullable enum types
  • Added comprehensive test coverage for enum arithmetic operations

Reviewed Changes

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

File Description
src/System.Linq.Dynamic.Core/Parser/TypeHelper.cs Updated IsCompatibleWith to use Int32 for enums instead of Int64, renamed variables for clarity, and added TypesAreEqual helper method
src/System.Linq.Dynamic.Core/Parser/ExpressionPromoter.cs Fixed decimal conversion check to handle nullable types correctly using new TypesAreEqual method
test/System.Linq.Dynamic.Core.Tests/Parser/TypeHelperTests.cs Added comprehensive test coverage for enum type compatibility and renamed existing tests for clarity
test/System.Linq.Dynamic.Core.Tests/QueryableTests.Select.cs Added integration tests for enum+integer and integer+enum addition operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@StefH StefH merged commit 9f59211 into master Oct 25, 2025
6 checks passed
@StefH StefH deleted the stef-951-enum_DayOfWeek branch October 25, 2025 08:53
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