GitHub Visual Studio Extension

I just released an Alpha release of my Visual Studio extension for working with issues on GitHub.

It allows you to access and manage GitHub issues for repositories that you have commit access to. You can filter and view issues for a repository, edit issues, add comments and close issue. This is the first Alpha release, more features are coming.

Download

The easiest way to download is by going to Tools | Extensions in Visual Studio and searching for the GitHub Extension. It is also available in the Visual Studio Gallery and in the GitHub Releases for the project.

Instructions

  • To view a list of open issues, go to View | Other Windows | GitHub Issue List (Ctrl+W, Ctrl+G)
  • Log in to GitHub by clicking the logon icon at the upper right of the issue list window
  • Open the issue window by double clicking an issue in the list, or by going to View | Other Windows | GitHub Issue Window (Ctrl+W, Ctrl+H)
  • Add a new issue to the selected repository with the + button in the issue list, or from Tools | New Issue on GitHub (Ctrl+W, Ctrl+I)
  • Edit an issue with the edit button on the Issue window
  • Add comments to, or close and issue with the comment button on the issue window

Credits

Screenshots

Login Window

Login

Issue List

Issue List

Issue Window

Issue Window

Read More

C# 6.0 – String Interpolation

This is another post in the series on the new features that are coming in C# 6.0.

If you want to try out any of these features now, check out the Rosyln compiler and then install the Visual Studio 2015 Preview or fire up a VM in Azure with Visual Studio 2015 Preview already installed.

String interpolation in C# is fairly easy if you only have a couple of arguments, but it can be error prone with many arguments or if you need to re-order the arguments. It is also difficult to quickly see which variable gets substituted in where.

Currently, we write code like this,

var msg = string.Format("You ordered {0} {1}{{s}}", line.Quantity, line.Product.Name);

C# 6.0 makes this easier. You can omit the `String.format` and put the variables right in the curly braces. Notice the slash at the start.

var msg = "You ordered \{line.Quantity} \{line.Product.Name}{s}";

Notice that pesky improper pluralization though. It was always a pain to deal with. Now, just put the code you need inline.

var msg = "You ordered \{line.Quantity} \{line.Product.Name}\{line.Quantity > 1 ? "s" : ""}";

The syntax currently uses a slash before the brace. In a later update, it will be switching to a dollar sign before the first quote and no slash, like this,

var msg = $"You ordered {line.Quantity} {line.Product.Name}{s}";

If you want to check out the code for this series of posts, it is on GitHub at https://github.com/rprouse/CSharp60.

Read More

Switch Visual Studio Settings for Different Solutions

Switching between projects with different formatting styles can be a real pain. I have finally found a solution if you are using Visual Studio and a partial solution for most other platforms.

If you add two configuration files to the root of the solution, they will automatically configure your editor to the coding standards of the solution when you open it and restore your settings to your defaults when you close.

Editor Config

This file defines spacing and tabs for the files in the solution. There are plugins available for pretty much every editor and IDE out there including Visual Studio, Vi, Emacs and even Notepad++.

For more information, got to http://editorconfig.org/. The Visual Studio extension is on GitHub, and can be installed from the Visual Studio Gallery.

Rebracer

Rebracer sets all of the code formatting rules for the project when you open the solution and restores your defaults when you close. To change the settings you simply need to open edit the Visual Studio options and the changes will automatically be saved out to the Rebracer.xml file.

Rebracer is also on GitHub, and can be installed from the Visual Studio Gallery.

Read More

NUnit 3.0 – Values Attribute for Enums

To celebrate the second alpha release of NUnit 3.0, I am going to write a few posts on some of the new features that we’ve added.

Today’s feature is a simple one, but one of my favorites. With older versions of NUnit, if you wanted to run a test against every value of an enum, you would either have to write code to iterate through the values, or add them as TestCases and risk missing values added to the enum later. With the 3.0 release, you can now write a test method like the following which will be run with every enum value. The [Values] attribute on an enum parameter will automatically expand to all possible Enum values.

[Test]
public void MyEnumTest([Values]MyEnumType myEnumArgument)
{
    //...
}

It is probably less useful, but we also added the same support for Boolean values. Add the [Values] attribute to a bool and the method will be run with true and false.

[Test]
public void MyBoolTest([Values]bool value)
{
    //...
}

Read More

Visual Studio 2013 Modifies NUnit Project Files

I’ve seen this several times now and an issue was just reported against the NUnit Visual Studio adapter, so I thought I would document my findings on this.

If you run non-Microsoft unit tests in Visual Studio using a test adapter, Visual Studio 2013 will modify the project file and add the following lines.

<ItemGroup>
  <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>

This happens for NUnit, XUnit and other 3rd Party test adapters. This behavior is a new feature of Visual Studio 2013.

In this issue on Connect, Microsoft says it is intentional and provides what I see as a less than ideal workaround.

Posted by Microsoft on 10/24/2013 at 7:38 AM

This behavior is intentional.

To support third-party test frameworks, like NUnit and XUnit, Visual Studio 2012 loaded Test Explorer on solution open, regardless of whether it contained test projects. This added seconds of delay to startup and solution open scenarios for all users, majority of whom don’t use tests.

In Visual Studio 2013, we changed it so that Test Explorer package is loaded only when the solution contains one or more test projects. Test projects are identified in two different ways. Projects created from one of the built-in unit test project templates are identified using project type GUIDs. Other types of projects, such as Class Library project with XUnit or NUnit tests, are identified by Test Explorer during first test discovery and “tagged” with the Service/item.

You can avoid Visual Studio automatically adding the Service/item to your test projects by creating them from any of the built-in unit test project templates. In other words, select the “Unit Test Project” template instead of the “Class Library” template in the New Project dialog.

If you want to change existing projects from a “Class Library” to a “Unit Test Project”, edit the project file and add the following to the first PropertyGroup

<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TestProjectType>UnitTest</TestProjectType>

This isn’t much different than the Service being added, but maybe it is more correct because it is a test project?

Unfortunately, this doesn’t work if anyone is using Xamarin studio since the Unit Test Project type is not supported.

Read More