Invalid Child_XXX call

Invalid Child_XXX call

Old forum URL: forums.lhotka.net/forums/t/7581.aspx


jureleskovec posted on Monday, September 07, 2009

Test case:

1) Parent calls UpdateChildren(this) in the DataPortal_Update method.
2) The call is SUCCESSFULLY dispatched to the child's method Child_Update(ISomeInterface parent).

The problem is that the parent object is not of type 'ISomeInterface', so I assume csla doesn't check that.

Another interesting thing here is that runtime does not check the parameter type compatibily when calling methods and passing params using .NET reflection.


-- Jure

RockfordLhotka replied on Monday, September 07, 2009

You are more than welcome to take a look at MethodCaller and help to improve the code used to simulate method overload resolution. It is really complex, and gives a person a great deal of respect for compiler authors (since normally compilers do this for you).

No, CSLA doesn't do everything the compiler does. I'm not entirely sure that's realistic, since the compiler does it at build time, and MethodCaller does this at runtime - so doing everything the compiler does would almost certainly have a serious performance impact (and not a good one).

Of course there's nothing I can do about the fact that the compiler can't do parameter type checking when the call routes through the data portal.

If you really need compiler type checking, then you should not use the child data portal, and instead should use the old style of having the parent object explicitly call methods on the child objects. That gives you strong typing and compile-time checking, at the cost of you having to do the plumbing work the data portal does for you (calling MarkAsChild/MarkNew/MarkOld/etc).

Copyright (c) Marimer LLC