Skip to content

Make aliases an option

Do you prefer int or Int32? How about string or String? Some developers have strong preferences, others don’t care. Personally, I prefer to use the actual CLR type names (in other words I prefer Int32 and String) and since I do, I feel as though I am a second-class citizen.

Interestingly enough, it is Visual Studio who makes me feel this way! I am constantly frustrated when I use intellisense to auto-populate an object instantiation like this:

Dictionary<String,Int32> dictionary = new

If I use intellisense to populate the remaining code I am left with this:

Dictionary<String,Int32> dictionary = new Dictionary<string,int>();

This happens with any code that Visual Studio generates on my behalf: method overrides, method stubs, etc. It would be really nice to be able to specify that I prefer to use the CLR type names over their C# aliases. So I am making an official Visual Studio feature request:

Please allow us to specify whether or not suggested and generated code uses C# aliases or CLR type names.

Those of us who care will greatly appreciate it.

5 Comments

  1. Brian

    I’ll sign your petition.

    Posted on 28-Nov-09 at 12:53 pm | Permalink
  2. Maybe a petition isn’t such a bad idea :)

    Posted on 28-Nov-09 at 12:56 pm | Permalink
  3. Michael Chandler

    AFAIK the recommendation is to use the language’s ‘native’ alias, i.e. int in C#, Integer in VB.NET.

    Why not just var dictionary = new Dictionary<String,Object> … then you don’t hit the problem :-)

    Posted on 25-Apr-10 at 4:08 am | Permalink
  4. Michael Chandler

    Does your blog have some type of code tag? It’s really annoying losing the less than / greater than symbols!

    Posted on 25-Apr-10 at 4:10 am | Permalink
  5. @Michael Chandler – I am working setting up a better textbox for comments – currently all angle brackets are stripped out. Sorry about that! As for using var, that is not a bad idea – at least I can avoid the pain when I use local variables! :)

    Posted on 25-Apr-10 at 6:25 am | Permalink

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*