The (non generic) System.Action delegate
There's been one delegate I wish would have been integrated in .NET 2.0 :
[code:c#;ln=on]
namespace System
{
public delegate void Action();
}
[/code]
Well, it's been added to the .NET framework 3.5. That will avoid me to create here and there an empty delegate that returns nothing and takes nothing in parameter. It's particularly useful with anonymous methods.
My discovery of that particular type is a bit odd though. A big project I'm currently working on is defining this type :
[code:c#;ln=on]
namespace T1 { public enum Action { A } }
[/code]
"T1" is made up, "Action" is not. And it's being used like this :
[code:c#;ln=on]
Action a = Action.A;
[/code]
And it compiled just fine using .NET 2.0. During a migration to the .NET Framework 3.5, I came across some compilation problems telling me that the resolution of "Action" was ambiguous. I thought at first that this was because of a change in the resolutions of types in C# 3.0, but after a bit of digging I found out about that non-generic System.Action delegate, which is defined in System.Core.dll. By the way, they also added some other System.Action overloads with two, three and four generic parameters.
Reflector tells me that the non generic version is being used by System.Linq.Expressions.Expression. I'm guessing that might be used by LINQ in some way... maybe by some generated code.