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

Can't access members of objects other than the function parameter #209

Merged
merged 4 commits into from
Apr 15, 2015

Conversation

mfenniak
Copy link
Owner

Some attempts to access a member of an object in a LINQ expression tree, other than the parameter, don't work. In particular, using the new regex match operator from #107 and then accessing fields on the result don't work. This seems to be caused by BaseExpression.cs only supporting static members, not any random expression type for which a IObjectDatumConverter is available.

First attempt to fix this caused an issue where anonymous types that could & should be evaluated client-side are turning into server-side serialized objects. In particular, variables referenced from the function scope by a delegate. Was able to address this with a hack in the AnonymousTypeDatumConverterFactory, but that doesn't fix the same problem on the newtonsoft converters.

Was able to address the problem in the first approach by identifying that the expression nodes referenced a constant, and using client-side conversion for the constants. The hack disappeared, tests passed. Fixed up some code duplication and this PR is good to go.

@mfenniak mfenniak force-pushed the arbitrary_member_access branch 2 times, most recently from 7e2b51f to 7ee7bb8 Compare April 15, 2015 13:19
mfenniak and others added 4 commits April 15, 2015 07:19
Removes the hacky fix in AnonymousTypeDatumConverterFactory and also
works for the Newtonsoft converter equally well.
Now that BaseExpression supports MemberAccess on any type, the
single/two parameter lambda converters don’t have to have duplicate
code doing the same thing.  They still need a special case to handle
Convert nodes on the parameter object.

GenericTypeConstraintExpressionTests required a change; accessing a
member on the interface here doesn’t seem right because we don’t know
how to treat that interface.  So, I supplied the correct datum
converter factory for that interface.  Code makes more sense now, and
tests pass.  For the original reported issue #169 it should be
functionally equivalent as that issue was using the newtonsoft
converter which presumably would work on the interface as well.
mfenniak added a commit that referenced this pull request Apr 15, 2015
Allow access to members of objects other than the function parameter
@mfenniak mfenniak merged commit d97e3a3 into master Apr 15, 2015
@mfenniak mfenniak deleted the arbitrary_member_access branch April 15, 2015 14:25
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