Syntax Highlighting

Syntax Highlighting improves the understanding of source code by changing the font and/or the background. Code elements can be detected more quickly using highlighting. It allows a visual distinction of fields, properties, method parameters, variables, classes, structures, enumerations, methods, events and much more.

Rewards:
  • recognize code elements within a blink of an eye
  • understand any source code faster and better
  • Visual Studio Theme dependent settings of the highlighting

Not convinced yet?

Try it!

Toggle

Highlights

Highlights are used to emphasize specific code elements according to its meaning or purpose. This can be done by the font formatting or the background.

Suggestions:
  • different font colors for types, constructors, methods or events help to differentiate them faster from other text
  • italicized method parameters can be distinguished directly from local variables
Examples:
  • Namespaces
  • Interfaces
  • Classes
  • Class Constructors
  • Class Deconstructors
  • Structures
  • Structure Constructors
  • Enumerations
  • Enumeration Members
  • Primitve Types
  • Delegates
  • Events
  • Sub (Visual Basic)
  • Labels
  • Methods
  • Method Parameters
  • Named Method Parameters
  • Properties
  • Type Parameters
  • Fields
  • Variables
  • Comments
  • Numbers
  • Operators
  • Strings
  • Keywords
  • Preprocessor Statements

Decorators

Decorators allow equal emphasis of different code elements which have similarities (e.g. static methods and static properties).

Suggestions:
  • static methods, fields or properties are immediately recognizable as such by bold typefaces
  • extension methods can be distinguished from normal methods by an underline
Examples:
  • Constants
  • Declarations
  • Structure Members
  • Extension Methods
  • Static
  • Virtual
  • Override
  • Syntax Error
  • Syntax Warning
  • Internal
  • Private
  • Protected
  • Public
  • Own Code (Same Assembly)
  • External Code (Referenced Assembly)

Area Highlights

Area Highlights highlight code areas by means of their background representation. This structures the source code into visual areas, thereby improving orientation. Large code areas where the beginning or the end are not visible can be identified more easily by the highlighting.

Suggestions:
  • Preprocessor areas, classes, methods, properties, or regions can be visually highlighted
  • important code blocks can be marked conspicuously (e.g. unsafe, fixed)
Examples:
  • Constructors
  • Deconstructors
  • Methods
  • Regions
  • Fixed
  • Lock
  • Unsafe
  • Using
  • SyncLock (Visual Basic)
  • Preprocessor Define
  • Preprocessor Error
  • Preprocessor If
  • Preprocessor Line
  • Preprocessor Pragma Warning
  • Preprocessor Pragma Checksum
  • Preprocessor Undefine
  • Preprocessor Warning

Indicators

Indicators mark the location of specific keywords with a visual marker in the left side bar of Visual studio

Suggestions:
  • early outs and returns are more noticeable
Examples:
  • Throw
  • Return
  • Break
  • Goto
  • Continue
  • Exit (Visual Basic)

Example

This example visualizes the advantages of Syntax Highlighting. The code example below shows the default code highlighting of Visual Studio. Enable any predefined highlight from below, to see it in action.

using System.Linq;
using System.Collections.Generic;

namespace Library
{
public delegate void Delegate;
public enum Enumeration
{
Member1
Member2
}

public class Class : BaseClass
{
private Enumeration _field;
public event Delegate Event;
public List<int> Property { get; set; }

public Class()
{
_field = Enumeration.Member2;
BaseEvent += OnBaseEvent;
}

public void OnBaseEvent(int from, int count)
{
System.Console.WriteLine($"{from}, {count}");

var localVariable = new System.Random();
for (int i = from; i < from + count; i++)
{
if (localVariable.Next() % 2 == 0) continue;
Property.Add(i);
}
}

public override void OverrideMethod()
{
if (IsStaticMethod())
throw new System.Exception();

OnBaseEvent(Property.Count(), 10);
}

public static bool IsStaticMethod()
{
return true;
}
}
}
Toggle all
Highlights
Namespaces
Enumeration Members
Class Constructors
Methods
Method Parameters
Properties
Fields
Events
Variables

Decorators
Static
Extension Methods
External Code (Referenced Assembly)

Area Highlights
Constructors
Methods

Indicators
Return
Continue
Throw