Conversation
…(>, >=, <, <=) When comparing two values of the same nullable type (e.g., Instant?) using relational operators, the check for IComparable<> interface was done on the nullable type itself (Nullable<T>), which doesn't directly implement IComparable<>. The fix uses TypeHelper.GetNonNullableType() to get the underlying type first, so that if T implements IComparable<T>, nullable T? also works correctly with relational operators. Fixes: Operator '>' incompatible with operand types 'Instant?' and 'Instant?' Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/b497145d-ba3d-430a-b608-eda596efffdd Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
…mparisons Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/b497145d-ba3d-430a-b608-eda596efffdd Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix operator '>' incompatible with nullable Instant comparison
Fix relational operators failing for nullable IComparable types (e.g., Instant?)
Mar 28, 2026
StefH
requested changes
Mar 28, 2026
test/System.Linq.Dynamic.Core.Tests/TypeConvertors/NodaTimeConverterTests.cs
Show resolved
Hide resolved
test/System.Linq.Dynamic.Core.Tests/TypeConvertors/NodaTimeConverterTests.cs
Show resolved
Hide resolved
Agent-Logs-Url: https://github.com/zzzprojects/System.Linq.Dynamic.Core/sessions/4e543367-6cb4-4164-bd33-fbf0fecca256 Co-authored-by: StefH <249938+StefH@users.noreply.github.com>
StefH
approved these changes
Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relational operators (
>,>=,<,<=) threwOperator '>' incompatible with operand types 'Instant?' and 'Instant?'for any nullable struct type implementingIComparable<T>that isn't explicitly listed inIRelationalSignatures.Root cause
Nullable<T>does not itself implementIComparable<T>— only the underlyingTdoes. InParseComparisonOperator, the interface check was called directly on the nullable type, sotypesAreSameAndImplementCorrectInterfacewasfalseforInstant?, falling through toCheckAndPromoteOperandswhich had no matching signature.Fix
Use
TypeHelper.GetNonNullableType()before the interface check so thatT?is treated the same asTforIComparable<>andIEquatable<>resolution:This applies to both the
IComparable<>check (relational operators) and theIEquatable<>check (equality operators) for consistency.Tests
Added parameterized tests in
NodaTimeConverterTestscovering all relational operators (>,>=,<,<=) as well as equality operators (==,!=) against bothInstantandInstant?properties, with count assertions verifying correct filtering semantics (including thatnullentries satisfynull != valuein C# nullable semantics for the nullable case).📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.