Problem processing MemberBinding expression that contains initilization of subclass

41 views
Skip to first unread message

Lei Yao

unread,
Jan 30, 2015, 11:08:26 PM1/30/15
to re-mot...@googlegroups.com
Hello guys,

I might found a bug in relinq expression tree visitor, when playing with EF7.

And I possibly found the root cause and fix, in class Remotion.Linq.Clauses.ExpressionTreeVisitors.AccessorFindingExpressionTreeVisitor, the method GetMemberAccessExpression should check if the input expression is the member’s declaring type (or subclass of declaring type), and do a conversion when necessary. Of course I could be wrong, or perhaps there's other more elegant way to fix.

private Expression GetMemberAccessExpression (Expression input, MemberInfo member) {

// This is the fix part <<
if (!member.DeclaringType.GetTypeInfo().IsAssignableFrom(input.Type.GetTypeInfo()))
{
input = Expression.Convert(input, member.DeclaringType);
}
// >> This is the fix part

  var methodInfo = member as MethodInfo;
  if (methodInfo != null)
    return Expression.Call (input, methodInfo);
  else
    return Expression.MakeMemberAccess (input, member);
}

Best regards,
Ray

Michael Ketting

unread,
Jan 31, 2015, 4:42:14 AM1/31/15
to re-mot...@googlegroups.com
Hi Ray!

Thanks for reporting this. I'll check a few things first and will then open an issue on our issue tracker (https://www.re-motion.org/jira/browse/RMLNQ)

Best regards, Michael

Michael Ketting

unread,
Jan 31, 2015, 10:18:59 AM1/31/15
to re-mot...@googlegroups.com
Hi Ray!

I have now created an issue for this: https://www.re-motion.org/jira/browse/RMLNQ-54

I reduced the sample to its most-likely minimal case and will see if I can reproduce the issue. If not, I'll most likely require a repro-sample, but hopefully, the situation is straight forward :)

Best regards, Michael

Lei Yao

unread,
Feb 2, 2015, 6:09:08 AM2/2/15
to re-mot...@googlegroups.com
Thank you Michael,

If anything I could help, please let me know.
And one more thing, will the fix be ported to 1.1.5 release? Since EF7 depends on that version, and we depends on EF7.

Best regards,
Ray

Michael Ketting

unread,
Feb 2, 2015, 6:38:43 AM2/2/15
to re-mot...@googlegroups.com
Hi Ray!

No, the release will be in the 2.0.0 alpha range (with an RTM version in time for EF7 RTM). That shouldn't be an issue since v2 just means we're now using SemVer.

Best regards, Michael

Michael Ketting

unread,
Feb 2, 2015, 9:00:38 AM2/2/15
to re-mot...@googlegroups.com
Hi Ray!

Help's always appriciated!
We have a Contrib-Guide at https://relinq.codeplex.com/wikipage?title=Contributing%20to%20re-linq

On my side, it looks like it will be the weekend till I get to dig into it myself, so if you want to give the issue a headstart, a fine integration test in adddition to the bugfix and unit test would be appreciated.
With the issue you found, the integration test would be located at UnitTests/Parsing/QueryParserIntegrationTests/NewWithAddedMembersQueryParserIntegrationTest.cs in case you want to dig into the depth of how expression trees work :)

Best regards, Michael

Lei Yao

unread,
Feb 4, 2015, 7:01:12 AM2/4/15
to re-mot...@googlegroups.com
Hi Michael,

We're not in that a hurry, weekend is totally ok for us, we're currently unblocked with a locally built Remotion.Linq, strong name verification skipped.
re-linq is really amazing and powerful, I'm eager to contribute it but I found I'm not familiar with the test framework, don't know how to initiate a test run or debug it. Yeah I'm a VS guy who only plays with IDE.
I'll try to get use to NUnit first and then maybe next time I can do some real contribution.

Best regards,
Ray

Michael Ketting

unread,
Feb 7, 2015, 8:13:04 AM2/7/15
to re-mot...@googlegroups.com
Hi Ray!

Great to know re the local build.

I've set up a pull-request for this. The solution is basically your suggestion with some code-refactoring applied :)

https://github.com/re-motion/Relinq/pull/1

I'll release a new alpha-build once it's reviewed and merged.

Best regards, Michael

Michael Ketting

unread,
Feb 8, 2015, 3:37:50 PM2/8/15
to re-mot...@googlegroups.com
Hi Ray!

v2.0.0-alpha.2 is now released and up on NuGet.

Best regards, Michael

Lei Yao

unread,
Feb 10, 2015, 3:08:26 AM2/10/15
to re-mot...@googlegroups.com
Thank you Michael, I've verified with the new release that the problem is fixed.

Thanks,
Ray

Michael Ketting

unread,
Feb 11, 2015, 2:03:25 AM2/11/15
to re-mot...@googlegroups.com
Great. Thanks for the update!
Best regards, Michael
Reply all
Reply to author
Forward
0 new messages