Tuesday, October 04, 2005
I've had previous problems with obfuscating code with Dotfuscator.  I seem to be cursed...I've found another one.    Is no one else using this product to obfuscate CLR 2.0 code?  This one is quite wicked.  I spend several hours digging through before and after IL. (which is difficult when the purpose for obfuscation is to make it difficult to read) Here's the recipe for disaster:
  • A generic method with the following characteristics:
    • More than one type parameter.
    • A return type composed of one or more of the method's type parameters other than the first one.

Some C# example signatures (Not useful or practical, just simple examples that show the problem):

static IEnumerable<TValues> FindDictionaryValues<TKey, TValue>(IDictionary<TKey, TValue> dictionary)

static TValue FindAValueInADictionary<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
 
After obfuscation with dotfuscator (even with all obfuscation options disabled), those two signatures will look like:

static IEnumerable<TKey> FindDictionaryValues<TKey, TValue>(IDictionary<TKey, TValue> dictionary)

static TKey FindAValueInADictionary<TKey, TValue>(IDictionary<TKey, TValue> dictionary)
 
What happens is fairly simple.  Any reference to the method's type parameters in the return type becomes a reference to the first type parameter (usually !!0 in the IL).  What's more, this corruption also happens at the call site, which I didn't discover until I had written a regular expression to find and repair the corrupt signatures.
 
It is quite as if generics support was cobbled on as a hurried afterthought/sellingpoint rather than being properly integrated into their codebase.  Their support for 2.0 is poor, even for "beta" status.  However, Preemptive seems interested in fixing the issues.  I'll update when I know more.
 
[UPDATE 10/06/2005] I wanted to let everyone know that PreEmptive is being very responsive to this issue.  They've delivered a patch and I am currently evaluating it.  So far, it appears to fix my issues, but we're working through a few other issues.  Will update when I have more info.
posted on Tuesday, October 04, 2005 2:08:26 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
Related posts:
LinqToStdf now on CodePlex
Image Slicer for Deep Zoom in Silverlight 2
Silverlight limitations and Constrained Callvirt in IL
What are the generic Delegates in the framework for?
What is System.__Canon and why is it on my stack?
Adding support for .ashx-based views in ASP.net MVC
Tracked by:
"Fa Cup Fixtures" (Fa Cup Fixtures) [Trackback]
"highschool girls gone wild" (highschool girls gone wild) [Trackback]
"citizens gas" (citizens gas) [Trackback]
"copy folder to cd" (copy folder to cd) [Trackback]
"used avalanche bass boats" (used avalanche bass boats) [Trackback]
"beach resort Puerto Vallarta" (beach resort Puerto Vallarta) [Trackback]
"persimmon tree" (persimmon tree) [Trackback]
"katrina update" (katrina update) [Trackback]
"hainan Isiand" (hainan Isiand) [Trackback]
"myrtle beach timeshares" (myrtle beach timeshares) [Trackback]
"free information on diabetes" (free information on diabetes) [Trackback]
"allegra kuhn" (allegra kuhn) [Trackback]
"bed and breakfast maine" (bed and breakfast maine) [Trackback]
"anti deppresant Celexa" (anti deppresant Celexa) [Trackback]
"columbia greene community college" (columbia greene community college) [Trackback]
"asian bitches online" (asian bitches online) [Trackback]
"online finance textbooks" (online finance textbooks) [Trackback]
"freshman mandated to live in dorms" (freshman mandated to live in dorms) [Trackback]
"yamaha keyboards" (yamaha keyboards) [Trackback]
"narrow water ireland" (narrow water ireland) [Trackback]
"69 ford mustang" (69 ford mustang) [Trackback]
"isolate rs232" (isolate rs232) [Trackback]
"men%27s two-tone Tag Heuer watches" (men%27s two-tone Tag Heuer watches) [Trackback]
"orchid lore" (orchid lore) [Trackback]
"cum on face prague escorts" (cum on face prague escorts) [Trackback]
"advertising comps" (advertising comps) [Trackback]
"Suunto sm-36" (Suunto sm-36) [Trackback]
"energy audits" (energy audits) [Trackback]
"2004 suzuki marauder 1600 horsepower" (2004 suzuki marauder 1600 horsepower) [Trackback]