Sorry guys. Stupid mistake from my side. Case closed.

On 15 Sty, 11:38, Janusz Lembicz <[email protected]> wrote:
> Sorry guys for the mess above. I haven't noticed the links Reflector
> is adding. Corrected version of IL below:
>
> .method public hidebysig specialname instance string
> get_StringProperty() cil managed
> {
>     .maxstack 1
>     .locals init (
>         [0] string str)
>     L_0000: ldarg.0
> ->  L_0001: ldfld int32 DllB.B::integer INSTEAD OF : L_0001: ldfld
> string DllA.A::<StringProperty>k__BackingField
>     L_0006: stloc.0
>     L_0007: br.s L_0009
>     L_0009: ldloc.0
>     L_000a: ret
>
> }
>
> .method public hidebysig specialname instance void
> set_StringProperty(string 'value') cil managed
> {
>     .maxstack 8
>     L_0000: ldarg.0
>     L_0001: ldarg.1
> ->  L_0002: stfld int32 DllB.B::integer INSTEAD OF : L_0002: stfld
> string DllA.A::<StringProperty>k__BackingField
>     L_0007: ret
>
> }
>
> Janusz
>
> On 15 Sty, 00:46, Janusz Lembicz <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I'm working on an assembly merging utility. Recently I've encountered a
> > strange problem.
> > There are two classes in separate assemblies:
>
> >  public class A
> >  {
> >         public string StringProperty { get; set; }
> >  }
>
> >  public class B
> >  {
> >         public int integer;
> >  }
>
> > I'm copying all elements from both of them to an output assembly and it
> > works fine (peverify doesn't report any errors) when I first copy elements
> > from the DllB containing class B and then from  DllA containing class A.
> > When I do it in the opposite order I get following errors:
>
> > [IL]: Error: [merged.dll : DllA.A::get_StringProperty][offset
> > 0x00000001][found ref ('this' ptr)'DllA.A'][expected ref 'DllB.B']
> > Unexpected type on the stack.
> > [IL]: Error: [merged.dll : DllA.A::get_StringProperty][offset
> > 0x00000006][found Int32][expected ref 'System.String'] Unexpected type on
> > the stack.
> > [IL]: Error: [merged.dll : DllA.A::set_StringProperty][offset
> > 0x00000002][found ref ('this' ptr) 'DllA.A'][expected ref 'DllB.B']
> > Unexpected type on the stack.
> > [IL]: Error: [merged.dll : DllA.A::set_StringProperty][offset
> > 0x00000002][found ref 'System.String'][expected Int32] Unexpected type on
> > the stack.
>
> > After checking with Reflector I noticed, that getter and setter methods of
> > StringProperty, when loading the string backing field, are trying to load
> > the integer field defined in class B instead.
>
> >  .method public hidebysig specialname instance string
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > *get_StringProperty
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://merged:...>*()
> > cil managed
> > {
> >     .maxstack 1
> >     .locals init (
> >         [0] string
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > *str*)
> >     L_0000: ldarg.0
> > ->  L_0001: ldfld int32
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > DllB.B 
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://merged:...>::integer
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://merged:...>
> > INSTEAD OF : L_0001: ldfld string
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > DllA.A 
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://DllA:1....>::<StringProperty>k__BackingField
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://DllA:1....<StringProperty>k__BackingField:String>
> >     L_0006: stloc.0
> >     L_0007: br.s L_0009
> >     L_0009: ldloc.0
> >     L_000a: ret
>
> > }
>
> >    .method public hidebysig specialname instance void
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > *set_StringProperty
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://merged:...)>*(string
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > 'value') cil managed
> > {
> >     .maxstack 8
> >     L_0000: ldarg.0
> >     L_0001: ldarg.1
> > ->  L_0002: stfld int32
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > DllB.B 
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://merged:...>::integer
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://merged:...>
> > INSTEAD OF : L_0002: stfld string
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorli...>
> > DllA.A 
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://DllA:1....>::<StringProperty>k__BackingField
> > <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://DllA:1....<StringProperty>k__BackingField:String>
> >     L_0007: ret
>
> > }
>
> > Something is getting messed up with MetadataTokens, but I cannot
> > really identify what. Any help would be appreciated. I'm enclosing a
> > solution I've created to test this issue.
>
> > To decrease the code size I've made it handle only this particular
> > case so I wouldn't try changing the test classes much if I were you.
>
> > Thank you in advance,
>
> > Janusz
>
> >  Merger.zip
> > 12KZobaczPobierz

-- 
--
mono-cecil

Reply via email to