Extending Visual Studio (part 1)

I love Visual Studio, always have. From the moment I wrote my first “Hello World!” in C, until becoming an expert C# developer.

With all due respect, however, there was always something missing. One user needs this, the other needs that. Of course, an IDE can’t have it all. The question is only whether an average user can extend VS to inlcude whatever is missing. This series of posts will try to fill the gaps, trying to answer this question: how to get into Visual Studio that which is missing. I will stick them all into a category named “Extending Visual Studio” for easy reference.

But before I begin, here’s a disclaimer – I am no expert in VS extensions; these posts are simply a collection of my experiences and adventures in the world of extending Visual Studio.

Before we are able to extend Visual Studio, we need the Visual Studio SDK. Install it and then continue reading!

So, you have the SDK? Great!

We’re done with technicalities, let’s create an extension!

Continue reading

Use .Any instead of .Count

I am amazed by how many developers use IEnumerable<T>.Count() when they should use IEnumerable<T>.Any().

How many times have you seen/written this:

if (collection.Count() > 0)
{
    // Now that we know we have some elements,
    // let's do something meaningful
}

There are (at least) 3 basic flaws with this approach:

1. Highly inefficient
2. Semantical implications
3. Infinite loops

Continue reading