RSS

Visual Studio Add-ons

I’ve been getting the same question a lot lately. What plugins, enhancements, extensions, etc. do you use in Visual Studio? So here’s the surprisingly short list:

ReSharper

The ReSharper website says:

ReSharper is a renowned productivity tool that makes Microsoft Visual Studio a much better IDE. Thousands of .NET developers worldwide wonder how they’ve ever lived without ReSharper’s code inspections, automated refactorings, blazing fast navigation, and coding assistance.

I can tell you the “.NET developers worldwide wonder how they’ve ever lived without ReSharper” is completely true. Once you learn to use it, you’ll never want to code without it. I remember the first week I used it I was angry at myself for waiting so long to get my hands on it.

Links:

StyleCop

The official product description reads:

StyleCop analyzes C# source code to enforce a set of style and consistency rules. It can be run from inside of Visual Studio or integrated into an MSBuild project. StyleCop has also been integrated into many third-party development tools.

The ability to run a tool and have it tell you where to fix your styling is invaluable. Create a custom configuration file (agreed upon by the team of course) and then share it with your team or even better integrate it into you build server. This will ensure that a field is formatted like a field should be consistently in every file. No more style switches per file.

Oh and by the way, the latest release works with ReSharper to allow for quick cleanup of any errors found.

Links:

Search References

How and why the functionality of this gallery extension isn’t built into Visual Studio completely baffles me. This simple extension adds a search box to the top of the .Net tab on the Add References dialog.

Links:

Snippet Designer

If you write code that is structurally the same over and over again, you should learn to build snippets. If you want to build snippets, you want to take a look at this extension. Snippet Designer allows you to highlight code and export as snippet. It has a great GUI for adding in replacement sections, setting the properties of your snippet, etc.

Here is a screenshot of Snippet Designer being used to edit my null coalescing operator snippet.

Links:

 
Leave a comment

Posted by on August 26, 2011 in Software Development

 

Tags: , , , , , , , , ,

Calculate Elapsed Time in .NET

I came across this while preparing an upcoming blog entry and felt the need to share. I was looking for a way to calculate the time of an operation. I searched over and over again only to find the following pattern:

DateTime startTime = DateTime.Now;
// do operation
DateTime endTime = DateTime.Now;
TimeSpan runTime = endTime - startTime;

Unfortunately, this pattern isn’t very accurate and rarely outputs anything other than zero on simple operations. I needed to output elapsed time for even these simple operation so I kept searching until finally I came across the System.Diagnostics.Stopwatch class. The code is more readable and (after a bit of testing) is capable of tracking the elapsed time of simple operations.

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
// do operations
stopwatch.Stop();
TimeSpan runTime = stopwatch.Elapsed;
long runTimeMilliseconds = stopwatch.ElapsedMilliseconds;
long runTimeTicks = stopwatch.ElapsedTicks;

Hopefully, putting this out there will help people find this method much quicker than I did. And as my mother used to tell me: just because everyone else does it, it doesn’t make it right.

 
Leave a comment

Posted by on June 23, 2011 in Software Development

 

Tags: , , ,

SP 2010 Site Collection PowerShell Script

The following script is what we’ve been using to create site collections with their own database in SharePoint 2010.

Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

## Configure the script
$databaseName = "SP_Content_Database_Name"
$webApplicationUrl = "http://localhost"
$siteCollectionUrl = "http://localhost/sites/its"
$siteCollectionName = "Site Collection Name"
$siteCollectionOwner1 = "DOMAIN\user1"
$siteCollectionOwner2 = "DOMAIN\user2"
$siteCollectionTemplate = "STS#1"

## Create the database
New-SPContentDatabase -Name $databaseName -WebApplication $webApplicationUrl

## Create the site collection
New-SPSite -URL $siteCollectionUrl -OwnerAlias $siteCollectionOwner1 -SecondaryOwnerAlias $siteCollectionOwner2 -ContentDatabase $databaseName -Name $siteCollectionName -Template $siteCollectionTemplate

If you need a list of site templates available on the machine you can run:

Get-SPWebTemplate | Sort-Object "Title"

 
Leave a comment

Posted by on June 9, 2011 in Microsoft SharePoint

 

Tags: , , , , ,

Video: Code Monkey

Oldie but goodie for my coding friends.

 
Leave a comment

Posted by on June 7, 2011 in Uncategorized

 

Tags:

Project Changes

If you’ve looked at my Projects page recently, you may have noticed that there were a few changes.

docXtract

The bad news first. I have removed docXtract. I found that Sandcastle and it’s supporting tools (most notably Sandcastle Help File Builder) have grown to a point that there is no need for another product.

Visual Studio Code Snippets

Now the good news. I’ve been working on a Logitech G11 keyboard which has 18 macro keys. I’ve been assigning code snippet macros to the keys and it has been increasing my productivity tremendously. I’ve also started writing my own code snippets. This new project is an online home for those snippets.

 
Leave a comment

Posted by on April 20, 2011 in Uncategorized

 

Tags: , , ,

SPS NOLA 2011 Presentation Materials

The materials (code and PowerPoint deck) from my presentation at SharePoint Saturday New Orleans 2011 can be downloaded using the following link:

Web Part Presentation Material (SkyDrive Folder)

I will also be posting the code to my CodePlex repository for online viewing.

 
Leave a comment

Posted by on February 26, 2011 in Speaking Engagements

 

Tags: , , , , , , ,

MCPD Web Developer 4

Right on the heels of the upgrade to Web Developer 3.5, I took the test for an upgrade to .NET 4. I’ve finally caught up to the latest release. I have to say this was the longest Microsoft certification test that I’ve taken. It was over 80 questions long and split into 4 sections. For a second I thought my test would be lost. When I clicked to finish the exam the testing software crashed. Fortunately, everything was there just like I left it when they rebooted the computer.

 
Leave a comment

Posted by on February 16, 2011 in Personal

 

Tags: , , ,

SharePoint Saturday New Orleans 2011

First, SharePoint Saturday New Orleans 2011 has opened registration and placed the session list online. If you’re interested in SharePoint at all this is a must attend event. The sessions span all areas of SharePoint including project management, end users/power users tools, administration, architecture, development and more.

Secondly, I will be presenting “Developing Custom Web Parts”. No SharePoint experience required but I am recommending ASP.NET experience if you attend. Here’s the description I sent in:

Web parts are a logical starting point for ASP.NET developers to begin their journey into SharePoint. This session focuses on the ins and outs of web part development as well as web part and SharePoint development best practices. Code examples will use C#.

 
Leave a comment

Posted by on January 18, 2011 in Speaking Engagements

 

Tags: , , ,

MCPD Web Developer Upgraded to 3.5

Over the holidays, I upgraded my MCPD to .NET 3.5. Now only one more to go to catch up to latest release. This was my first upgrade so I didn’t know what was going on until after I was done. They split the upgrade up into 2 banks of questions representing the 2 tests for that MCPD. Just a heads up for those wondering why you get told you’ll get 40-something questions and end up with 1 of 20-something on the first screen.

 
Leave a comment

Posted by on January 4, 2011 in Personal

 

Tags: , , ,

jQuery XHTML Strict Target=”_blank” Solution

As many of you know, XHTML Strict does not allow the target attribute within <a> tags. I have been using a JavaScript solution which I found online a few years back. The code was a bit verbose so I decided to update it using jQuery.

$(document).ready(function () {
    $('a[rel="external"]').each(function(i) {
        $(this).attr('target', '_blank');
    });
});

With the above code in place, simply put rel=”external” on any anchor tags that need to open in a new window.

 
2 Comments

Posted by on November 27, 2010 in Web Development

 

Tags: , , , ,

 
Follow

Get every new post delivered to your Inbox.

Join 57 other followers