Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0"?>
- <SyntaxDefinition name="C#" extensions=".cs" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
- <!-- The named colors 'Comment' and 'String' are used in SharpDevelop to detect if a line is inside a multiline string/comment -->
- <Color name="Comment" foreground="Green" exampleText="// comment" />
- <Color name="String" foreground="#A31515" exampleText="string text = "Hello, World!""/>
- <Color name="StringInterpolation" foreground="#A31515" exampleText="string text = $"Hello, {name}!""/>
- <Color name="Char" foreground="#A31515" exampleText="char linefeed = '\n';"/>
- <Color name="Preprocessor" foreground="Green" exampleText="#region Title" />
- <Color name="Punctuation" exampleText="a(b.c);" />
- <Color name="ValueTypeKeywords" foreground="Blue" exampleText="bool b = true;" />
- <Color name="ReferenceTypeKeywords" foreground="Blue" exampleText="object o;" />
- <!-- <Color name="MethodCall" foreground="MidnightBlue" fontWeight="bold" exampleText="o.ToString();"/> -->
- <Color name="NumberLiteral" foreground="DarkBlue" exampleText="3.1415f"/>
- <Color name="ThisOrBaseReference" foreground="Blue" exampleText="this.Do(); base.Do();"/>
- <Color name="NullOrValueKeywords" foreground="Blue" exampleText="if (value == null)"/>
- <Color name="Keywords" foreground="Blue" exampleText="if (a) {} else {}"/>
- <Color name="GotoKeywords" foreground="Blue" exampleText="continue; return null;"/>
- <Color name="ContextKeywords" foreground="Blue" exampleText="var a = from x in y select z;"/>
- <Color name="ExceptionKeywords" foreground="Blue" exampleText="try {} catch {} finally {}"/>
- <Color name="CheckedKeyword" fontWeight="bold" foreground="DarkGray" exampleText="checked {}"/>
- <Color name="UnsafeKeywords" foreground="Olive" exampleText="unsafe { fixed (..) {} }"/>
- <Color name="OperatorKeywords" fontWeight="bold" foreground="Pink" exampleText="public static implicit operator..."/>
- <Color name="ParameterModifiers" foreground="Blue" exampleText="(ref int a, params int[] b)"/>
- <Color name="Modifiers" foreground="Blue" exampleText="static readonly int a;"/>
- <Color name="Visibility" foreground="Blue" exampleText="public override void ToString();"/>
- <Color name="NamespaceKeywords" foreground="Blue" exampleText="namespace A.B { using System; }"/>
- <Color name="GetSetAddRemove" foreground="Blue" exampleText="int Prop { get; set; }"/>
- <Color name="TrueFalse" foreground="Blue" exampleText="b = false; a = true;" />
- <Color name="TypeKeywords" foreground="Blue" exampleText="if (x is int) { a = x as int; type = typeof(int); size = sizeof(int); c = new object(); }"/>
- <Color name="SemanticKeywords" foreground="Blue" exampleText="if (args == null) throw new ArgumentNullException(nameof(args));" />
- <Color name="ClassName" foreground="#2B91B2" exampleText="class MyClass{}; MyClass a = new Namespace.MyClass();" />
- <Property name="DocCommentMarker" value="///" />
- <RuleSet name="CommentMarkerSet">
- <Keywords fontWeight="bold" foreground="Red">
- <Word>TODO</Word>
- <Word>FIXME</Word>
- </Keywords>
- <Keywords fontWeight="bold" foreground="#E0E000">
- <Word>HACK</Word>
- <Word>UNDONE</Word>
- </Keywords>
- </RuleSet>
- <!-- This is the main ruleset. -->
- <RuleSet>
- <Span color="Preprocessor">
- <Begin>\#</Begin>
- <RuleSet name="PreprocessorSet">
- <Span> <!-- preprocessor directives that allows comments -->
- <Begin fontWeight="bold">
- (define|undef|if|elif|else|endif|line)\b
- </Begin>
- <RuleSet>
- <Span color="Comment" ruleSet="CommentMarkerSet">
- <Begin>//</Begin>
- </Span>
- </RuleSet>
- </Span>
- <Span> <!-- preprocessor directives that don't allow comments -->
- <Begin fontWeight="bold">
- (region|endregion|error|warning|pragma)\b
- </Begin>
- </Span>
- </RuleSet>
- </Span>
- <Span color="Comment">
- <Begin color="XmlDoc/DocComment">///(?!/)</Begin>
- <RuleSet>
- <Import ruleSet="XmlDoc/DocCommentSet"/>
- <Import ruleSet="CommentMarkerSet"/>
- </RuleSet>
- </Span>
- <Span color="Comment" ruleSet="CommentMarkerSet">
- <Begin>//</Begin>
- </Span>
- <Span color="Comment" ruleSet="CommentMarkerSet" multiline="true">
- <Begin>/\*</Begin>
- <End>\*/</End>
- </Span>
- <Span color="String">
- <Begin>"</Begin>
- <End>"</End>
- <RuleSet>
- <!-- span for escape sequences -->
- <Span begin="\\" end="."/>
- </RuleSet>
- </Span>
- <Span color="Char">
- <Begin>'</Begin>
- <End>'</End>
- <RuleSet>
- <!-- span for escape sequences -->
- <Span begin="\\" end="."/>
- </RuleSet>
- </Span>
- <Span color="String" multiline="true">
- <Begin>@"</Begin>
- <End>"</End>
- <RuleSet>
- <!-- span for escape sequences -->
- <Span begin='""' end=""/>
- </RuleSet>
- </Span>
- <Span color="String">
- <Begin>\$"</Begin>
- <End>"</End>
- <RuleSet>
- <!-- span for escape sequences -->
- <Span begin="\\" end="."/>
- <Span begin="\{\{" end=""/>
- <!-- string interpolation -->
- <Span begin="{" end="}" color="StringInterpolation" ruleSet=""/>
- </RuleSet>
- </Span>
- <!-- don't highlight "@int" as keyword -->
- <Rule>
- @[\w\d_]+
- </Rule>
- <Keywords color="ThisOrBaseReference">
- <Word>this</Word>
- <Word>base</Word>
- </Keywords>
- <Keywords color="TypeKeywords">
- <Word>as</Word>
- <Word>is</Word>
- <Word>new</Word>
- <Word>sizeof</Word>
- <Word>typeof</Word>
- <Word>stackalloc</Word>
- </Keywords>
- <Keywords color="TrueFalse">
- <Word>true</Word>
- <Word>false</Word>
- </Keywords>
- <Keywords color="Keywords">
- <Word>else</Word>
- <Word>if</Word>
- <Word>switch</Word>
- <Word>case</Word>
- <Word>default</Word>
- <Word>do</Word>
- <Word>for</Word>
- <Word>foreach</Word>
- <Word>in</Word>
- <Word>while</Word>
- <Word>lock</Word>
- </Keywords>
- <Keywords color="GotoKeywords">
- <Word>break</Word>
- <Word>continue</Word>
- <Word>goto</Word>
- <Word>return</Word>
- </Keywords>
- <Keywords color="ContextKeywords">
- <Word>yield</Word>
- <Word>partial</Word>
- <Word>global</Word>
- <Word>where</Word>
- <Word>select</Word>
- <Word>group</Word>
- <Word>by</Word>
- <Word>into</Word>
- <Word>from</Word>
- <Word>ascending</Word>
- <Word>descending</Word>
- <Word>orderby</Word>
- <Word>let</Word>
- <Word>join</Word>
- <Word>on</Word>
- <Word>equals</Word>
- <Word>var</Word>
- <Word>dynamic</Word>
- <Word>await</Word>
- </Keywords>
- <Keywords color="ExceptionKeywords">
- <Word>try</Word>
- <Word>throw</Word>
- <Word>catch</Word>
- <Word>finally</Word>
- </Keywords>
- <Keywords color="CheckedKeyword">
- <Word>checked</Word>
- <Word>unchecked</Word>
- </Keywords>
- <Keywords color="UnsafeKeywords">
- <Word>fixed</Word>
- <Word>unsafe</Word>
- </Keywords>
- <Keywords color="ValueTypeKeywords">
- <Word>bool</Word>
- <Word>byte</Word>
- <Word>char</Word>
- <Word>decimal</Word>
- <Word>double</Word>
- <Word>enum</Word>
- <Word>float</Word>
- <Word>int</Word>
- <Word>long</Word>
- <Word>sbyte</Word>
- <Word>short</Word>
- <Word>struct</Word>
- <Word>uint</Word>
- <Word>ushort</Word>
- <Word>ulong</Word>
- </Keywords>
- <Keywords color="ReferenceTypeKeywords">
- <Word>class</Word>
- <Word>interface</Word>
- <Word>delegate</Word>
- <Word>object</Word>
- <Word>string</Word>
- <Word>void</Word>
- </Keywords>
- <Keywords color="OperatorKeywords">
- <Word>explicit</Word>
- <Word>implicit</Word>
- <Word>operator</Word>
- </Keywords>
- <Keywords color="ParameterModifiers">
- <Word>params</Word>
- <Word>ref</Word>
- <Word>out</Word>
- </Keywords>
- <Keywords color="Modifiers">
- <Word>abstract</Word>
- <Word>const</Word>
- <Word>event</Word>
- <Word>extern</Word>
- <Word>override</Word>
- <Word>readonly</Word>
- <Word>sealed</Word>
- <Word>static</Word>
- <Word>virtual</Word>
- <Word>volatile</Word>
- <Word>async</Word>
- </Keywords>
- <Keywords color="Visibility">
- <Word>public</Word>
- <Word>protected</Word>
- <Word>private</Word>
- <Word>internal</Word>
- </Keywords>
- <Keywords color="NamespaceKeywords">
- <Word>namespace</Word>
- <Word>using</Word>
- </Keywords>
- <Keywords color="GetSetAddRemove">
- <Word>get</Word>
- <Word>set</Word>
- <Word>add</Word>
- <Word>remove</Word>
- </Keywords>
- <Keywords color="NullOrValueKeywords">
- <Word>null</Word>
- <Word>value</Word>
- </Keywords>
- <Keywords color="SemanticKeywords">
- <Word>nameof</Word>
- </Keywords>
- <!-- Mark previous rule-->
- <!--<Rule color="MethodCall">
- \b
- [\d\w_]+ # an identifier
- (?=\s*\() # followed by (
- </Rule>-->
- <!-- The type name in the type definition -->
- <Rule color="ClassName">
- (?<=class|interface|enum)\s+([\d\w_]*)
- </Rule>
- <!-- The type inheritions or implementations -->
- <Rule color="ClassName">
- (?<=(class|interface)\s+[\d\w_]*\s*\:[\d\w_\,\s|.]*)
- [\d\w_]+
- (?=\s*($|\,|\{))
- </Rule>
- <!-- The type parameters of a generic class: List<MyClass> -->
- <Rule color="ClassName">
- (?<=<[\d\w_\,\.\s<>]*) #starts with <
- [\d\w_]+
- (?=(\[\])?(>|\s*\,[\s\.\d\w\,\[\]<>]*>)) #ends with >
- </Rule>
- <!-- The class name of generic class example: Dictionary<string,bool> -->
- <Rule color="ClassName">
- \b
- [\d\w_]+ # the class name
- (?=<[\d\w_\,\.\s<>]+>) # followed by something between < and >
- </Rule>
- <!-- The class name in any variable or property declaration, or function -->
- <Rule color="ClassName">
- \b
- [\d\w_]+ # the class name
- (?=(\s*\[[0-9]*\])?\s+[\d\w_]+(
- \s*\= # variable assignment
- |
- \; # variable declaration
- |
- \s*\( # open parethese, for return type of function
- |
- \s*\{ # open bracket, for properties
- |
- \s*$)) # end of line without anything, normaly in properties where open bracket is in the next line
- </Rule>
- <!-- The class name in a cast example: (MyClass) a -->
- <Rule color="ClassName">
- \b
- (?<=\() # starts with open parenthese
- \s*
- [\d\w_]+ # the class name
- \s*
- (?=\)\s*[\d\w_]+) # ends with close parenthese followed by an identifier
- </Rule>
- <!-- The class name of a method parameter example: (ref MyClass a, params MyClass[] b, MyClass c) -->
- <Rule color="ClassName">
- \b
- [\d\w_]+
- \s+
- (?=[\d\w_]+\s*[\,\)]+)
- </Rule>
- <!-- The class name in new instance -->
- <Rule color="ClassName">
- \b
- (?<=new\s+[\d\w_\.]*)
- [\d\w_]+
- (?=(\s*\[[0-9]*\])?(
- \s*\( # open parethese, for constructor parameters
- |
- \s*\{ # open bracket, for properties
- |
- \s*$)) # end of line, for properties in next line
- </Rule>
- <!-- Digits -->
- <Rule color="NumberLiteral">
- \b0[xX][0-9a-fA-F]+ # hex number
- |
- ( \b\d+(\.[0-9]+)? #number with optional floating point
- | \.[0-9]+ #or just starting with floating point
- )
- ([eE][+-]?[0-9]+)? # optional exponent
- </Rule>
- <Rule color="Punctuation">
- [?,.;()\[\]{}+\-/%*<>^+~!|&]+
- </Rule>
- </RuleSet>
- </SyntaxDefinition>
Advertisement
Add Comment
Please, Sign In to add comment