efcore icon indicating copy to clipboard operation
efcore copied to clipboard

ExpressionEqualityComparer NullReferenceException

Open EricABC opened this issue 10 years ago • 4 comments

Some low-hanging fruit here, nameless parameters throw a NullReferenceException on ParameterExpression.Name.GetHashCode(); inside ExpressionEqualityComparer line 101 when dynamically building expression trees (ie. using 'Expression.Parameter(typeof(something))' without a parameter name).

EricABC avatar Feb 12 '16 22:02 EricABC

@EricABC is this manifesting in some way when you are using EF? Or just a theoretical thing that could be hit based on looking at the code?

rowanmiller avatar Feb 12 '16 23:02 rowanmiller

Yup, it did in fact occur for me. I have a sparse-matrix model with dynamic stored schema where I build a set of property filters on a query dynamically. On one of my properties didn't have a name and that was the culprit. As soon as I named it the problem was solved for me and everything worked like a charm. Admittedly I have a few customizations in place, including an implementation for https://github.com/aspnet/EntityFramework/issues/242 that inherits off of a few internal namespaced items (just serializes stuff in shadow properties), but none of it would have effected the call path to caching the query, which is what ultimately gets the hashcode. If you prefer I can get you an unadulterated repro.

EricABC avatar Feb 13 '16 00:02 EricABC

Repro at https://github.com/EricABC/EFBugReproIssue4549

EricABC avatar Feb 13 '16 01:02 EricABC

fixed in da1a1a839f869564482d37b519c52e3b2b95b1c6

maumar avatar Feb 16 '16 21:02 maumar