hazzik / DelegateDecompiler

A library which is able to decompile a delegate or a method body to its lambda representation
MIT License
522 stars 62 forks source link

String.Concat decompile issue #142

Closed magicmoux closed 5 years ago

magicmoux commented 5 years ago

Hi @hazzik,

I'm not sure wether it's an issue that should be addressed by DD but I noticed errors on EFCore tests :

Message:   Expected and actual are both <System.Collections.Generic.List`1[System.String]> with 4 elements
  Values differ at index [0]
  Expected string length 22 but was 18. Strings differ at index 17.
  Expected: "Apis mellifera : False"
  But was:  "Apis mellifera : 0"

It seems that non-string serialization is provider-related (the same TestSelectMultipleLevelsOfAbstractMembersOverTphHierarchy test works perfectly well with EF6). After some tests, I could solve part of the problem but the solution won't work on nullables (either Nullable<> or non-ValueType expressions)

The question is: should we force a ToString call on Concat for non-string values occurrences ? The only other alternative is to rework the source lambda expression like :

p => p.Species + " : " + (p.IsPet ? Boolean.TrueString : Boolean.FalseString)

which seems pretty cumbersome to me.

Any Idea ? Max.

hazzik commented 5 years ago

The expression tree looks correct for that test, so I believe the issue is in the EF itself.

magicmoux commented 5 years ago

I totally agree with you that the issue is in EFCore. Maybe it would be advisable to state into the doc that serialization may be provider-specific and not addressed by DD thus should be handled specificly then.