Repository navigation
test: sweep the EF translators for operands mapped as a type their overload does not declare (#295) - #432
Merged
Conversation
…erload does not declare (#295) The translators recognized an overload by its name and argument count, and mapped an operand from what it was not: a RangeSet operand that was neither the multirange nor the element became a range, a value set call's second operand a set, a factory's bounds the element, an aggregate's source ranges. Every answer was right for the overloads that exist, but one added later with another operand type would have been translated as one of them, without an error: RangeSet.Contains(StringSet) became @> over a value set mapped as a range. TranslatorDispatchSweepTests (conventions, no database) hands every public query member over every discovered type to the translator providers of a real context, one operand per declared parameter type, and requires each operand mapped as its declared type and the member's own result type. The translators now map an operand from its declared parameter type and throw MissingArm, naming the overload, for any other; MissingArmTests holds each arm with an overload that does not exist. QueryMembers.Close moves from the translation-support probe so both share it. Found-By: RV Defect-Class: SQL Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 25, 2026
Closed
Merged
Closed
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.
Closes #295
Part of 10.3.0 (#408): it goes ahead of #405, #406 and #191, so the translator arms they add are written under the sweep.
mainfirst, then cherry-picked intorelease/10.x.Problem
The EF translators recognize an overload by its name and argument count, and some then chose an operand's mapping from what the operand was not:
RangeSetcalls (Operand(),AsSet()): anything that wasn't the multirange or the element was mapped as a range.Contains/Removewas assumed.CreateFinite,CreateUnboundedStartandCreateUnboundedEndwere matched by name and argument count, with their bounds assumed to be the element type.Every answer was right today, because only the overloads those arms were written for exist. But an overload added later with another operand type would have been translated as one of them. A
RangeSet.Contains(StringSet)became@>over a value set mapped as a range, with no error and no failing test. That's the receiver-shaped dispatch trap one layer up, and the shape of dotnet/efcore#39329.Change
TranslatorDispatchSweepTests(conventions, no database): every public query member (QueryMembers) over every discovered range and value set type is handed to the translator providers of a real context (UseValueRangesNodaTime(), so EF Core's, Npgsql's and both plugins' translators run in their real order), with one operand per declared parameter type. A translation must map each operand as its declared type and answer the member's own type, and a translator that throws fails the sweep. It also fails if it reaches none of the plugin's six areas, so it can't pass by inspecting nothing.src/**/Query/, likeEngineDispatchConventionTests. That can't see the change it has to catch: the seed adds a public overload in core and touches no translator. The behavioral sweep starts from the public API, as the translation-support inventory does, and judges what the translators produce.MissingArm(anUnreachableExceptionnaming the overload and the operand type) for any other. Declining wouldn't be enough, because EF Core's own translators match by name too, as its collectionContainstookRangeSet.Contains(10.x:RangeSet.ContainsthrowsArgumentExceptionon the EF Core 10 patch that carries dotnet/efcore#37081 #288).ValueRangesMethodCallTranslator:RangeSetoperands go by parameter type, and the three factories are recognized by their whole signature, with any other overload of those names refused. The set-operand arms' unreachable_now throws instead of declining.ValueSetsMethodCallTranslator: the set operands (as the set,IValueSet<T>orIValueSetFactory<TSet, T>) and the element go by parameter type.ValueRangesAggregateMethodCallTranslator: the source must be a sequence of the range or of its multirange.ValueSetsMemberTranslator:CountandIsEmptyare recognized by name and type, and any other declines, since a member has no operand to mis-map.QueryMembers.CloseandMentions: moved fromTranslationSupportProbeTestsso the probe and the sweep share one way of closing a member over a type.oracles.json(silent-default), described indocs/oracles.md, with a rule inAGENTS.md.No answer changes for any existing overload, and no package's public API changes. So there's no changelog row.
Not here: the query interceptor's
RangeSetContains.Equivalenthas the same fallback, sending any other one-argumentContainsto the value overload. That's #320 (and its 10.x port #326), which gets its own PR. The sweep calls the translators directly, so it doesn't reach the interceptor.Tests
MissingArm.rangeset-overload-without-translator-arm.patch(addsRangeSet.Contains(StringSet)in core):MissingArmTests(EF translation tests): each translator is handed an overload that doesn't exist, built as aMethodInfo/PropertyInfowith the declaring type, name and parameters a later one would have:RangeSet.Contains/Union(StringSet),DateRange.CreateFinite(int, int, bool, bool),ValueSetExtensions.Overlaps(StringSet, Int32Set)andContains(StringSet, int),RangeAgg(IEnumerable<IRange<DateOnly>>), and along CountonStringSet. 7/7 pass. With the four translators reverted tomain, all 7 fail: "no exception was thrown", and a non-null translation forCount.🤖 Generated with Claude Code