Do not throw a NullReferenceException when validing “this” in an extension method

One pattern I’ve started running into is developers explicitly throwing a NullReferenceException when validating the “this” parameter of an extension method. public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action) { if (null == enumerable) { throw new NullReferenceException(); } // rest omitted } The desired behavior here is to make extension methods look even more…

3

Avoiding automation bugs when implementing IOleCommandTarget

Shortly after Visual Studio 2010 shipped I wanted to experiment with the new VSIX format for traditional Package extensions.  I fired up my copy of Visual Studio, ran through the new package project wizard.  But instead of a nice shiny new project I was greeted with a project load error dialog.  After a bit of…


Newlines in the immediate window

A question came up recently on stack overflow concerning the display of newlines in the immediate window.   The author noted that any .ToString method which contained a newline printed incorrectly when evaluated in the immediate window.  For example given the following ToString implementation public override string ToString() { return "Hello" + Environment.NewLine + "World"; }…


My next adventure

After 4+ years on the languages team it’s time for me to move onto the next adventure.  I joined the languages team in the winter of 2006.  Since then I’ve worked on pretty much every part of the language experience including the compiler, debugger and IDE, shipped 2 releases of Visual Studio, several independent projects…

1

Using lambdas to create generic factories

One item I find to be limiting in C# is the new generic constraint.  The syntax construct specifies that the type backing a given generic parameter contains a parameter less constructor.   It allows methods to create instances of generic parameters in a type safe manner. public static void Example<T>() where T : new() { var…

4

Why is LINQ absent from debugger windows (Part 2)?

Some readers may remember an article I published almost half a year ago about LINQ being absent from the debugger windows.  That post explored the initial design of the feature, it’s limitations and ultimately why it was absent but promised a future article on a slightly different approach.  It’s quite late but I’ve finally had…

8

VsVim Update Released (Version 0.8.1)

I just released an update to VsVim for Visual Studio 2010.  This is available on the extension manager in Visual Studio or can be downloaded directly at the following link. Link: http://visualstudiogallery.msdn.microsoft.com/en-us/59ca71b3-a4a3-46ca-8fe1-0e90e3f79329 GitHub: http://github.com/jaredpar/VsVim New Features I forgot to add an entry when 0.8.0 was released so this is the main set changes for both…

1

Metablogging – changes to my blog

Recently the MSDN blog architecture got a long overdue update to a new infrastructure.  Most of these changes are very welcome but a few are causing a bit of issues for me and readers My blog URL changed to – http://blogs.msdn.com/b/jaredpar/ Additionally my RSS feed changed to – http://blogs.msdn.com/b/jaredpar/rss.aspx Several of my recent posts were…


Nothing is private in the debugger (part 2)

In a previous post I discussed how accessibility is ignored when evaluating expressions in the debugger and the unexpected scenarios that it creates.  One case I neglected to mention in that article is how this behavior works with the VB late binding engine.  The expression evaluator only relaxes accessibility rules when binding an expression.  This…


Nothing is private in the debugger

The goal of the debugger is to provide rich inspection capabilities for a process.  The main method of inspection is through the evaluation of textual expressions which is handled by a language specific component known as the expression evaluator. This component is the data provider for a good portion of the debugger windows (watch, locals,…