Why are anonymous types generic?

Suppose you use an anonymous type in C#: var x = new { A = “hello”, B = 123.456 }; Ever taken a look at what code is generated for that thing? If you crack open the assembly with ILDASM or some other tool, you’ll see this mess in the top-level type definitions .class ‘<>f__AnonymousType0`2′<‘<A>j__TPar’,'<B>j__TPar’>…


Hiring for Roslyn

A couple years ago I made a blog posting called “The Managed Languages Team Is Hiring” mere hours before our senior management announced that our hiring goals had been met and told me to please stop recruiting people. That was a little embarrassing. This time I have been assured that, really truly, we do have…


All your base do not belong to you

People sometimes ask me why you can’t do this in C#: class GrandBase{  public virtual void M() { Console.WriteLine(“GB”); }} class Base : GrandBase{  public override void M() { Console.WriteLine(“B”); }} class Derived : Base{  public override void M()   {     Console.WriteLine(“D”);    base.base.M(); // illegal!   }} The author of the most-derived class here…


Big head, long tail

Here’s a graph of the population size of the one hundred largest urban areas in Canada: (Click on the graph for a larger version.) Notice how there is an enormous spiky “head” on this graph: Toronto, Montreal and Vancouver are quite large cities by any measure. Then there is an immediate sharp drop to a…


Bit twiddling: What does warning CS0675 mean?

From the sublime level of continuation passing style we go back to the mundane level of twiddling individual bits. int i = SomeBagOfBits();ulong u = SomeOtherBagOfBits();ulong result = u | i; // combine them together Whoops, that’s an error. “Operator | cannot be applied to operands of type int and ulong.” There are bitwise-or operators…


Asynchrony in C# 5, Part Eight: More Exceptions

(In this post I’ll be talking about exogenous, vexing, boneheaded and fatal exceptions. See this post for a definition of those terms.) If your process experiences an unhandled exception then clearly something bad and unanticipated has happened. If its a fatal exception then you’re already in no position to save the process; it is going…


Asynchrony in C# 5, Part Seven: Exceptions

Resuming where we left off (ha ha ha!) after that brief interruption: exception handling in “resumable” methods like our coroutine-like asynchronous methods is more than a little bit weird. To get a sense of how weird it is, you might want to first refresh your memory of my recent series on the design of iterator…


The Annotated Fourth Edition is available

A brief digression from C# 5 to talk about C# 4: the annotated C# 4 specification is now available in book form from Addison-Wesley. It is of course handy to have a specification in book form, particularly if you’re going to while away the hours with the book sitting by a warm fire. (It’s hundreds…


Asynchrony in C# 5 Part Six: Whither async?

A number of people have asked me what motivates the design decision to require any method that contains an “await” expression to be prefixed with the contextual keyword “async”. Like any design decision there are pros and cons here that have to be evaluated in the context of many different competing and incompossible principles. There’s…


Asynchrony in C# 5 Part Five: Too many tasks

Suppose a city has a whole bunch of bank branches, each of which has a whole bunch of tellers and one gofer. There are a whole bunch of customers in the city, each of whom wants to withdraw a whole bunch of money from the bank at some varying time throughout the day. The algorithm…