Skip to content

fix: RangeSetContains.Equivalent refuses a Contains overload it has no static form for (#320) - #434

Merged
CaffeinatedCoder merged 1 commit into
mainfrom
chore/320-rangeset-contains-equivalent
Oct 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
mainfrom
chore/320-rangeset-contains-equivalent

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #320

The interceptor half of #295 (PR #432). Its 10.x port is #326, which follows #433 (the port of #295), because the refusal here is #295's MissingArm.

Problem

RangeSetContains.Equivalent maps a RangeSet<TRange, T>.Contains instance method to its static form by operand type: Set when the operand is the set, Range when it's any IRange<>, and Value for anything else. Only the three overloads exist today, so every answer is right. But an overload added later, such as Contains(StringSet), would be routed to Value<TRange, T>(set, T). The interceptor's Expression.Call would then throw an ArgumentException at query compile that names neither the overload nor the missing arm. That's the fallback-arm shape AGENTS.md forbids, and the translator sweep from #295 doesn't reach it, because it calls the translators directly.

Change

  • Equivalent matches each overload by its exact operand type: the set, IRange<T> over the set's element, or T. Any other one-argument Contains throws MissingArm, naming the overload and its operand type. The old IRange<> test also accepted an IRange over another element type.
  • MissingArm's summary and message now cover the interceptor as well as the translators, and the message drops "in the translator". The AGENTS.md rule from Sweep the EF translators for name-only dispatch and default operand classification #295 names Equivalent too.

Internal, with no answer changes and no public API change, so there's no changelog row.

Tests

Two tests in MissingArmTests (EF translation tests):

Proved three ways, with RangeSetContains.cs from main and the seed rangeset-overload-without-translator-arm.patch from #295:

  1. Fix reverted: the refusal test fails ("no exception was thrown"), and the reflection test passes on the three overloads that exist.
  2. Fix reverted, seed applied: the reflection test fails too, with "Contains(StringSet) maps to Value[DateRange,DateOnly](RangeSet…, DateOnly)", the silent mis-routing this issue describes.
  3. Fix restored, seed applied: the reflection test fails with the refusal, "RangeSet<DateRange, DateOnly>.Contains(StringSet) has no translation for an operand of type StringSet".

Full runs, locally on the .NET 11 RC2 SDK: conventions 417/417, EF translation 311/311, NodaTime EF translation 83/83, core 1,399/1,399, NodaTime 239/239, ASP.NET Core 92/92, integration on PostgreSQL 16 306/306.

🤖 Generated with Claude Code

…o static form for (#320)

Equivalent mapped a RangeSet.Contains instance method to its static form by
operand type, and sent every operand that was neither the set nor an IRange<>
to the value form. An overload added later, such as Contains(StringSet), would
then fail in Expression.Call with an ArgumentException naming neither the
overload nor the missing arm. Each overload is now matched by its exact
operand type (the set, IRange<T> over the set's element, or T), and any other
throws MissingArm naming it, as the translators do since #295.

MissingArmTests holds it with a reflection test over every public
one-argument Contains, which a new overload fails, and with an overload that
does not exist.

Found-By: RV
Defect-Class: SQL
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 11.0.0 milestone Oct 25, 2026
@CaffeinatedCoder CaffeinatedCoder added chore Build, CI, packaging, refactoring with no behaviour change area/range-set RangeSet and multirange algebra package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL labels Oct 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 8b32901 into main Oct 25, 2026
14 of 15 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the chore/320-rangeset-contains-equivalent branch October 25, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/range-set RangeSet and multirange algebra chore Build, CI, packaging, refactoring with no behaviour change package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

main: RangeSetContains.Equivalent hands any other one-argument Contains on RangeSet to the value overload

1 participant