This post originated from an RSS feed registered with .NET Buzz
by Udi Dahan.
Original Post: VS2005 Code Generation Bug
Feed Title: Udi Dahan - The Software Simplist
Feed URL: http://feeds.feedburner.com/UdiDahan-TheSoftwareSimplist
Feed Description: I am a software simplist. I make this beast of architecting, analysing, designing, developing, testing, managing, deploying software systems simple.
This blog is about how I do it.
I just ran into a VERY annoying bug in VS2005. Say I have a generic delegate - CompletionCallback(T message) where T : IMessage; and an object which exposes an event of that type, let's say Envelope where T : IMessage. If I have instantiated a specific envelope like this: Envelope env = new Envelope(); then when I type in "env.Completed += " the code that VS generates is "new CompletionCallback(Form1_Completed)". This obviously doesn't compile. If the compiler can do type inference to find out which generic method to call, why can't the code generator generate the proper code?...