Wednesday, September 14, 2005

I've been distracted all morning, drooling over the C# 3.0 features.  First, I was upset that they would tease us with 3.0 features before 2.0 is even released yet (and it's still a little silly), but being able to download, play with them, and run them makes a world of difference.  Here's my favorites distilled for those who don't want to check it out.

  • Tons of type inference stuff.
    • List<int> list = new List<int>();
    • becomes
    • var list = new List<int>();
    • I'm not sure how I feel about "var".  It makes it feel a little like javascript.  I can see how that makes the language less ambiguous, and three letters isn't that bad.
  • Tons of initialization stuff
    • Initialize any collection-type-thing like you would an array. (new List<int> {1,2,3,4})
    • Intialize objects with a named-parameter feel (new Person {FirstName="Mark", LastName="Miller} //not a constructor)
  • A few AOP-ish goodies with extension methods - This is extremely cool.  Add methods to string, or anything else.  Very sweet.
  • "Fix" the anonymous delegate syntax with lambda expressions
    • delegate(int x) {return x+1;}
    • becomes
    • x => x + 1
    • This will be hard to approach for some, but I think it's great
  • Anonymous Types - This is excellent for working with data where you don't really need a formal type, you just need to work with some data.
  • Language Integrated Query - This is the grand-daddy of them all.  Query against objects, query against XML, query against relational data, query against anything!  All using first-class features of the language!  I'm pretty excited about this.

I'm dissapointed in the lack of first-class duck typing support (late binding).  Yeah, we get half-way there through the use of query and anonymous classes, but there's some scenarios where that seems like hammering a tack with a sledgehammer.

I'm really excited in the innovation I see in the CLR-world.  Sure, lots of the above represent old ideas, but the query stuff represents big innovation in that space that fits right in where the "hurt" is.

posted on Wednesday, September 14, 2005 9:17:46 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Saturday, September 03, 2005

Doesn't that sounds like an awesome band name?  Someone here just said that and I had to write it down.  This seemed like as good a place as any.

posted on Saturday, September 03, 2005 1:50:13 PM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
 Thursday, September 01, 2005

Most of my day today was tracking down a problem with our app when we obfuscated it.  We were getting a System.EntryPointNotFoundException in the obfuscated version, while the normal one worked fine. The stack trace contained the following on the top of the stack trace:

at System.Collections.Generic.IEnumerable`1.GetEnumerator() +0

No concrete class, and an assembly code offset of 0. Weird, eh? After tweaking with lots of settings and digging through the IL of several iterations of differing obfuscation techniques, I finally determined the problem.

I had three overloads of a method that each took a different parametrization of IEnumerable<T>.  For the sake of example, we'll say IEnumerable<A>, IEnumerable<B>, and IEnumerable<C>.  In the obfuscation process, calls to any of the three were being changed to the IEnumerable<A> overload.  Sure enough, PEVerify was giving errors about the wrong type being on the stack. (I was going to show the IL before and after, but I just realized that I deleted the non-working one after fixing it. I'll post it if I can find it again)  It seems that Dotfuscator was not distinguishing properly between overloads if they only differ by parameterization types. I have not verified it, but this may have been aggravated by iterator methods.

We're working up some sample code to send to Preemptive so they can address the problem, but debugging it was frustrating enough to post a synopsis of the account for Google to find.

posted on Thursday, September 01, 2005 12:13:07 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]