Skip to content

fix: FindArrayInClosure — search plain objects in object[] (display class pattern)#81

Closed
korchak-aleksandr wants to merge 1 commit intomainfrom
korchak/fix-find-array-in-display-class
Closed

fix: FindArrayInClosure — search plain objects in object[] (display class pattern)#81
korchak-aleksandr wants to merge 1 commit intomainfrom
korchak/fix-find-array-in-display-class

Conversation

@korchak-aleksandr
Copy link
Copy Markdown
Collaborator

Problem

FindArrayInClosure only recursed into Delegate.Target when searching object[] items. But Closure.Constants can contain a plain <>c__DisplayClass object (not a Delegate) that holds the actual array:

Closure
  .Constants = Object[]
    [0] = <>c__DisplayClass15_0   ← plain object, not Delegate
           .allowedIds = int[]    ← the array we need

This caused TryExtractArrayFromSpanExpression to return null for Pattern 2 when used via ExecuteWithQueryCompilation in Mindbox.Framework, resulting in NotSupportedException at runtime.

Fix

One-liner: recurse into any non-null item in object[], not just Delegate.Target.

// before
if (item is Delegate nested && nested.Target != null) {
    var found = FindArrayInClosure(nested.Target, arrayType, depth + 1);

// after
var searchTarget = item is Delegate nested ? nested.Target : item;
if (searchTarget != null) {
    var found = FindArrayInClosure(searchTarget, arrayType, depth + 1);

…lass pattern)

Closure.Constants can contain a plain <>c__DisplayClass holding the array,
not only a Delegate. Recurse into any non-null item, not just Delegate.Target.
@korchak-aleksandr
Copy link
Copy Markdown
Collaborator Author

Closing: Framework handles MemoryExtensions.Contains normalization before expressions reach data-linq, so this fix is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant