Linq and Anonymous Types

gwernergwerner Posts: 3
edited December 2, 2010 1:39PM in SmartAssembly 5
First of all, love SmartAssembly. It was probably the easiest obfuscation method that my team tried.

There is one thing that we find we have to constantly workaround, however. Assume you have a function that looks like this on a web form:
void whatever(someclass inputData)
    var mydata = from s in inputData
                         orderby s.Name
                         select new { s.Name, s.Value, Calculated = s.Field+5 };
    myDataGrid.DataSource = mydata;

If obfuscation is enabled in SmartAssembly, this web form will not work, because the anonymous type generated in mydata will have its types renamed. When you go to databind, the field names will be different and the program will fail at runtime.

I realize that as a workaround we could create actual types instead of using anonymous types, and as long as we make them protected or public it won't be obfuscated. Unfortunately, however, there are literally hundreds of these types of statements in our code and, in all reality, it defeats the purpose of anonymous types.

Is there a setting or something somewhere to exclude anonymous types from obfuscation?
Grady Werner
SmarterTools Inc


Sign In or Register to comment.