Excel Art – The New ASCII Art?

Reading my daily CodeProject newsletter today, I came across this article about a Japanese artist who uses the graphic editing tools in Excel to create art.

Like many commenters, I disappointed that he hadn’t actually used Excel cells to create the image in the style of Pointillism.

If you know C# this is not a problem, and a few minutes later we have this code:

            // gembox spreadsheet key set

            // create the Excel output file
            var xl = new GemBox.Spreadsheet.ExcelFile();
            var ws = xl.Worksheets.Add("IBMPC");

            const string imageResource= "ExcelPaint.IBM PC 5150.jpg";

            var thisEXE = System.Reflection.Assembly.GetExecutingAssembly();
            using (var resource = thisEXE.GetManifestResourceStream(imageResource)) 
                var img = new Bitmap(resource);
                for (int x = 0; x < img.Width; x++)
                    for (int y = 0; y < img.Height; y++)
                        // get pixel colour from image
                        Color pixel = img.GetPixel(x, y);

                        // write to Excel cell
                        ws.Cells[y, x].Style.FillPattern.PatternForegroundColor= pixel;
                        ws.Cells[y, x].Style.FillPattern.PatternStyle = GemBox.Spreadsheet.FillPatternStyle.Solid;


I use the excellent GemBox SpreadSheet library for my Excel interaction. The code should not really need any explanation: read a pixel, write a “pixel”.

The resulting output is an Excel Spreadsheet, as shown below. Initially the aspect-ratio of the image was distorted as the cells were not square. I manually resized the column widths to 2, and it looks correct.


You can download the resulting output yourself here. I have to admit this is not going to win awards for image compression techniques: the original JPG was only 43KB and the Excel sheet was 1291KB. But hey, it’s 100% cooler.

For reference this is the original image:

In case you’re wondering – why an old PC as a test picture? This was the first suitable image I found, it’s one of my collection of old computers. It’s also a reference to the ASCII art of days gone by.

Controller is Missing from “Add New Item” Dialog in Visual Studio 2012

We upgraded an ASP.NET 4.0 WebForms application to use MVC4 – but the “Add New Item” dialog didn’t list Controller in the list of web file types.

After a bit of research and using a file compare tool, I found this is controlled by the “ProjectGuidTypes” setting in the .csproj file.

An MVC web project will have the {E3E379DF-F4C6-4180-9B81-6769533ABE47} type in this setting. If your project isn’t showing this option, try adding this to the setting, e.g. :


Unit testing private methods

Until the release of Visual Studio 2012 (VS2012), it was possible to create an accessor class in MS Test code that allowed you to test private and protected methods in classes. In VS2012 this has been deprecated (although not yet removed).

While looking for alternatives for testing private I came across this StackOverflow article about nUnit, and the accepted answer is that the theory is you should only be testing the public methods on a class.

Wrong, wrong, wrong

I contend this is a totally misguided theory. The purpose of unit testing is to ensure our code operates in the way it was intended to operate. If we ignore private code inside the class, we are making an assumption that the public methods will operate in a way that allows us to deterministically test the internal code. This is not necessarily the case, and might even lead to having to change the code to allow us to test the private methods in this way. This would be wrong.

I can see why this theory arises: if a method is private, it’s internal and we the developer did not intend that a production application using that class should use this method. That’s fine: but in unit testing we are not in a production environment, we are in the abstract, testing environment. We are not just ensuring the public methods work, we want to be assured the private ones work as well.

In this case we need to ensure that each method (whether private or public) operates as intended. It cannot be called unit testing if we only test the public class. This is integration testing.


I was debugging an open source library called MvcRouteUnitTesting. This has a private ValueCompare() method that takes two objects and tries to see if they are equal.

There are several edge cases where I suspected this method has a bug, and states that two identical values are not equal, when in fact they are.

If we follow the Public-Only-Theory we would need to create instances of the containing class and set the data such that the method would be called for each test case.

But we are then hostage to the public method implementation: in reality our test is testing both the containing class as well as the method in question. A later revision of the public method code might make our tests pass even though we are trying to test something else.

We are not actually testing just the unit method in question we are testing the whole codebase.

VS2012–Testing My Patience

Another thing I’ve come across in Visual Studio 2012 is the new Test Explorer.

Where the Solution Explorer has gone from strength to strength, the Test Explorer has gone backwards.

Let’s look at the group by option in Visual Studio 2010:


Now let’s see how this has improved in Visual Studio 2012’s Test Explorer:


Okay, I know you’re working on it Visual Studio team. Release the new one in version 2011SP1 if it’s not ready. But you’ve actually killed the testing functionality in VS2012.

I used the class name as a functional part of the test, so the group by enabled me to find a set of tests related to a class, focus on those and move on.

My VS2010 grouped list looks like this:


Here is the same project in VS2010:


Now I have a sea of similarly-named test methods and no clue which one does what because I’ve lost the context of the class and project it relates to.

I have to consider renaming all my tests. Or switching back and doing my testing is VS2010 – which is exactly what I do.

Yes, I know the VS2012 team is aware of this and are planning to do something. But it’s like they removed the stairs from my house to fit a lift (elevator for those in the US) but didn’t finish the job. I’ve moved in and now have to get upstairs by climbing the scaffolding.


Since this original post, the Test team has since included the updates to the testing functionality in Visual Studio 2012 Update 1 so that you can now group by module and ‘traits’ (TestProperty attributes in VS unit tests). Thank you VS TestTeam – finally I can retire VS2010!

VS2012 – Fifty Shades of Grey

There are lots of good and interesting things in Visual Studio 2012, but there are (as always) some negative points.

Grey Greyer Greyest

I still hate the new bland UI colour scheme. It’s like a minimalist architect got hold of the Victorian Gothic that was VS2010, and removed everything.

That is a personal, aesthetic viewpoint and some people must love it, but this new bland UI is actually bad from a practical, functional viewpoint.

Why Icons?

I’m ‘old school’ so I remember what apps were like before icons. WordPerfect and Lotus 123 had no GUI, so text was all you had. Finding commands among the sea of text was hard because (unless you learned their location through experience) you had to read each text entry to figure out what it was.

Icons were introduced to get rid of load of text and provide a shortcut: to make it faster to find the command you needed. People can see and filter a lot of pictures much faster than words. To quote Wikipedia (my emphasis):

The icon itself is a small picture or symbol serving as a quick, intuitive representation of a software tool, function or a data file accessible on the system

Why VS2012 Got It Wrong

In this respect the new icons work against you. Microsoft has reintroduced a little splash of colour in some, but it’s grudging and barely visible except up close.

Take this example, where we compare VS2010 and VS2012 toolbars:


Now the challenge: find the previous bookmark icon

VS2010: image

VS2012: image

How did you fare? Chances are that the VS2012 took longer because all the icons are very similar and the colour hint is so subtle as to be almost pointless.

The pale blue is dominant in the VS2010 icon so you can visually filter out most of the icons because they are obviously different. In VS2012 the dominant colour is black, as it is in most of the icons.

It would seem that now VS2012 favours form over function.

It Doesn’t Stop There

Okay so the icons are rubbish. What about the fifty-shades-of-grey scheme? Well if that’s what the design team like fine, but why just two options? Why not allow us to customise it?

The designers have tried to flatten out the interface and remove all the borders. I can almost hear the design meeting: “too much visual clutter!”

So they threw out the baby with the bathwater and removed all the boxes. So now the menu, the icons, the tabs and the toolbars all float together in design nirvana.

So, like a farm where all the hedges were removed, everything visually wanders about and the menu and icons and workspace all tend to blur together.

“I know!” pipes up a junior member in the design meeting, “what if we make all the menu commands in CAPS? Then it’ will be easier to make out!”

And so it came to pass.

Roll on, VS2014.


Thankfully I’m not alone, and there are now extensions to alleviate the worst of the VS2012 UI:

Visual Studio 2012 Color Theme Editor

and even

Visual Studio Icon Patcher

The colour editor seems to work fine. The icon patcher requires both 2010 and 2012 installed and is a a first beta, so you may not want to try that out.

VS 2012 Cool Features

A lot of Microsoft blogs have focused on the high level changes in Visual Studio 2012 but there are lots of small, but cool IDE changes.

Despite the new fifty-shades-of-grey interface (which I think is taking minimalism too far) here are some of the ones I like:

Solution Explorer – now with Go-Faster-Stripes

Multiple Explorer Windows

You have a big solution: say ten or twenty projects. You’ve got a great nested folder structure on each. But the thing you’re working on requires files in a subfolder at the very top project, and some others in the bottom project.

Working with the files in this situation makes solution explorer more like “solution disorienter” as you have to flick back and forth.

But now you can open more than one instance! Right click on any project or folder:


Note the new “New Solution Explorer View” – click this and a new window appears. If you clicked a project or a folder, the new Scope to This feature is used: the new window only has that scope showing. Now you can open two, three or more scopes on just the folders you need to work with, and not the whole project.

Suspend Work

Something I’ve not played with yet, as I think it requires TFS 2012, is the Suspend Work option. This saves not just the window states, but the whole workspace and the source control changes. It’s like Shelvesets-on-steroids. Hopefully it works better than Shelvesets.