Another idea for the C# editor

I was pitching this idea to the team about a new feature we could have for the C# editor, but I wanted to get your ideas on it.  Whether you think it’s good, or bad, or things you think it might do instead.  If you liked it I would add it to that list we’ve been working on for things to add to C#.

Basically I’ve been trying to figure out ways to help users in two areas:. error correction and discoverability of code.  Error correction seems like something we should be a lot better at considering we have an immense understanding of your code, and the context surrounding the error should be quite helpful in figuring out what you probably meant to write.  Helping with discoverability should also be something we do considering that we know about the entire system.  Basically, if we know so much, why do we help so little?

Part of the problem is that we don’t want to be in your face all the time.  Sometimes you just want to code and not be bothered.  How many times do you get mad at Word because you’re typing some stuff and all of a sudden it mucks around with it and you have to fix it?  In our opinions that kind of interference could be a deal breaker for many coders.  We’ve gone slightly against that model with 2005 to test the waters and get feedback from you guys as to whether or not you like it, hate it, or are just ok with it.  We’ve done it in two ways.  One is by bringing up a completion list automatically when you’re typing an identifier, and the other is through the use of smart tags that can help you based on what you’ve just done with the code. 

Bringing up a completion list automatically when typing an identifier seems like a pretty basic idea.  You want to type “Console.WriteLine”, so you start hitting “C” and the completion list is up, the typing of “o” will get you to “Console” and you can know just hit ‘enter’.  When you get used to it it makes for some pretty damn quick typing.  However, it can be a nuisance if you are doing something like typing a call to a method that doesn’t exists yet.  In that case you’ll have to hit ‘esc’ to get the completion list to disappear.  (This is similar with what happens in VS2002/3 when you have a completion list up because you hit <dot> and you type something that isn’t in the list).  One of the things we learned quickly with this feature was that if we didn’t list all relevant information in a completion list then this would drive you crazy.  For example if we didn’t include “out” in the completion list when you were typing a method then instead of typing “out int param” you’d type “OutOfMemoryException int param” because the “o” would bring up the completion list and “out” would select that exception.  Because of this we worked very hard to make sure that at any point in your code we would know everything that was valid to type at that point.  The only times we’d screw up would be if you were coding in a forward thinking style where you were using things before you’d ever declared them (of course, we already screwed this up in the past, so we weren’t too worried).

The smart tags come about in a few places.  Mainly when we want to alert you that we could help you out based on what you’ve just typed.  For example if you have a class called “Foo” and you go to the name, delete it and type “Bar” you’ll get a smart tag that when invoked offers to rename all things that used to refer to “Foo” to now refer to “Bar” instead.  Other examples are when we see that you’ve typed a method call to a method that doesn’t exist.  We’ll offer to generate the stub of that method for you in the appropriate location.  We’ll also now give you a smart tag offering to add a using when you use a type from a namespace you don’t currently have a using for. 

In order to make these features truly useful we had to work very hard to make sure that at edit time we really had a very strong understanding of the system.  This was necessary otherwise we’d just be in the way causing you to get code you didn’t intend to write and also bothering you with unhelpful smart tags (i.e. a smart tag to add a using you already have would just aggravate you).

Because of these enhancements to the core architecture I was able to take the help one step further.  Specifically I spiked a spell checker into the IDE.  It has a few cool (IMO) features and I wanted your feedback on it.  A picture might help out a little:


As you can see the smart tag is broken into three areas.  The first two are the ones you might have already seen in the current releases.  They offer, respectively, possible using‘s and fully qualified name replacements for the unbound item. The third area is new.  It is the section that uses some heuristics to determine what you might have meant if you type a name that we cannot bind.   As you can see, the spelling can be way off and we will still offer relevant correction.  Also the replacement we offer does not have to be a type or namespace, but can be anything legal in C# at that point:

We do aggressive scanning of the system to see what you might have wanted to type, and we try to sort by relevance:

As you can see, we’ve found the your local variable “xmlReader” and we offer it first since it’s probably the most relevant.  However, that was the only thing in the close proximity that came close to what was typed in, so we broaden our search a bit finding some possible matches.

One thing to note is that there are two user interaction models for the spell-checking component of this smart tag.  The first is to correct misspellings for names the user already knew about.  The second is to help youexplore the system.  i.e. if you’re interested in XPath but they don’t know if we have any support for it.  So you type XPath and immediately see a wealth of information.  Yourealize we have a whole namespace dedicated to this which they can then “use” and explore using the rest of the in-code intellisense architecture. 

I was thinking that because there are these two modes it might make sense to split the smart tag into two different things (see paragraph below).  However it kind of makes sense here if you think of this smart tag as a method of resolving unknown names right at one central location.  So rather than having to navigate away to add a using, or having to open object browser to find the right type, we offer the support right in the code and we offer support that no other tool in VS can give (i.e. finding names similar but not exactly like what you typed).

Something else I’ve considered is implementing this more akin to how Word does it with squiggles.  i.e. type a name we don’t recognize and we underline it.  If you right click then we offer the results right there in the completion set.  However, I didn’t implement it this way because I already had the work done for this smart tag and I wanted to make this spike as light as possible.

What do you think?

Comments (45)

  1. * On the left column of the first dropdown picture, how about accelerators for pressing 1, 2, 3, etc. so that one doesn’t have to slowly use arrow keys to get the 5th item. This way I can quickly realize "Oh I want System.Collections and to get this I press 4."

    * Transparency. This would work very well for the normal Intellisense ("typing the dot brings up the menu") as well. It can sometimes be frustrating when typing to have the lines of text below you be hidden from view — sometimes you need this text for various reasons. So this way you get the utility of the new feature, but it doesn’t obscure your view of what you’ve already been working on. Possibly transition to opaque if the mouse moves into the drop-down’s screen rectangle, and back to translucent if it moves outside again. This use of transparency is something I used to great effect in an app I recently worked on: not only does it look cool but it has honest-to-gosh benefits for the user.

  2. Don says:


    I’ve been wanting an IDE with this type of spell-checking for YEARS!

    It all looks good, including the smart tags implementation.


  3. Rick: Great ideas. I’ll see how to work through the accelerator problem.

    Transparency is also great. The debugger has it for the new tooltips. You hit ctrl and it goes to like 10% transparency, allowing you too what’s underneath it. I’ll see if I can add that feature to all of our UI that covers part of the screen.

    Note: Hitting esc will minimize the smart tag back to "tickler" mode. Hitting ctrl<dot> will bring it up again.

  4. Cyrus, By the way, … that is the app I used transparency in.

    Using ctrl to knock it down to 10% doesn’t sound too bad actually … that’s a simple pinky finger away most of the time!

  5. Martin says:

    Great. I really like this. And keep the smart tag. IMHO it’s better than the underlining Word does. The transparency is a good idea, too.

  6. Rick: I’ll talk to the editor team to see how to go about doing that 🙂

    Martin: Why is it better than the underlining?

  7. Cleve Littlefield says:

    I think I like the underlining because most likely I will know that I typed it wrong and that will limit my selection to only suggestions… not the using or fully qualified items. I think they are two different interaction models.

    Another question, is this going to slow my IDE? If so, would separating some stuff into a smart tag and some into the underlines mitigate some of that?

    As for other interaction model, where you type XPath and see a wealth of information, isnt this better displayed in the dynamic help you have now? Does dynamic help use heuristics to come up with its information? Too be honest, I dont use dynamic help because it rarely give me enough information to warrant taking space on my screen.

  8. federico says:


    I’ve not followed all the feedback you have tried to get from users.

    I’ve to be sincere: coming from Intellij IDEA I simply cannot use VS2003 as is (of course a limitation of mine).

    So I’m actually using Resharper.

    I can focus my mind only on these clear consideration as a whishlist:

    1 – I’d like to have a shortcut for a popup of the list of Namespaces/Classes/Methods/… if you get Reshasper working on an instance of VS2003 hit Ctrl+F12

    2 – IDEA/Resharper both assumes the developer is smart enough and don’t try too hard to interpolate the name or to correct it

    3 – navigating the code (go to definition with a shortcut, implements interface, override members, GO TO IMPLEMENTATION when you are on an interface/abstract class)

    4 – organize the using clauses (remove unused)

    5 – when I write the name of a non already ‘using’ class, write the using for me

    6 – restrict complete list only to scope reachable varables compatible with the expected type.

    The IDEA is to have the developer master the code at the higher level possible (writing a misspelled name could mean ‘correct me’ or I’m expressing the intention to define a new class/struct/enum so don’t correct me: help me create the class).

    I’m not pushing Resharper, I’m only saying: see what it can do for a developer, please do that if you want to create a possibly better (at least for me) IDE.

    I don’t think you are too far to those kind of functionality.

    Thank you very much for allowing feedback from users

  9. Speaking about the general topic of completion lists: Are you going to handle the problem that sometimes the sheer number of members makes a completion list a bit annoying to use? Especially if you don’t know the exact name of what you are looking for?

    I wrote about a possible solution here:

  10. Mitch Walker says:

    Very nice. I think I would prefer the squiggle approach as it would give a quick (and visually lightweight) view of code "correctness". Mistyped locals, type names, etc. would be readily apparent and easy to fix.

  11. senkwe says:

    Cyrus, what I’m curious about is, are these just image mock ups or do you actually have some demo code running on your personal build of the IDE. If it’s the latter, it’d make for a cool blog article.

  12. Senkwe: What part of it would make a good blog article?

  13. Roland: I added that to the list of things people could vote for.

  14. senkwe says:

    Cyrus, what I meant was that since I don’t have access to any version of VS 2005, I can’t tell if these images are stuff currently in the beta or if you’re running some specialized build on on your own machine and implementing this stuff as an experiment. So (assuming I’m not looking at photoshopped images) it would be cool to know how you’re interfacing with smart tags inside the editor window and whether or not any of that type of integration is available to third parties as well as what type of performance issues you’re facing and how you’re overcoming them etc etc. Ok so maybe it’s just me thats curious 🙂

  15. Ron says:

    Is the Enter key the only way to auto-complete/correct? I really like the ability to use Tab or <dot> to complete the entry (ala normal intellisense).

  16. Jason Hasner says:

    The ability to customize it would be nice. Something more than turning it on or off all together.

  17. Max Battcher says:

    This Spelling and Grammar checking for C# has led me to another suggested feature idea… How about a "document contains errors" icon ala the Word Spelling and Grammar checking icon (the pen writing, check, x-mark on book icon towards the right hand side of the status bar). At a glance you can tell if the IDE thinks the code is buildable; and if there are any errors from the build. Double click on it to cycle through document errors like old school spell checking… as opposed to doing it TODO item at a time. Word also uses the context menu of the icon for temporarily hiding spelling and grammar highlighting (underlining).

  18. AT says:

    It’s some-that bad idea.

    This will increase pool of people who will start to code first, instead of think first. Once people has design specs and basic code stubs – they do not need correction like you propose.

    Also I prefer to keep people who are unable to spell out override out of SD ;o)

    As well it’s impossible to type "overide" with current IntelliSence (it include all keywords in addition to classes).

    Spell checking must be done only in comments/strings. There is already numerous spell-check Add-ins for VS.NET available from third-parties. They are trivial as they use Office API for dictionaries.

    As well automatically adding "using" is nonsense. "Smart" IDE can add classes not relevant to context. As well – they not add Assembly references automatically if class used is not from currently available assemblies ?

    I prefer C# team better focus on overall software process improvements (like a newly added TDD) instead of typos in code editor.

    You need to focus how IDE will fit in overall SD process picture – Requirements, Design, Coding, Testing, Production, Support/Bug Fixing, Next Iteration

    Small details like spell-checking must be given to third-parties using VSIP.

  19. Daren says:

    I think it would be a great addition, as long as it remains advisory – your example regarding Word is bang on the money (Word 2003 in it’s default configuration DRIVES ME NUTS!). I believe that these kind of language support features for C# are vital in maintaining the reputation of VS as the most productive development environment.

  20. Duncan Godwin says:

    I like the changes and think I would prefer a red squiggle though I would have to play with it for a bit!

    If this were to be implemented I would need some form of ignore/ignore all and I guess custom dictionary which would sit at the project level.

    I can see another use for the red (or another colour) squiggles for indicating unnecessary casts.

    As for other C# editor wishes, what about?:

    * When cutting and pasting code from one file to another if the using statements aren’t already listed offer to add them. Much like Word 2003’s keep existing formatting / use documents formatting.

    * I mentioned in a comment elsewhere about implementing parent class constructors – could this be a Smart tag similar to implementing and interface? e.g. Manager : ->tag<-Employee

    Could the option be provided for implementing abstract methods as well.

    When implementing and interface or overriding a method could there be an editor option to add a using statement rather than fully qualify the type parameters or return values. e.g. if I have an abstract method that takes an XmlReader and I don’t already have System.Xml as a using clause I will get a fully qualified type even though – to me it makes sense just to add a using clause as if I’m going to use one type I’m probably going to use others in the same namespace.

  21. Max Battcher says:

    AT: I prefer to let the computer do as much for me as it can. People are inprecise and prone to errors. Computers are extremely precise and often cannot tolerate errors. The reason we have computers is to automate tasks. Most of the applications I (or anyone else) will right are about automating tasks. Other than games, I’m having a hard time coming up with a program that doesn’t automate some task. So the question becomes why do we spend so much time automating others’ tasks and not thinking about automating our own (taking as much of the grunt work in coding out as we can).

    Also, it appears you haven’t looked much into Agile programming. Strict designs are fine and dandy, but don’t get down quickly. Test first coding, "keep it simple stupid", and design as you go are large parts of getting software done on time and under budget. I often "use" methods before I implement them, and if I were to do more unit testing, as suggested by many, would be doing even more.

    Then you suggest handing this sort of functionality to 3rd Party vendors… Is this your idea of working for job security? Because, I don’t see why, if Microsoft has the time and people to develop as many features as they can, I should pay extra money for features… Not to mention, although these features would be great to have, I don’t think I would pay additional money for them.

  22. Senkwe: Ah, I see. I’ll post later about the process I went about doing this.

  23. Ron: i’m not sure if <tab> will select something in the smart tag drop down. It would make sense for it to since it’s the default completion character in most drop downs.

  24. Cleve: Two things. First, we would only include this if there were no performance overhead over typing.

    Second. I would put it here instead of dynamic help because we’re trying to be very code focussed. Many people disable dynamic help because they just want to use the editor. It also follows the model that we are providing suggestions for how to make your code correct.

  25. Frederico: What does ctrl-f12 do? You can already get a list of namespaces/classes/methods by hitting ctrl-<space>

    2) We are not automaticaly fixing your code, we are offering suggestions when the code is wrong. You don’t have to expand the smart tag if you don’t want to.

    3) We support "goto definition" "implement interface" "override members" "goto implementation"

    4) I’m hearing a lot about cleaning up usings. It’s something we’ll look into.

    5) This is what this feature does. When you use a class without having the "using" we offer to add the using for you.

    6) This is a very good idea, we’ll look into it.

  26. Roland: The large size of completion lists is something we are concerned with and we are thinking about ways in making it better. Thanks for the suggestions, they’re excellent.

  27. Jason: How would you like to customize it?

  28. Mitch: Very true. We also want to be careful though with inundating you with squiggles and other visual distractions.

  29. Max: I believe we already have that support. You can disable or enable the error squigglies that we show. When you’re showing them, f8 will cycle through them.

  30. AT: You’re addressing one side of the features set. The other side is a way to help discover the system around you. Do you not like that either?

    Also, do you not feel that the VS2005 team system software is helping out the software process?

    We have tools to help you design, to help test, to help support, etc.

    You say that we should help with coding. I would think that helping to fix mistakes and to discover the system would be part of that.

  31. Daren: Unlike Word, we would not be doing anything automatically. You would just get a smart tag tickler when we knew we could help correct a problem. ctrl-<dot> or the mouse will bring up the list and you can choose something from that.

    The tickler is pretty innocuous so I don’t think it will bother you.

  32. Duncan: I like the suggestion about unnecessary casts.

    This feature will help you fix up the usings after you paste the code.

    We provide support for implementing abstract methods.

    I like the idea that we automatically add usings when you override a method. I’ll look into that.

  33. federico says:


    by hitting ctrl+<space> you get a completion list where your caret is.

    By hitting Ctrl+F12 you get a navigable list of what is defined in the current file, something like the two historical combo box at the top of the file Visual Studio has always had, only easier to use and to reach without using the mouse.

    As an aside note, another cool feature is ctrl+N to open a toolwindow in wich I can write the name of the type I wich to go to (smart completed of course …)

    or ctrl+shift+N: the same thing but with file names

    Of course shortcuts are only the excuse to talk about the feature … 🙂

    Cyrus, thank you very much for your attention.


  34. Frderico:

    Ahhhh. Very cool 🙂

    This is something that we’ve also been discussing. A way to easily navigate the whole tree based structure of code.

    Thanks for all the info!

  35. Duncan Godwin says:

    In VS2003 I often found a problem where you would be using a class, but because it’s super class wasn’t one of the imported namespaces you would only see the methods in the sub class. This greatly reduced the discoverability of methods in a class and often meant looking at the documentation to find what was needed only to see the class inherits from something that isn’t imported. You get the idea.

    There is a second problem which I think is related but I’m unsure how solvable it is. For example if I type SqlConnection I get prompted to import System.Data.SqlClient. Which is great except a lot of this namespace is very dependent upon System.Data, as soon as you create an SqlCommand and try and set it’s CommandType (or anything similar) you are using items from the other namespace which when used writes out the fully qualified type with namespace. It’s a problem of dependence and associativity. All the child namespaces below System.Data are very much tied to System.Data.

    I’ve been thinking about information about classes. I would consider the core ones to be Disposable, Serializable (attribute or explict interface), Remotable?. It would be really useful

    if these could be shown as small icons as part of the tooltip for the class to save on going to the documentation.

  36. Duncan: I agree taht we should do a better job pulling in all the dll’s you need for full intellisense. THis can be quite confusing and irritating.

    I like your ideas on IDisposable. I’m not sure about Serializable though. I like IDisposable because there are best practises associated with tat we should be helping you with.

    How would knowing if something is serializable help you?

  37. Duncan Godwin says:

    Serializable helps in a number of situations, when I need to persist an object to a database, ASP.NET session state, Remoting request or an MSMQ body.

    So when I’m looking at what objects may/may not be appropriate it’s useful to be able to find out quickly if my intented object is seralizable.

  38. Duncan: Gotcha! Are there any other types you’d like to get specialized feedback on?

  39. Duncan Godwin says:

    There are no other types off the the top of my head without being able to simply view the classes/interfaces a type inherits from.

    I have another idea for where rich validation could save compile time errors – Method parameters could be validated i.e. will the parameter work directly, though a specified cast, or though an IConvertible become an acceptible parameter in a given position.

    This could also work for return values.

    I have a method:

    void DoSomething(int value) {}

    If I type


    The 45 would be underlined in some colour indicating it’s not an int.

  40. There are appropriate places for ticklers and for squiggies.

    A tickler is appropriate as an indicator that there is assistance available to the developer. Its a great indicator for the rename refactoring as well as to expose the option to add a "using" statement. Speaking of usings, please, PLEASE add the ability to auto-order them. Lack of auto-order drives me nuts! (as does the poor job it does with formatting of the next line).

    Squigglies are great indicators that something is broken or could use improvement. In other words, for errors and warnings (Yes, I think ReSharper got that part right). Every known error in code should get a red underline. I should not have to wait to compile to see it. Conversely, the underlines should go away as soon as the error is cleared up.

    Similarly, warnings should get their underlining dynamically rather then compile-iduced and there should be a way to opt out of some or all the warnings. As another commenter suggested, it would be great to either get the full power of FxCop into the dynamic warnings or at least cover some common cases like an unsafe use of an IDisposable object.


  41. Michael; I completely agree.

    However, we do not know until compile time that there is an error. Yes, that’s somewhat lame, but we focussed on adding other things into our architecture for VS2005 rather than that support.

    We defintely do want to do what you’re proposing though!