schotime / NPoco

Simple microORM that maps the results of a query onto a POCO object. Project based on Schotime's branch of PetaPoco
Apache License 2.0
848 stars 302 forks source link

Difference between NPoco version 5.3.0 and 5.3.1 #644

Closed mikkelbu closed 3 years ago

mikkelbu commented 3 years ago

We got notified by dependabot that a new version of NPoco was pushed. When we examined the changes we were a bit unsure whether there were any changes as 5.3.1 is not mentioned in this repository.

I've compared the nuget files using fuget.org and not found any differences at the API level, but if I compare the IL I can see that the code for the lambda expression for ComplexPropertiesWhere in FluentMappingConfiguration,cs is different (this is the only non-trivial difference as far as I can tell).

https://github.com/schotime/NPoco/blob/ea9db72d0d89ee532ffe3a2d2cc1bf245ecf814d/src/NPoco/FluentMappings/FluentMappingConfiguration.cs#L176-L177

In 5.3.0 the IL generated for ComplexPropertiesWhere is similar to the one generated for ReferencePropertiesWhere which makes sense looking at the code on master, but in 5.3.1 is it different.

IL in 5.3.0

    .method /*06000B08*/ assembly hidebysig 
            instance bool  '<ProcessSettings>b__5_14'(class [netstandard/*23000001*/]System.Reflection.MemberInfo/*01000066*/ x) cil managed
    // SIG: 20 01 02 12 81 99
    {
      // Method begins at RVA 0x23bb2
      // Code size       37 (0x25)
      .maxstack  8
      IL_0000:  /* 03   |                  */ ldarg.1
      IL_0001:  /* 28   | (06)0003D1       */ call       class [netstandard/*23000001*/]System.Type/*01000025*/ NPoco.ReflectionUtils/*02000057*/::GetMemberInfoType(class [netstandard/*23000001*/]System.Reflection.MemberInfo/*01000066*/) /* 060003D1 */
      IL_0006:  /* 28   | (06)000444       */ call       bool NPoco.TypeHelpers/*02000069*/::IsAClass(class [netstandard/*23000001*/]System.Type/*01000025*/) /* 06000444 */
      IL_000b:  /* 2C   | 16               */ brfalse.s  IL_0023

      IL_000d:  /* 03   |                  */ ldarg.1
      IL_000e:  /* D0   | (02)000018       */ ldtoken    NPoco.ComplexMappingAttribute/*02000018*/
      IL_0013:  /* 28   | (0A)00007D       */ call       class [netstandard/*23000001*/]System.Type/*01000025*/ [netstandard/*23000001*/]System.Type/*01000025*/::GetTypeFromHandle(valuetype [netstandard/*23000001*/]System.RuntimeTypeHandle/*010000BA*/) /* 0A00007D */
      IL_0018:  /* 28   | (06)0003DB       */ call       class [netstandard/*23000001*/]System.Collections.Generic.IEnumerable`1/*01000028*/<class [netstandard/*23000001*/]System.Attribute/*01000018*/> NPoco.ReflectionUtils/*02000057*/::GetCustomAttributes(class [netstandard/*23000001*/]System.Reflection.MemberInfo/*01000066*/,
                                                                                                                                                                                                                                                                 class [netstandard/*23000001*/]System.Type/*01000025*/) /* 060003DB */
      IL_001d:  /* 28   | (2B)0001A8       */ call       bool [netstandard/*23000001*/]System.Linq.Enumerable/*010000BB*/::Any<class [netstandard/*23000001*/]System.Attribute/*01000018*/>(class [netstandard/*23000001*/]System.Collections.Generic.IEnumerable`1/*01000028*/<!!0>) /* 2B0001A8 */
      IL_0022:  /* 2A   |                  */ ret

      IL_0023:  /* 16   |                  */ ldc.i4.0
      IL_0024:  /* 2A   |                  */ ret
    } // end of method '<>c'::'<ProcessSettings>b__5_14'

IL in 5.3.1

    .method /*06000B08*/ assembly hidebysig 
            instance bool  '<ProcessSettings>b__5_14'(class [netstandard/*23000001*/]System.Reflection.MemberInfo/*01000066*/ x) cil managed
    // SIG: 20 01 02 12 81 99
    {
      // Method begins at RVA 0x23bb2
      // Code size       53 (0x35)
      .maxstack  8
      IL_0000:  /* 03   |                  */ ldarg.1
      IL_0001:  /* 28   | (06)0003D1       */ call       class [netstandard/*23000001*/]System.Type/*01000025*/ NPoco.ReflectionUtils/*02000057*/::GetMemberInfoType(class [netstandard/*23000001*/]System.Reflection.MemberInfo/*01000066*/) /* 060003D1 */
      IL_0006:  /* 28   | (06)000444       */ call       bool NPoco.TypeHelpers/*02000069*/::IsAClass(class [netstandard/*23000001*/]System.Type/*01000025*/) /* 06000444 */
      IL_000b:  /* 2C   | 26               */ brfalse.s  IL_0033

      IL_000d:  /* 03   |                  */ ldarg.1
      IL_000e:  /* D0   | (02)000018       */ ldtoken    NPoco.ComplexMappingAttribute/*02000018*/
      IL_0013:  /* 28   | (0A)00007D       */ call       class [netstandard/*23000001*/]System.Type/*01000025*/ [netstandard/*23000001*/]System.Type/*01000025*/::GetTypeFromHandle(valuetype [netstandard/*23000001*/]System.RuntimeTypeHandle/*010000BA*/) /* 0A00007D */
      IL_0018:  /* 28   | (06)0003DB       */ call       class [netstandard/*23000001*/]System.Collections.Generic.IEnumerable`1/*01000028*/<class [netstandard/*23000001*/]System.Attribute/*01000018*/> NPoco.ReflectionUtils/*02000057*/::GetCustomAttributes(class [netstandard/*23000001*/]System.Reflection.MemberInfo/*01000066*/,
                                                                                                                                                                                                                                                                 class [netstandard/*23000001*/]System.Type/*01000025*/) /* 060003DB */
      IL_001d:  /* 28   | (2B)0001A9       */ call       class [netstandard/*23000001*/]System.Collections.Generic.IEnumerable`1/*01000028*/<!!0> [netstandard/*23000001*/]System.Linq.Enumerable/*010000BB*/::Cast<class NPoco.ComplexMappingAttribute/*02000018*/>(class [netstandard/*23000001*/]System.Collections.IEnumerable/*0100005B*/) /* 2B0001A9 */
      IL_0022:  /* 28   | (2B)0001AA       */ call       !!0 [netstandard/*23000001*/]System.Linq.Enumerable/*010000BB*/::FirstOrDefault<class NPoco.ComplexMappingAttribute/*02000018*/>(class [netstandard/*23000001*/]System.Collections.Generic.IEnumerable`1/*01000028*/<!!0>) /* 2B0001AA */
      IL_0027:  /* 25   |                  */ dup
      IL_0028:  /* 2D   | 03               */ brtrue.s   IL_002d

      IL_002a:  /* 26   |                  */ pop
      IL_002b:  /* 16   |                  */ ldc.i4.0
      IL_002c:  /* 2A   |                  */ ret

      IL_002d:  /* 28   | (06)00018E       */ call       instance bool NPoco.ComplexMappingAttribute/*02000018*/::get_ComplexMapping() /* 0600018E */
      IL_0032:  /* 2A   |                  */ ret

      IL_0033:  /* 16   |                  */ ldc.i4.0
      IL_0034:  /* 2A   |                  */ ret
    } // end of method '<>c'::'<ProcessSettings>b__5_14'

So it seems that before we just asked whether the attribute existed. Now we also access the property ComplexMapping (on ComplexMappingAttribute). Was this just a change forgotten in https://github.com/schotime/NPoco/commit/2e96dbc533fa5d91af62082113933b51f08ba914#diff-d1f54cbfb911590df55eb5a792983526a9eb5a4aff0a786698e648841153d27e that have not been pushed yet ?

EDIT: It looks like the two versions were created on the same day - August 25.

schotime commented 3 years ago

Apologies. It had been committed locally and looks to have failed the push. Should be up to date now.

mikkelbu commented 3 years ago

No problem. We just try to check what the changes are when we are bumping our dependencies. Thanks for the quick answer 👍.