views:

798

answers:

4

Coming from Eclipse, I'm disappointed with the very limited syntax coloring capabilities offered for C# by Visual Studio (all versions, up to 2010).

In particular, I'm interesting in distinct coloring for methods / fields / locals / static stuff.

I'm aware Visual Assist can enhance the coloring, but I've failed to find any free alternative capable of doing that, so I'm turning to SO (I hope it's programming-related enough). Is there any free (or at least cheaper than Visual Assist) solution capable of enhancing the syntax coloring for C#?

+7  A: 

It's not free, but ReSharper does this (and quite a lot more besides):

http://www.jetbrains.com/resharper/features/coding_assistance.html#Syntax_Highlighting

Warren
So it does, but looks like it's as expensive as Visual Assist, if not more :(
Oak
It's not expensive once you've found out how much it increases your productivity.
Diego Mijelshon
R# is invaluable. Once you have it, you will not be able to live without it. It makes coding so much more pleasurable. VisualAssist is more for C++ than anything else.
sylvanaar
ReSharper basically makes Visual Studio comparable to Eclipse. You're going to keep finding missing features until you get it.
Greg
+2  A: 

Hmya, watch out: one IDE's flaw is another IDE's feature. Visual Studio's syntax coloring is purely based on lexical analysis. Fast, simple and always accurate, no matter how completely borked the code is while you are editing it. To get the Eclipse-like coloring, the editor needs to be able to parse the code so it can classify identifiers. That's a much harder problem.

More to the point, there are changes in VS2010 that emphasize doing things exactly the opposite way. To get accurate syntax coloring your preferred way, you'd be likely to focus on getting the class "super-structure" done first. Exactly the opposite of what VS2010 is doing. It lets you skip the boring details and type code. And offers refactorings that lets you automatically create the field/property/method declarations from that code.

Microsoft spends a lot of money researching the most effective use of their software. You're liable to cut yourself off from the innovations they came up with if you try too hard getting things back the way you always did it before.

Hans Passant
Yeah, you wouldn't want to disagree with Microsoft's well paid researchers... Why can't it attempt to do a semantic analysis then fall back on purely lexical if the parse fails? Also, I don't see why better highlighting means refactoring is any more or less useful.
Matthew Flaschen
I am aware of the method Visual Studio uses to colorize tokens - I have implemented a syntax colorer in Visual Studio myself, for a different language.I agree, to some extend, that maybe I should accept the cons along with the pros of working differently than how I'm used to, but I don't think I'm asking for a lot - all I want is some syntax coloring and Visual Assist / Resharper seem to implement it just fine...
Oak
So, what did you implement? Lexical coloring or parsing coloring?
Hans Passant
@Hans: Lexical only, and on an even simpler level than what C# does (I only inspected token types).
Oak
A: 

JetBrains ReSharper includes enhanced syntax highlighting but costs a bit more than Visual Assist. It is absolutely worth its price but not only for syntax highlighting.

DevExpress offers CodeRush and RefactorPro probably including enhanced syntax highlighting, too, but I am not sure because I just tested it some time ago (at least it has a very colorful overlay when it comes to refactoring). There is a free edition - CodeRush Xpress - available.

Daniel Brückner
Thanks, but it appears CodeRush Xpress does not have any enhancements to the syntax highlighting.
Oak
+7  A: 

Well, I could understand from the rest of the responses that the answer is a resounding "no, there is no such extension available for free", so I ended up writing one on my own:

better syntax coloring

(light brown for methods, magenta for variables, otherwise their color would have been black)

It's a bit crude, but it works for me - and it was free :)

EDIT: Anyone interested in doing the same - using the "Editor Classification" template, bundled with the Visual Studio SDK, is a great starting point.

Oak
Nice... that's the spirit!! +1
Warren
Any chance of releasing the thing as free/open source so the rest of us can enjoy it?
Omer Raviv