Closed rodro75 closed 6 years ago
Hello @rodro75 ,
You are 100% right,
The ExpandoObject
make static type not working as expected. The "String" is considered as being part of the ExpandoObject
which is obviously wrong.
We added a temporary fix this week in the v2.4.13 since someone else reported us a similar issue. Release Note: https://github.com/zzzprojects/Eval-Expression.NET/releases/tag/v2.4.13
By setting UseTypeBeforeDynamic
to true, our code will look at the type list before mapping it to the ExpandoObject.
We hope to eventually provide a better fix.
Best Regards,
Jonathan
Thanks @JonathanMagnan .
Unfortunately my use case is not covered by the new setting, which works only when the Expando is the root object.
The test CanReferenceStringMethodsWhenExpandoInsideAnonymousDataContext still fails. I also tried not to use anonymous type as the root, by creating a class like this:
public class DataContext { public DataContext() { System = new ExpandoObject(); Custom = new ExpandoObject(); AdditionalInfo = new ExpandoObject(); } public dynamic System { get; } public dynamic Custom { get; } public dynamic AdditionalInfo { get; } }
but still no luck! Even using Expando containing Expandos.
I attached the updated unit tests.
Please let me know if there is something I can do, even a temporary hack.
Thank you!
Hello @rodro75 ,
Thank you for reporting,
We will look at it this Monday.
Best Regards,
Jonathan
Hello @rodro75 ,
The v2.4.16 has been released.
All your units test are now passing with this version ;) We still have some improvement to do with Expando but at least this basic case now work.
Let me know if everything works correctly as well on your side.
Best Regards,
Jonathan
Oh, great!
I will try again with Expandos and see if I can get rid of the need to generate types dynamically.
I'll let you know, thank you very much.
-Rodrigo-
Hello @rodro75 ,
This issue will be closed since it has been resolved.
Feel free to reopen it if you feel otherwise.
Best Regards,
Jonathan
Hi,
I'm having a hard time figuring out why I cannot reference String.IsNullOrEmpty(...) and I found that it really depends on the data that is sent in as a parameter! Sometimes the String alias is getting lost.
So I wrote some unit tests to figure out when and why. It looks like the ExpandoObject is causing the bug, both when it's used as the root data object or as a second-level data object.
In my use case I have a root object that exposes 2 properties, which need to be dynamic. At the root level we have: System and Custom. Both of them have different members from time to time, so they need to be either a dictionary or an ExpandoObject. I would prefere the latter because my clients can use a nicer syntax (Custom.Foo.Length instead of Custom["Foo"].Length for example).
I attached my unit tests.
EvalTests.cs.txt
Can you please help me? I'm using version 2.4.12
Thanks!