Search code examples
visual-studiovisual-studio-2010syntax-highlightingdynamic-language-runtimedynamic-code

How to highlight dynamic code in visual studio


Is it possible and if so how, to make Visual Studio highlight dynamic expressions in code?

When I just hovered above some code, visual studio told me it was a dynamic expression. This made me realize I made a mistake in my code and used one dynamic too many. But I also realized that if I had not hovered, a 'huge swath' of dynamic code that was supposed to be static would have escaped.

So I wondered if it is possible to make Visual Studio change the background color of dynamic expressions, so those pieces will be clearly recognizable.

[edit]
With dynamic expressions I mean the use of the dynamic keyword in regular code.


Solution

  • You would need an Extension. You can create your own, but I would suggest getting pre-built ones.

    Visual Studio has a lot of extensions lately, because of it's popularity. There are many options I could suggest, but many are rather buggy, so I would suggest using one of the safer, more well known ones like Resharper (my all time favorite and that of many others as well)

    I also like JustCode.

    There are so many others available though, and if you want to find them, cruise down the Visual Studio Gallery like Morvader said. Visual Studio Gallery

    EDIT:
    2 notes I forgot to mention:

    • Dynamic Intellisense is included in Resharper
    • Dynamic Highlighting is included as well. If you want to modify the color from the default light blue you can go to Tools->Options...->Environments->Fonts and Colors->Display items->ReSharper Late Bound Identifier
      Also make sure that in Resharper->Options...->Code Inspection->Settings "Enable code analysis" and "Color identifiers" are checked.