Visual-Studio articles

Envy Code R coding font v0.7 preview  

Envy Code R font preview #7 highlighting some of the characters in a chart.The next version of my Envy Code R font especially designed for programming (monospaced, easily distinguishable characters) is nearing completion and represents a very response-driven update to feedback, specifically:

  • ReadOnly, Greg Jandl: Comma clarified and change applied to full quotation marks, semi-colons and various accented letters
  • Adrian Bool, Greg Jandl: The slash on the zero has been redrawn to be less heavy
  • jxp: The Euro symbol has been redrawn from scratch
  • Aristotle Pagaltzis: Braces are more curvy and a full set of box-drawing characters have been added
  • IRC: Hash sign with longer legs

I have also fleshed out a number of additional symbols and accented letters that has seen the number of code pages supported increase to 12 pages and made a large number of tweaks to the italic version which was a last-minute addition to 0.6 (PR6) and had a number of errors especially round the accented letters.

Of course what you really want to know is how the new version looks in Visual Studio with that lovely Humane theme of mine:

Envy Code R font at 10 point in Visual Studio 2008 with my Humane theme.

There is still some work to do on the sizes above and below 10 point (again) as well as fleshing out a few more symbols, letters and italicising additional letters such as a curly k and rounder e which I hope will be finished towards the end of this week.

The observant followers may have noticed a pixel has been shaved off the vertical height which now brings it in line with the bitmapped Envy Code B coding font. I had intended on making the change for some time and the box characters practically demanded it to ensure the centres were whole pixels and not off-centre but some people may not like it…

A newer version of Envy Code R is available.


Droid Sans Mono great coding font  

Google’s Android project, an open platform for mobile devices, has been hitting the news a lot in the last couple of days with it’s open APIs, Java-based development platform and optimized virtual machine which includes the lovely set of typefaces from Ascender known as the Droid family.

Check out previous coverage of the well-known and lesser-known coding fonts.

There are a number of Droid fonts including Droid Sans and Droid Serif but of particular interest for developers is the Droid Sans Mono font that looks great in Visual Studio not only at my favorite 10 point… but from 7 point upwards with either ClearType or standard font smoothing although some might find the fact it smooths at all sizes a little soft (or Mac-like).

Here it is at 9 point with Rob Conery’s Vibrant Ink (WekeRoad Ink) theme:
Screen shot of Droid Sans Mono at 9 point with Vibrant Ink 2 theme in Visual Studio

Here it is at 11 point with my Humane theme:
Screen shot of Droid Sans Mono at 11 point with Humane theme in Visual Studio

And here it is 12 point in Xcode on the Mac:
Screen shot of Droid Sans Mono at 12 point in Xcode on the Mac

The only issues are:

  • the lack of a bold weight or italic variant which limits the syntax highlighting options
  • the 0 is currently not slashed (there could be some other indistinguishable character pairs)

Being that the Droid family is Apache licensed no doubt somebody will fill that gap (okay, okay, I’ll give it a shot when I get some time;-)

Download Droid Sans Mono (TrueType TTF) (79 KB, 10/2011 source)

Try my free scalable coding font Envy Code R (shown below) with Visual Studio italic support, has a bold variant and distinguishable pairs 0O etc:

Envy Code R font at 10 pt with italics in Visual Studio using Humane theme.


Colour schemes for Visual Studio  

The default syntax colour/color scheme in Visual Studio seems to be stuck in the 16-colour era so once you’ve found your perfect font you are going to need a great theme to go with it.

Here is the theme I’m currently using at home (currently on a 42″ 1900×1200 LCD TV until I can find space for my monitor) that a couple of people have asked for.

To to take full advantage of this theme you will need to download:

  • Envy Code R for the syntax font with the italics hack
  • PalmOS for the output window’s tiny text

Alternatively you could remap it to your coding font of choice (but you won’t get italics because of limitations within the Visual Studio IDE).

Screen shot of Envy Code R PR7 with HumaneStudio theme.

If this scheme doesn’t appeal to you then why not try:


Refactoring shared libraries and public APIs  

Refactoring is an essential process to keep code clean and elegant while it evolves. IDE’s offer common refactorings (although somewhat short of those prescribed in Fowler’s excellent Refactoring book and way short of the overall goals explained in Kerievsky’s Refactoring Patterns).

One limitation of existing tools is that they can only update references within your solution. When you are refactoring a shared library this is a problem, especially if it is your public API to the outside world.

We need to introduce metadata to document how the API has evolved and extend the tools to generate and understand this metadata.

Let’s take a look at a few of the refactoring in Visual Studio and see how they could be documented using the .NET metadata mechanism of choice, attributes.


Starting simple lets we had a property named Reference:

public string Reference {
  get { return id; }

We are going to rename Reference to StockCode for the release. The tool could introduce a stub for backward compatibility whilst also marking it with metadata giving us:

[DeprecatedRefactorRename("StockCode", "")]
public string Reference {
  get { return StockCode; }

public string StockCode {
  get { return id; }

The library is both binary and source compatible but with a little IDE work they could get a warning that Reference is now StockCode and given the choice of updating all the references in their project.

Nice. Let’s try a few more:

Remove Parameters

public bool AddStock(int quantity, DateTime arrival, StorageBin location) {

We are switching to a managed warehouse and so we no longer need to know where items are stored so we refactor and remove the StorageBin.

[DeprecatedParameterRemoved("location", "")]
public bool AddStock(int quantity, DateTime arrival, StorageBin location) {
   return AddStock(quantity, arrival);

public bool AddStock(int quantity, DateTime arrival) {

Reorder Parameters

[DeprecatedParametersReordered("arrival, quantity", "")]
public bool AddStock(int quantity, DateTime arrival) {
   return AddStock(arrival, quantity);

public bool AddStock(DateTime arrival, int quantity) {

Move Method

Existing tools offer little support for MoveMethod because they haven’t considered how to refactor the references. It is difficult to retain binary compatibility unless the class has a reference to class that now has the method we are interested in.

[DeprecatedMethodMoved("StockController", "Add", "")]
public bool AddStock(DateTime arrival, int quantity) {
  return stockController.Add(this, arrival, quantity);

Let’s say the current calling code looks something like:

selectedProduct.AddStock(DateTime.Now, input.Value);

However with a little ingenuity the IDE could examine the new method and map existing parameters based on name and type. If it still doesn’t have enough information consider local variables and properties of the objects it does have to present choices. This works especially well if your parameters are not primitives. Our code becomes:

stockController.Add(selectedProduct, DateTime.Now, input.Value);

Keeping it clean

We don’t want our classes being cluttered with deprecated code indefinitely so the solution should contain two extra revision numbers, one detailing the oldest revision of attributes to keep in the source, the other for the oldest revision to compile into the binary. All the [Deprecated] marked methods and properties can slip into another file, perhaps Product.deprecated.cs so they stay out of sight until needed.

For .NET it would need somebody at Microsoft to take this on board and move us forward from ObsoleteAttribute as the facility should be cross-tool and so adding it solely to SharpDevelop would be of limited gain.