Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyNotFoundException when opening visualizer #126

Open
bart-degreed opened this issue Jul 15, 2021 · 2 comments
Open

KeyNotFoundException when opening visualizer #126

bart-degreed opened this issue Jul 15, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@bart-degreed
Copy link

bart-degreed commented Jul 15, 2021

In response to here.

Thanks, v1.7.115 fixes the exception. It's a bit hard to repro this because we dynamically build expressions. I've tried to create a repro using LINQ code, but the compiler optimizes away the casts, so it results in a different tree.

The best I can offer to repro at the moment is:

This should hit the breakpoint and enable you to activate the visualizer.

@bart-degreed bart-degreed added the bug Something isn't working label Jul 15, 2021
@zspitz
Copy link
Owner

zspitz commented Jul 15, 2021

Thanks for opening this. I'll try to repro when I get a chance.

Could I trouble you to choose the "Factory methods" formatter from within the visualizer on one of these expressions, and provide the output? It generates C# with the factory method calls needed to produce a similar expression. That should be a far more straightforward repro path.

@bart-degreed
Copy link
Author

bart-degreed commented Jul 15, 2021

Yes sure, I wasn't able to do that earlier, due to the crash. See output below. However, I'm not sure how to translate the "not implemented" part.

// using static System.Linq.Expressions.Expression

var todoItem = Parameter(
    typeof(TodoItem),
    "todoItem"
);

Call(
    typeof(Queryable).GetMethod("Where", new[] { typeof(IQueryable<TodoItem>), typeof(Expression<Func<TodoItem, bool>>) }),
    --
-- Not implemented - NodeType: Extension not implemented.
--,
    Quote(
        Lambda(
            AndAlso(
                AndAlso(
                    AndAlso(
                        Call(
                            MakeMemberAccess(todoItem,
                                typeof(TodoItem).GetProperty("Description")
                            ),
                            typeof(string).GetMethod("StartsWith", new[] { typeof(string) }),
                            MakeMemberAccess(
                                Call(
                                    typeof(Tuple).GetMethod("Create", 1, new[] { typeof(string) }),
                                    Constant("T")
                                ),
                                typeof(Tuple<string>).GetProperty("Item1")
                            )
                        ),
                        Equal(
                            MakeMemberAccess(todoItem,
                                typeof(TodoItem).GetProperty("Priority")
                            ),
                            MakeMemberAccess(
                                Call(
                                    typeof(Tuple).GetMethod("Create", 1, new[] { typeof(TodoItemPriority) }),
                                    Constant(TodoItemPriority.Low)
                                ),
                                typeof(Tuple<TodoItemPriority>).GetProperty("Item1")
                            )
                        )
                    ),
                    Not(
                        Equal(
                            MakeMemberAccess(todoItem,
                                typeof(TodoItem).GetProperty("Owner")
                            ),
                            Convert(
                                Constant(null),
                                typeof(Person)
                            )
                        )
                    )
                ),
                Not(
                    Equal(
                        MakeMemberAccess(todoItem,
                            typeof(TodoItem).GetProperty("Assignee")
                        ),
                        Convert(
                            Constant(null),
                            typeof(Person)
                        )
                    )
                )
            ),
            todoItem
        )
    )
)

The Tuple.Create().Item1 calls basically represent constants, but this makes EF Core parameterize the produced SQL.

The models used are in the models directory.

@zspitz zspitz pinned this issue Aug 11, 2021
@zspitz zspitz unpinned this issue Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants