Generic Obscenity

by Ivan Hamilton 12/12/2007 6:33:00 PM

I've been trying to fix outstanding issues in my MonoMerge build and most problems appear to resolve around generics.

I have 3 test assemblies (1 EXE, 2 DLL) that I use to test. The EXE references the two DLLs and they reference each other. To test, I build the 3 assemblies, Merge the three assemblies into 1, disassemble the 3 original and 1 merged assemblies. I then run a custom little tool over the IL text to compare the method bodies. The custom tool is needed because the order of items in the merged assembly isn't preserved.

My little test assemblies only cover what my mind can come up with... and I'm pretty gentle. For a final test, I use "the most terrifying assembly for generics stuff: the great C5 library". I was introduced to the C5 Generic Collection Library by a jbevain post. He was happy that Cecil could round-trip C5 (I don't know how he tested the result). So that seemed like a good test for MonoMerge. My god, C5 IL looks like an exclamation mark factory exploded. Here's a couple of examples:

.method public virtual  hidebysig  newslot instance default class C5.IList`1<!!V> Map<V> (class C5.Fun`2<!T, !!V> mapper)  cil managed
IL_0015:  call instance class C5.IList`1<!!0> class C5.ArrayList`1<!T>::map<!!0> (class C5.Fun`2<!0,!!0>, class C5.ArrayList`1<!!0>)

Ugly as it may seem, it is a very good test. There have been quite a number of possible generic usage scenarios that I wouldn't have thought up myself.

At this point, I'll state that there's no way in the world I could debug the issues I'm having without ILDasm, PEVerify & MonoDis. If you ever try assembly manipulation, you can not live without these.

After undoing some work (that I shouldn't have done), my own tests appear to pass (again), but C5 brings everything crashing down (in new and interesting ways). Argh!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

.NET

Related posts

Comments

Add comment


 

biuquote
Loading



Powered by BlogEngine.NET 1.3.1.30
Original theme by Mads Kristensen

About the author

Name of author Ivan Hamilton
"My inner nerd can beat up your inner nerd."

E-mail me Send mail

Adsense

Calendar

<<  January 2018  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Recent comments

Tags

None

    Entropy

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2018

    Sign in