Visual Studio 2015 Cheat Sheet

Visual Studio 2015 Cheat SheetI couldn’t find an updated version of the cheat sheet for Visual Studio 2015, so I updated it myself with the new keybindings. I removed the links at the bottom to make more room. There have been several versions of this over the years. Thanks to Phil Price for the version I based this on.

You can download this as an easy to print PDF or an easy to edit Word document.

If I missed your favorite new shortcut, make sure to let me know in the comments to I can update the cheat sheet.

Read More

NUnit 3.0 Test Runner for Android and iOS

We are busy preparing the long awaited beta release of NUnit 3.0 that should ship this week, but I’ve also been working on NUnit 3 runners for Android and iOS using Xamarin. It is still early days, but it is working fairly well, so I wanted to show it off and hopefully get some feedback on it. Windows phone will follow shortly and I will update it to support other platforms like Windows Store when Xamarin’s support moves from early preview to beta.

The following is the current process.

1. Creates a Xamarin Android or iOS application project. I hope to create a project template eventually.

2. Reference nunit.runner and nunit.framework in the project. It will be a NuGet package with the correct Xamarin dependencies.

3. In MainActivity.OnCreate() on Android or AppDelegate.FinishedLaunching() on iOS, swap the App object with the one we provide.

On Android:

 protected override void OnCreate(Bundle bundle)
 {
    base.OnCreate(bundle);

    global::Xamarin.Forms.Forms.Init(this, bundle);
    LoadApplication(new NUnit.Runner.App());
 }

On iOS:

 public override bool FinishedLaunching(UIApplication app, NSDictionary options)
 {
     global::Xamarin.Forms.Forms.Init();
     LoadApplication(new NUnit.Runner.App());

     return base.FinishedLaunching(app, options);
 }

4. Write unit tests in the current assembly, or if you have tests in another referenced assembly, add those assemblies in App.AddTest(Assembly testAssembly).

Screenshot_2015-03-25-18-36-39

5. Build and deploy the test app. When you launch it, it looks like this. The icon is generic because it comes from the project you created. If I create a template, then I will replace it with the NUnit icon.

Screenshot_2015-03-25-18-36-43

6. Click the Run Tests button.

Screenshot_2015-03-25-18-36-49

7. You get the typical overall summary of the test run. You can then drill down into just the failed or all tests. I might change the wording on those bottom buttons.

Screenshot_2015-03-25-18-36-59

8. You see a scrolling list of all tests. The colored text is the test name. I just named some Fail, Error, etc so I could quickly eyeball mistakes :) You can then drill down into the individual tests for more information.

Of course, you can navigate up and down the stack and re-run tests. Some frameworks allow you to re-run individual tests. I’m not sure how useful that is, so I am holding off on that.

Read More

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