Rename Team Project in VSO

With yesterday update, one of the most requested feature for TFS/VSO was finally active, you can now rename a Team Project. It can be done directly from collection administration page, in the same place where you can delete a Team Project



Once selected you should only provide a new name.


Now you will be warned with a long warning message that tells you exactly what kind of intervention you need to do after the rename.


Clicking the link provided in the warning box will bring you to a page full of detailed step on how to perform all the above operations. ( )

The first operation you need to do is recreate all local workspaces unless you will have Visual Studio 2012 or Visual Studio 2013 Update5, that can manage this situation automatically. So it is just a matter of time before this step will be automatic. Until Now, if you try to access Local workspaces of renamed project with older version you will be greeted with a detailed error message.


Another annoying stuff is that you need to edit all the build based on TFVC, and update path of solution/project to build, because build are still not updated by the rename project. I think that this will be fixed in some next upgrade.

One of the nicest stuff is that you will have automatic redirect of old urls. As an example I’ve renamed TP Experiments, but I’m still able to use the old url in the Browser.

Clearly the redirect will work until you create a new TP with the name of the old renamed project.

Gian Maria.

Quickly run Unit Test With VS 2012/2013/..

With VS 2012 and newer versions we can run Unit Tests from various frameworks directly from Visual Studio IDE, thanks to the concept of Test Adapters. When you are doing Test Driven Development you usually go with Red/Green/Refactor workflow; what you need is a way to quickly run all or part of your unit tests after you modified the code. The quickest solution is using the option to Run Tests After Build but it is available only for Premium and Ultimate edition, but you can also run test with little manual intervention resorting to Keyboard Shortcut.

Simply go to TOOLS->Customize menu, then choose to customize keyboard.


Figure 1: Keyboard customization in Visual Studio

Once configuration window is opened, search for TestExplorer.RunAllTests command, place cursor in the “Press shortcut keys:” textbox and press a shortcut, then press “assign” button to assign to this command. In my standard configuration I like to have CTRL+SHIFT+ALT+A shortcut, because it is not assigned to any other command and it is easy to press with left hand.


Figure 2: Assign CTRL+SHIFT+ALT+A to TestExplorer.RunAllTests command

Now I can write code, use shortcut and VS will build solution and run test for me automatically, without leaving my hands from the keyboard. Thanks to the various test adapter and the various grouping and filtering possibility offered by Test Explorer, you can do TDD in Visual Studio without the need of third party tools.

Gian Maria.

Nunit test not found for some assemblies with Visual Studio Test Runner

I’ve a project in Visual Studio 2013 where one of the assembly containing Tests refuses to show tests in Test Explorer window. The solution has tests written both in Nunit and in MSpec, and everything is good except for that specific assembly. If you notice that Test Explorer window misses some tests, the first thing you need to check is the output windows, where you can find some output for Test Adapters.


Figure 1: Output for test adapters can be found in standard Output Window

In the above situation the assembly that is ignored is Intranet.Tests.dll and the reason is that it is built for Framework45 and x64 platform, while the test runner is executing against x86 platform. Everything seems ok, every project is compiled in .ANY CPU, but looking at the raw project file I can confirm that PlatformTarget is set in x64. Changing to x86 (or removing it completely) solves the problem.


Figure 2: Platform target changed from x64 to x86

After I changed the PlatformTarget attribute, all tests belonging to that assembly are now available Test Explorer window.

Gian Maria.

Some love to Kanban Board in Visual Studio online

In some of recent updates on Visual Studio Online the team put some love into the Kanban Board. In January they enable editing tiles on the Board. In february we can Adding and editing some fields directly from the Board, as well as the ability to split column.


Figure 1: Split columns in Kanban Board.

I must admit that split column is a must and I’m very happy to have it now on my VSO account. In March the ability to reorder card on the board was introduced, as well as the possibility to specify Definition of Done for each column. Finally, with April deployment, we have now the ability to customize cards, as well as Markdown on Definition of Done, plus the ability to configure the Cumulative Flow Diagram.

With all these updates, Kanban support in VSO is starting to become really interesting.

Gian Maria.

Mixing native query and LINQ in Mongo Query

Lets look at the following query issued to a standard MongoCollection<T> instance object:

return _bufferCollection.Find(
        GetNextBlockQuery(lastTick, lastRevisionId))
    .OrderBy(d => d.LastUpdated)
    .ThenBy(d => d.RevisionIdNumeric);

The method GetNextBlockQuery simply return a Query<T> query object expressed with C# mongo query syntax. In this query the result of Find() method is simply sorted using standard LINQ syntax.

Do you spot where the problem is?

Find() method returns an object of type MongoCursor<T> that implements IEnumerable<T> but not IQueryable<T>.

If you query MongoCollection with LINQ using the AsQueryable() extension method, there is no problem using OrderBy() or ThenBy() LINQ extension methods. In this situation the implementation of IQueryable inside Mongo C# driver will translate everything to standard mongo query syntax, then it executes translated query to the server and returns objects to the caller.

In previous example instead, the OrderBy() LINQ operator is invoked against a MongoCursor and ordering will be done in memory. The problem is: OrderBy method will operate against IEnumerable object and iterates all the objects to return them in correct order.

If you use LINQ operators against standard MongoCursor, it will operates in memory, hurting performances.

This will hurt performances of the application: each time the query is executed, the entire resultset is loaded into memory and then sorted. To avoid this problem, you need not to mix native Mongo C# query with LINQ operators. The correct query is the following one:

 return _bufferCollection.Find(
      GetNextBlockQuery(lastTick, lastRevisionId))
           .Ascending(d => d.LastUpdated, d => d.RevisionIdNumeric));

This new version uses SetSortOrder() method of Mongo C# Query, so it will be sorted directly from Mongo server and objects will be loaded in memory during standard for-each enumeration. The above problem is really bad if you want to limit number of returned objects. If you use a Take(50) method to obtain only 50 objects, actually you are loading the entire collection into memory, then returning the first 50 elements. This is really different from asking mongo to return only 50 elements directly in the query.

One of the greatest problem is that if you limit number of record with LINQ operator Take()  on the first query, yoy are doing Client Side pagination, with significant performance loss.

As general rule, avoid mixing LINQ and Mongo query classes to issue query to your Mongo server, and prefer native Query syntax over LINQ because it will offer you the whole capabilities of Mongo. LINQ query at the contrary will expose only a subset of possible queries, and beware that Select operator operates in memory, instead of limiting the number of returned field directly from the server.

Gian Maria.