What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 129 Stack Exchange communities.

I just noticed that the color of this code doesn't look right in the code block.

List<int> will give <int> a red color, as will List<string>.

List<int[]> is colored correctly, as is List<Integer>. And by "correctly" I mean the way Visual Studio renders the color.

--Addition by Kevin Vermeer--
Here's how Stack Overflow renders the code:

Current Prettify highlighting

and here's how Visual Studio renders the code:

Note: The Integer class is undefined here

enter image description here

Here's an example on a live Stack Overflow question:

C# Lambda - remove items from list 1 not in list 2

Clarification from OP
This question took more bashing than I had expected. I'll try to explain the question and myself a bit further, without starting a discussion.

  • int, string, char, float, bool etc. are data types that almost always appear in blue, at least when posting c# code to SO. That's why I found it odd when it was colored red within < > tags, and even the tags themselves appear in red. I think this would have been more consistent:

    enter image description here
    And by consistent I don't mean how Visual Studio colors the code but keeping the colors consistent within a code-block on SO. That means data types should be blue even when appearing between < > tags.

  • The reason I put the word correctly in scare quotes is because I know there is no correct way of coloring code and that Visual Studio is not the standard (although it sure looks like the coloring of C# code on SO tries to follow that of Visual Studio).

    Scare quotes may indicate that the writer does not accept the usage of the phrase (or the phrase itself), that the writer feels its use is potentially ironic, or that the writer feels it is a misnomer. -Wikipedia

    ...More often though, scare quotes (which are also sometimes called sneer quotes) are used to impart a sense of irony or disdain.
    -Quick and Dirty Tips

share|improve this question
2  
Which question are you seeing this on? Syntax highlighting depends in part on the tags used in the question. –  Anna Lear Nov 8 '11 at 16:31
    
Ah, I see what you mean. The syntax highlighter on SO isn't based on what Visual Studio does, so there might certainly be differences. –  Anna Lear Nov 8 '11 at 16:41
14  
When did Visual Studio become the standard for user interface correctness? –  Caleb Nov 8 '11 at 16:42
2  
I think it's fair to say that the majority of C# developers use Visual Studio. And it's probably also fair to say that most of those users don't customize their color schemes. Now, other languages like Java, Python, Perl, etc.. that don't have a de-facto IDE (or are more often than not written in a terminal or plain-text editor) leave a lot of room for "creative license" when it comes to colorizing their elements. That being said, if most C# developers use Visual Studio, then doesn't it make sense (from a consistency standpoint) to have code samples that match Visual Studio's color scheme? –  Adam Maras Nov 8 '11 at 18:59
    
@Caleb - Please see my clarification. –  Niklas Nov 9 '11 at 12:00

2 Answers 2

up vote 10 down vote accepted

by "correctly" I mean the way Visual Studio renders the color.

This is not the "Correct" way. The correct way in this case is the way that Google Prettify, the highlighting engine powering Stack Exchange code blocks, highlights C#. And, in this case, it's doing it the same way that it highlights on every other C# code block.

Submit a patch to the Prettify project if you want this changed to match Visual Studio. You'll do well to remember that Visual Studio's scheme is not the only way to render C#. Consistency is meritorious, but you'll want to justify the change by analyzing other things like speed, consistency with other languages, and clarity/aesthetics.

share|improve this answer
    
Alright, I didn't know SO used Google Prettify and I've taken my question to their forum now. Please have a look at my update on this question too. I also want to say that my Visual Studio (2010) does not render the code as in the second picture, but more a combination of the two pictures you posted. –  Niklas Nov 9 '11 at 11:02
    
I also have Visual Studio 2010 (Professional), and that's what I used to create the screenshot. I just installed it last week; those are the defaults. I can't tell you what the defaults are in 2005 or 2008; I'm rocking the Textmate Vibrant Ink theme in those. –  Kevin Vermeer Nov 9 '11 at 13:18
    
I know now that the inconsistency lies within Prettify. But, please tell me that you understand this has nothing to do with Visual Studio but with the inconsistency in coloring data types in code-blocks on SO? If you don't agree then would you please explain to me why you think a data type should have a different color in these two cases? –  Niklas Nov 9 '11 at 15:01
    
@Niklas - I understand, but I don't think it's a big deal. The code is still quite readable in either case. I don't memorize the highlighting enough to depend on it being colored either way. As long as you're not using list<int> and list<int[]> simultaneously, either way seems allowable. It's a small inconsistency in Prettify, and one that I'm OK with. –  Kevin Vermeer Nov 9 '11 at 15:42
    
Thank you for that answer and I totally agree. –  Niklas Nov 9 '11 at 15:52

The color coding is correct, it's the default color formatting for Prettify. Keep in mind that Visual Studio itself can be completely customized in its color schemes, the default or any customization is not "correct", it's just one way of doing it. Prettify is another way (color scheme) of doing it as well.

Also keep in mind that even C# isn't tied to Visual Studio, notepad works fine...so there really is no reason to think VS is "correct" here, it's just what some users are used to.

share|improve this answer
    
Please have a look at my update and my comment on @Kevin Vermeer's answer. –  Niklas Nov 9 '11 at 11:04
    
@Niklas - ...okay, but it's still not a bug, this is the color scheme for code we've used for over 3 years, it just happens not to match how Visual Studio works. Go nuts on your quest to change it, but Prettify is pretty well established, don't know that you'll have much luck :) –  Nick Craver Nov 9 '11 at 11:18
    
I'm just curious as to why this question has 8 down votes (I don't know how you voted). Is it because I tagged it "bug" instead of "discussion" or because I didn't know SO used Prettify to color code? How should I have written the question? –  Niklas Nov 9 '11 at 12:00
    
@Niklas - On meta votes typically mean that someone agrees or disagrees with the request...so in this case most of the downvoters would probably disagree this is an issue, or something that should be changed. Don't take it personally, that's just how meta works! –  Nick Craver Nov 9 '11 at 12:04
    
I understand that people might not agree with my question and I can take the down votes, but for the right reason. It seems even you don't understand my point exactly since you start with The color coding is correct... and continue in the comments with ...happens not to match Visual Studio. My point was that a data type should be colored in the same way through out a posted code-block on SO. The data types could be colored orange for all I care, but then ALL data types should be orange. That's the inconsistency I wanted to point out, even if it's not up to SO to change it. –  Niklas Nov 9 '11 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .