Fix #4610 net10.0 follow-up: enum-aware Contains path for MemoryExtensions#4616
Merged
Merged
Conversation
…sions #4610 fixed `values.Contains(p.EnumMember)` against an EnumStorage.AsString document member by routing the case through `EnumIsOneOfWhereFragment` in `EnumerableContains.Parse`. That worked on net9.0 but the regression test file failed on net10.0 in CI for PR #4613 and #4615 with the same `Writing values of 'YourEnum[]' is not supported for parameters having NpgsqlDbType '-2147483639'` shape from the original bug. Root cause: on net10.0 the C# compiler resolves `array.Contains(x)` to `MemoryExtensions.Contains` (via the implicit `T[]` → `ReadOnlySpan<T>` conversion), not `Enumerable.Contains`. The match runs through `MemoryExtensionsContains.Parse`, not `EnumerableContains.Parse`, and the former had the identical enum-array-as-raw-CommandParameter bug — #4610's fix had only patched the latter. Mirror the same fix into `MemoryExtensionsContains.Parse`. The existing Bug_enum_asstring_array_contains regression tests now cover both parsers because they target the user-facing shape (`values.Contains(p.Status)`) and each .NET version routes that to a different parser. Verified: - Bug_enum_asstring_array_contains: 6/6 pass on net9.0 - Bug_enum_asstring_array_contains: 6/6 pass on net10.0 - Full LinqTests on net10.0: 1269 passed, 0 failed Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Jun 3, 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.
Context
#4610 fixed
values.Contains(p.EnumMember)against anEnumStorage.AsStringdocument member by routing the case throughEnumIsOneOfWhereFragmentinEnumerableContains.Parse. That worked on net9.0 locally and in CI, but the regression test file is now failing on net10.0 in CI for both open PRs (#4613, #4615) with the sameWriting values of 'YourEnum[]' is not supported for parameters having NpgsqlDbType '-2147483639'shape from the original bug.Root cause
On net10.0 the C# compiler resolves
array.Contains(x)toMemoryExtensions.Containsvia the implicitT[]→ReadOnlySpan<T>conversion — notEnumerable.Contains. Marten's parser registry has a dedicatedMemoryExtensionsContainsparser atLinqParsing.cs:52(ahead ofEnumerableContainsat line 53) precisely to handle that case, and itsParsehad the same raw-CommandParameter-from-enum-array bug:#4610's fix only patched
EnumerableContains—MemoryExtensionsContainswas missed because the local test runs were on net9.0 only.Fix
Mirror the same enum-aware branch into
MemoryExtensionsContains.Parse:The existing
Bug_enum_asstring_array_containsregression tests already cover both parsers — they target the user-facing shape (values.Contains(p.Status)), and each .NET version routes that shape to a different parser.Verified
Bug_enum_asstring_array_contains: 6/6 pass on net9.0Bug_enum_asstring_array_contains: 6/6 pass on net10.0 ← the regressionOnce this lands, the CI failures on #4613 and #4615 should clear with a rerun (they're not touching either parser, just running into the same flaky net10 fallout).
🤖 Generated with Claude Code