• Moving from WordPress

    This is my last post on WordPress and first post on Jekyll GitHub Pages.

    I’ve decided to abandon WordPress running on Azure Web Apps for a simpler static blog using Jekyll to convert Markdown to static content hosted on GitHub pages. I’ll go into the process I went though in a future post.

    This posts is here as a marker of when I moved everything over. I’ve tried to get the permalinks in Jekyll to match the ones in WordPress - but breaking any that were from my brief stint on DasBlog. As far as I know everything should just be the same - including the RSS feed on /feed.

    Shoot me a mail if there is a problem.

    Everything from this point on will be on the new format.

    The actual migration will occur at some point next week.

  • Fixing a broken Kanban Board

    Today I came across a team who had completely broken their TFS Kanban Board (Backlog Board). All they could see was a generic “there has been a problem” pink popup instead of their cards.

    When presented with this, the usual fix is to ensure background agent job is running, which it was. So I took a look in the Windows event logs for more detail and found this error (most of the details are removed for brevity, this is from the middle):

    Detailed Message: TF30065: An unhandled exception occurred.
    Exception Message: The given key was not present in the dictionary. (type KeyNotFoundException)
    Exception Stack Trace:    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.TeamFoundation.Server.WebAccess.Agile.Models.WorkItemSource.<>c__DisplayClass18.<GetProposedInProgressWorkItemData>b__13(IDataRecord dataRecord)
       at Microsoft.TeamFoundation.Server.WebAccess.Agile.Utility.WorkItemServiceUtils.<GetWorkItems>d__c.MoveNext()
       at Microsoft.TeamFoundation.Server.WebAccess.Agile.Models.WorkItemSource.GetProposedInProgressWorkItemData(ICollection`1 rowData, ICollection`1 hierarchy, ISet`1 parentIds)

    With this little information, all I could assume was that, somehow the configuration had become corrupted. My solution was to find the board settings for that team and delete them from the TFS Collection database.

    NOTE: Neither I nor Microsoft support you making changes directly to your TFS database. You do so at you own risk, and probably best with a backup. This SQL worked against our TFS 2012.3 Database, I cannot guarantee other versions have the same schema.

    First step is to find your TeamId from the Collection Database. Team Ids can be found in the ADObjects table.

    select * from ADObjects
    where SamAccountName like '%MyTeamName%';

    The TeamFoundationId GUID in this table is the value we are interest in.

    You can find the Board and Columns in the tbl_Board and tbl_BoardColumn tables using the following SQL:

    select * from tbl_Board b
    join tbl_BoardColumn bc on b.Id = bc.BoardId
    where TeamId = 'YouTeamId';

    Once you are happy that you have the found the rows for the team, you can then delete them from those two tables. You should probably copy the results into Excel just in case things go wrong.

    To delete you can use the following SQL Queries:

    delete bc
    from tbl_Board b
    join tbl_BoardColumn bc on b.Id = bc.BoardId
    where TeamId = 'YouTeamId';
    delete tbl_Board
    where TeamId = 'YouTeamId';

    Now if you refresh the board it should report that there is no configuration and needs to be setup again from scratch.

    I’ve no idea what caused this problem, or if it is fixed in a future update, but this got things working again for me.

  • Working in Visual Studio behind the Firewall

    Working in an “Enterprise” type environment means lots of *fun * obstacles getting in the way of your day to day work – the corporate proxy is one of my challenges.

    Since giving up on CNTLM Proxy, I haven’t been able to connect to nuget.org from the package manager, view the Visual Studio Extension Gallery or even get any extension/product updates from Visual Studio.

    This is a quick post with the changes I needed to get Visual Studio 2013 Update 4, NuGet 2.8 and Web Platform (Web PI) 5 to see past the corporate Squid proxy.


    Configuring NuGet based on this Stack Overflow answer by arcain.

    Running nuget.exe with the following switches will allow NuGet to use and authenticate with the proxy:

    nuget.exe config -set http_proxy=http://proxy-server:3128
    nuget.exe config -set http_proxy.user=DOMAIN\Dave
    nuget.exe config -set http_proxy.password=MyPassword

    It will put the values into your nuget.config file (with the password encrypted)

            <add key="http_proxy" value="http://proxy-server:3128" />
            <add key="http_proxy.user" value="DOMAIN\Dave" />
            <add key="http_proxy.password" value="base64encodedHopefullyEncryptedPassword" />

    Once Visual Studio is restarted, it should be able to see through the proxy.

    As per the comments on the answer some people might have success without the password – sadly, not in my case. Also, remember if you have to change your password (as I have to every month or so) you will need to re-enter your password.

    Visual Studio

    Setting up Visual Studio based on this blog post by Raffael Herrmann.

    • Open the devenv.exe.config file. I find it by right clicking the Visual Studio shortcut, selecting Properties and then “Open File Location”. If you have UAC enabled you will need to open it in a program running as Administrator.
    • Scroll to the end of the file and find the system.net section:
    <!-- More -->
            <ipv6 enabled="true"/>
    <!-- More -->
    • Add the following below </settings>:
    <defaultProxy useDefaultCredentials="true" enabled="true">
        <proxy bypassonlocal="true" proxyaddress="http://proxy-server:3128" />
    • The final version will look something like this:
            <ipv6 enabled="true"/>
        <defaultProxy useDefaultCredentials="true" enabled="true">
            <proxy bypassonlocal="true" proxyaddress="http://proxy-server:3128" />

    Web Platform Installer

    This was the same set of changes needed for Visual Studio, except with the WebPlatformInstaller.exe.config file, which I again obtained from the shortcut properties using “Open File Location”.


    Big thanks to Eric Cain and Raffael Herrmann for enabling me to connect to the internet again :).

  • UNC to URI Path Converter

    Yesterday, at work, I was trying to help someone enter a UNC path (\\server\share\file.txt) into a hyperlink control on our application, but it was rejecting it because it wasn’t a valid hyperlink. I discovered that you could enter a URI path (file://server/share/file.txt) and it worked fine. Problem solved? Not exactly, otherwise I wouldn’t have anything to write about.</p>

    The issue was that the users are non-technical folk and they can’t just fire up Linqpad and run the following code like I did to test if it worked:

    new Uri(@"\\server\share\file.txt").AbsoluteUri

    The rules around converting UNC paths to URI’s gets a little tricky when you have paths with spaces and special characters in them, so I thought I would Google/Bing for an online UNC to URI Path Converter… turns out I couldn’t find one, so I did what every software developer does, writes one.

    Path Converter

    This took a little over an evening, mostly due to me been unfamiliar with CSS, JQuery (I know, but it’s quicker than Vanilla JS) and TypeScript (first time I’ve ever used it).

    The entire website was setup in my VS Online account and linked to my Azure site as part of the new “one ASP.NET” setup template, and I even got to add Application Insights as part of the setup template. A few clicks on the Azure Portal and I had a Continuous Delivery Build Definition setup in VS Online. All I had to do then was push changes from my local git repository to VS Online and TFS would build the code and if it succeeded the site was updated within a few minutes.

    The site works by making a quick AJAX HTTP GET when you click the Convert button to a ASP.NET MVC site to use the URI class in .NET. That’s about it.

    Here’s the link to anyone who want’s to use it: http://pathconverter.azurewebsites.net/

  • The Future Looks Roslyn

    I’ve been keeping an eye on the development of Roslyn ever since Anders Hejlsberg announced Microsoft were open sourcing it at Build 2014. For those of you who don’t know what Roslyn is, it is Microsoft’s new C# and VB.NET compiler platform. There are many aspects to it, and if you want a nice overview Schabse Laks has a couple of blog posts on the subject.

    Most developers seem to be excited by the new C# 6.0 language and the future of the language going forward – I can see why, C# hasn’t really changed that much recently. Whilst I am interested in the language, another thing that has got me really excited as a C# developer is the Language Service.

    Language Service

    The language service is what Visual Studio uses to talk to the compiler to understand your code. Previously this was implemented as a series of “hacks” between Visual Studio and the compilers. This made it hard for the Visual Studio team to implement many decent refactoring experiences. The last time anything new really appeared for the “coders” was in VS2010 when the existing refactoring tools were released. Two full versions of VS later, and we still have the same refactoring features. Whilst the C# team have been busy working on Roslyn, products like Jet Brains ReSharper have come along with loads of features of their own, adding refactoring tools and code analysis. But I think times are changing…

    For those of you who have installed “Visual Studio 14” or the Roslyn End User Preview, you are seeing the beginning, of what I think, will be a revolution to Visual Studio’s coding experience for C# (as well as VB.NET).

    New Features

    Here’s a quick overview of some of the features added already:

    Visualising using directives that are not needed.


    Here you can see that I don’t need three of my five using directives so they are coloured grey.</span>

    Ctrl + . to Resolve

    Taking the previous “issue” with my code I can just place the caret on any of the lines with an issue and press Ctrl + . (full stop) to fix it.

    Remove Usings

    You even get a preview of what your class will look like when “fixed”.

    Ctrl + . has been used to Resolve issues with your code before (e.g. add using directives), but now it has previews and can suggest fixes to new problems. For example, it could suggest not to use Hungarian Notation and remove the prefix, this would be a lot better experience than the existing Code Analysis CA1704 rule.

    Alt + . and Refactoring

    Since VS2010, the basic refactoring was done via a series of keyboard combination shortcuts. Ctrl + R, M to Extract Method is the only one I remember, the others I know are there but I can’t remember the keyboard shortcuts. Now everything is under Alt + . and is context sensitive.

    So if I select a few statements in a block of code and do Alt + . get the option to Extract Method, select a field and do Alt + . I get Encapsulate Field, select the class name, Extract Interface, you get the idea.

    The interface for renaming has changed too to include live preview and errors.

    New Method

    Above you can see a New Method I’ve extracted and the Live Preview of renaming. If I decided to call “NewMethod” “Foo” I’d get this error because I already have method called Foo.

    New Method Error

    Code Lens

    Code Lens is a heads up display that is already available in VS2013 Ultimate and is powered by Roslyn to provide code and source control information inline in the editor. I’ve only played with this during the CTP of VS2013, but it seemed really promising – I’m now waiting on Microsoft to move it from the Ultimate SKU to Premium.


    Visual Studio 14

    All the aforementioned features are in VS2013 + End User Preview, Roslyn will actually ship enabled in the next Visual Studio code named “Visual Studio 14”. This has an early preview available and already more refactoring features have appeared. For example, Soma mentions a new Introduce Local refactoring in his blog post.

    This sort of stuff isn’t really ground breaking from a developer experience point of view and it’s nothing new for people who use Visual Studio add-ins like ReSharper. But, it is proof that Visual Studio’s Editor is back in the game.

    My opinion is that from now until VS 14 RTM ships, the C# and VS team will be focusing their efforts on stabilising the Compiler aspect of Roslyn and making sure everything “just works”, we may see a few more refactoring tools appear in the next update, but I’m not expecting much.

    After the RTM

    I’m looking forward to when Visual Studio 14 has hit RTM has shipped, what happens next…? The Visual Studio Editor team have time to take a good hard look at what they want to build, the C# compiler team can go back to working on language features. I expect the VS Editor team will be working on some awesome editor experiences, some we might have seen before in other products, others brand new. I cannot see them resting on their laurels once they have the Language Services as a platform to build on, they can do anything they want.


    The other thing that really excites me is the community aspect, building your own VS Editor extensions that leverage the Language Services from the compiler is now easy. What ideas will the community build, what would you build? I’m hoping that individual extensions will appear first, and then grow into suites of common functionality, and maybe even be implemented by the VS Editor team in the future.

    It doesn’t just have to be extensions, it is also really easy to write your own diagnostics tools. Already there is a String.Format Diagnostic package on the VS Gallery. So, where does this leave products like ReSharper? In my opinion, Microsoft always implement the features most people want, there will still be room for people to create their own extensions suites and JetBrains can charge for a professional package. However, now it will be a lot easier for people to build their own, no longer do you need to write a C# Code Analyser, so there could be some awesome free open source extension suites appearing too.


    I think the next few updates for Visual Studio will brings lots of exciting and powerful enhancements to the Visual Studio Editor for both the C# and VB.NET developers. It’s been a long time coming, but I think Visual Studio is back on the front font and ready to innovate some more.

  • Dealing with NewsBlur and Large Feeds

    I’m a premium NewsBlur member, and have been ever Google decided to shutdown Google Reader. Mostly my experiences have been very good, with great support from Samuel when I needed it.

    However, there has been one issue nagging at me for quite a while and this is, I cannot get a feed to Mark Seemann’s blog. I posted the problem on Get Satisfaction, but Samuel was unable to help due to the size of the feed. A few weeks ago a co-worker of mine mentioned Yahoo Pipes should be able to sort this, so I finally gave it a try. For those (like me until recently) who don’t know what Yahoo Pipes is it’s “a powerful composition tool to aggregate, manipulate, and mashup content from around the web”.

    After a few minutes tinkering, I had finally built a “pipe” that took the blog feed, performed a “truncate” operation to 10 posts and output the feed again. I then took the RSS feed to the pipe and handed it to NewsBlur and this time it coped perfectly with the feed.

    Piping hot

    I’m sure there’s more I can do with it, but for now that’s all I need.

    So, if anyone else needs a “Last 10 Feeds from Ploeh.dk blog” you can get the here.

  • Using Linqpad to Find Work Items with External IDs

    When you work on projects of a certain size, you will find that you begin to add custom fields to your TFS Work Items that you later want to search on. In my case it was an External Requirement ID field that we use to store the ID of requirements that our customers use to track requirements. I often use these when communicating with our customers, or even members of my team.

    For example:

    “Have you checked in A1 yet?”

    is easier to ask and understand than

    “Have you checked in 177484?”

    The problem that arises with this approach, is been able to find a work item by its External Requirement ID.

    To solve this issue, I once again turned to Linqpad and came up with a script that lets you search by a comma separated list entries against your work items. After a bit of digging I managed to find the correct API to be able to produce reliable TFS Web Access URL’s in the results:


    To use the script, just place you collection address and custom field name at the top. You can also add any other filtering into WIQL, for example, you might only want to search a certain Area Path.

    When you run the script you will be asked to “Enter External Requirement ID”, just enter the ID i.e. A1 or a list of ID’s i.e. A1, A2 and press Enter.

    I keep mine “Pinned” to the Jump List of Linqpad on my taskbar for ease of access.

    You can download the script from here:

    The script is based on my Linqpad TFS Template, if you need it for any other version of Visual Studio, download the correct template and copy and paste the body of the script between them.

  • Team Explorer Shortcuts

    Visual Studio 2013 has a re-designed Team Explorer, and I really like it, but I sometimes find some options, such as “Find Shelvesets” and “New Query”, to be buried away.

    For example, the normal path I have to take to find a shelveset is:

    • Pending Changes
    • Actions
    • Find Shelvesets

    This is really “clicky” and something I wished I could do quicker. Today I found out I could right-click on the tiles on the Team Explorer Home Page to get to some of those actions that are buried away:
    # Pending Changes From Pending Changes you can get to Find Shelvesets

    Pending Changes

    Work Items

    From Work Items you can get to “New Query”

    New Query

    My Work

    From My Work you can get to Request Review

    My Work

    Team Members

    If you have the TFS 2013 Power Tools installed, then even the Team Members gets the right-click treatment with access to “Team Utilities”

    Team Utils

  • Dealing with Code Analysis CA1822 and xUnit.net

    I recently started working on a new project and decided to use xUnit.net as my unit testing framework. I made a simple test class with a test method, but when I build it, Visual Studio Code Analysis complained with a “CA1822: Mark members as static” warning against my test method.

    Lets assume I have a test for MyClass that looks like this:

    public class MyClassTest
        public void TestMyProperty()
            var myClass = new MyClass(1);
            Assert.Equal(1, myClass.MyProperty);

    In this version, Code Analysis is complaining because TestMyProperty does not uses any instance members from MyClassTest. This is all well and good in production code, but I assumed (incorrectly) that you must have instance test methods for the test framework to pick them up. As it turns out, xUnit.net is better than that and works on static methods as well as instance methods.

    If these were all the tests I needed, I should mark the method as static. If all your test methods are static, you should mark the class as static too – otherwise you will get a”CA1812: Avoid uninstantiated internal classes” warning from Code Analysis.

    So the fixed version will look like:

    public static class MyClassTest
        public static void TestMyProperty()
            var myClass = new MyClass(1);
            Assert.Equal(1, myClass.MyProperty);

    Now, those of you who have used MSTest and Code Analysis might notice two things here:

    • xUnit.net is not bound by the same restrictions as MSTest. Anything public with a [Fact] attribute will be tested.
    • Why does CA1822 not occur when using the [TestMethod] attribute from MSTest?

    To answer #2, I turned to ILSpy, and pulled apart the Code Analysis rule assembly to find the following “hack” by Microsoft. If you want to take a look, the DLL is located in: %ProgramFiles(x86)%\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\Rules\PerformanceRules.dll

    There is a class for each rule, the one I was interested in was called MarkMembersAsStatic with the hack located in this method:

    private static bool IsVSUnitTestMethod(Method method)
        if (method.get_IsStatic() ||
            method.get_Parameters().get_Count() > 0 ||
            method.get_ReturnType() != FrameworkTypes.get_Void())
            return false;
        for (int i = 0; i < method.get_Attributes().get_Count(); i++)
            AttributeNode attributeNode = method.get_Attributes().get_Item(i);
            if (attributeNode.get_Type().get_Name().get_Name() ==
                "TestInitializeAttribute" ||
                attributeNode.get_Type().get_Name().get_Name() ==
                "TestMethodAttribute" ||
                attributeNode.get_Type().get_Name().get_Name() ==
                return true;
        return false;

    Remember, this is disassembled code and has been re-formatted by me

    That’s right, there is an explicit suppression of the CA1822 rule against any method with an attribute called [TestInitialize], [TestMethod] or [TestCleanup]. Well, that explains that little mystery.

    So far, I’ve not had any problems with xUnit.net, now I figured this out, and at some point in the future I may post more about my journey through TDD with it.

  • Getting a Windows 8 Live Tile for a WordPress

    Scott Hanselman has just posted on his blog about how easy it is to get a Windows 8 / 8.1 Live Tile for your own site. At the bottom he posted a link to the Custom Windows Pinned Tiles plugin for WordPress by Nick Hasley

    I thought I’d give it a go, and after a few minutes of clicking, and a little hacking in Paint.net to make an icon, I now have a live tile that displays updates of from my RSS feed:


    This really was easy, a big thanks to Nick for this awesome plugin.

    Update 2015

    Since migrating to Jekyll, this has been broken, I’ll look into fixing this one day.

subscribe via RSS