1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+
3+ <SyntaxDefinition name =" C#" extensions =" .cs" xmlns =" http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008" >
4+ <!-- The named colors 'Comment' and 'String' are used in SharpDevelop to detect if a line is inside a multiline string/comment -->
5+ <Color name =" Comment" foreground =" #57A64A" exampleText =" // comment" />
6+ <Color name =" String" foreground =" #D59D85" exampleText =" string text = " Hello, World!" " />
7+ <Color name =" StringInterpolation" foreground =" #D59D85" exampleText =" string text = $" Hello, {name}!" " />
8+ <Color name =" Char" foreground =" Magenta" exampleText =" char linefeed = '\n';" />
9+ <Color name =" Preprocessor" foreground =" Green" exampleText =" #region Title" />
10+ <Color name =" Punctuation" exampleText =" a(b.c);" />
11+ <Color name =" ValueTypeKeywords" foreground =" #4e8cc1" exampleText =" bool b = true;" />
12+ <Color name =" ReferenceTypeKeywords" foreground =" #4e8cc1" exampleText =" object o;" />
13+ <Color name =" MethodCall" foreground =" #c4c498" exampleText =" o.ToString();" />
14+ <Color name =" NumberLiteral" foreground =" #B5CEA8" exampleText =" 3.1415f" />
15+ <Color name =" ThisOrBaseReference" foreground =" #3C6C9E" exampleText =" this.Do(); base.Do();" />
16+ <Color name =" NullOrValueKeywords" exampleText =" if (value == null)" />
17+ <Color name =" Keywords" foreground =" #569CD6" exampleText =" if (a) {} else {}" />
18+ <Color name =" GotoKeywords" foreground =" #569CD6" exampleText =" continue; return null;" />
19+ <Color name =" ContextKeywords" foreground =" #569CD6" exampleText =" var a = from x in y select z;" />
20+ <Color name =" ExceptionKeywords" foreground =" #569CD6" exampleText =" try {} catch {} finally {}" />
21+ <Color name =" CheckedKeyword" foreground =" #569CD6" exampleText =" checked {}" />
22+ <Color name =" UnsafeKeywords" foreground =" #569CD6" exampleText =" unsafe { fixed (..) {} }" />
23+ <Color name =" OperatorKeywords" foreground =" #569CD6" exampleText =" public static implicit operator..." />
24+ <Color name =" ParameterModifiers" foreground =" #569CD6" exampleText =" (ref int a, params int[] b)" />
25+ <Color name =" Modifiers" foreground =" #569CD6" exampleText =" static readonly int a;" />
26+ <Color name =" Visibility" foreground =" #4e8cc1" exampleText =" public override void ToString();" />
27+ <Color name =" NamespaceKeywords" foreground =" #4e8cc1" exampleText =" namespace A.B { using System; }" />
28+ <Color name =" GetSetAddRemove" foreground =" #4e8cc1" exampleText =" int Prop { get; set; }" />
29+ <Color name =" TrueFalse" foreground =" #569CD6" exampleText =" b = false; a = true;" />
30+ <Color name =" TypeKeywords" foreground =" #569CD6" exampleText =" if (x is int) { a = x as int; type = typeof(int); size = sizeof(int); c = new object(); }" />
31+ <Color name =" SemanticKeywords" foreground =" #569CD6" exampleText =" if (args == null) throw new ArgumentNullException(nameof(args));" />
32+
33+ <Property name =" DocCommentMarker" value =" ///" />
34+
35+ <RuleSet name =" CommentMarkerSet" >
36+ <Keywords fontWeight =" bold" foreground =" Red" >
37+ <Word >TODO</Word >
38+ <Word >FIXME</Word >
39+ </Keywords >
40+ <Keywords fontWeight =" bold" foreground =" #E0E000" >
41+ <Word >HACK</Word >
42+ <Word >UNDONE</Word >
43+ </Keywords >
44+ </RuleSet >
45+
46+ <!-- This is the main ruleset. -->
47+ <RuleSet >
48+ <Span color =" Preprocessor" >
49+ <Begin >\#</Begin >
50+ <RuleSet name =" PreprocessorSet" >
51+ <Span >
52+ <!-- preprocessor directives that allows comments -->
53+ <Begin fontWeight =" bold" >
54+ (define|undef|if|elif|else|endif|line)\b
55+ </Begin >
56+ <RuleSet >
57+ <Span color =" Comment" ruleSet =" CommentMarkerSet" >
58+ <Begin >//</Begin >
59+ </Span >
60+ </RuleSet >
61+ </Span >
62+ <Span >
63+ <!-- preprocessor directives that don't allow comments -->
64+ <Begin fontWeight =" bold" >
65+ (region|endregion|error|warning|pragma)\b
66+ </Begin >
67+ </Span >
68+ </RuleSet >
69+ </Span >
70+
71+ <Span color =" Comment" ruleSet =" CommentMarkerSet" >
72+ <Begin >//</Begin >
73+ </Span >
74+
75+ <Span color =" Comment" ruleSet =" CommentMarkerSet" multiline =" true" >
76+ <Begin >/\*</Begin >
77+ <End >\*/</End >
78+ </Span >
79+
80+ <Span color =" String" >
81+ <Begin >"</Begin >
82+ <End >"</End >
83+ <RuleSet >
84+ <!-- span for escape sequences -->
85+ <Span begin =" \\" end =" ." />
86+ </RuleSet >
87+ </Span >
88+
89+ <Span color =" Char" >
90+ <Begin >'</Begin >
91+ <End >'</End >
92+ <RuleSet >
93+ <!-- span for escape sequences -->
94+ <Span begin =" \\" end =" ." />
95+ </RuleSet >
96+ </Span >
97+
98+ <Span color =" String" multiline =" true" >
99+ <Begin >@"</Begin >
100+ <End >"</End >
101+ <RuleSet >
102+ <!-- span for escape sequences -->
103+ <Span begin =' ""' end =" " />
104+ </RuleSet >
105+ </Span >
106+
107+ <Span color =" String" >
108+ <Begin >\$"</Begin >
109+ <End >"</End >
110+ <RuleSet >
111+ <!-- span for escape sequences -->
112+ <Span begin =" \\" end =" ." />
113+ <Span begin =" \{\{" end =" " />
114+ <!-- string interpolation -->
115+ <Span begin =" {" end =" }" color =" StringInterpolation" ruleSet =" " />
116+ </RuleSet >
117+ </Span >
118+
119+ <!-- don't highlight "@int" as keyword -->
120+ <Rule >
121+ @[\w\d_]+
122+ </Rule >
123+
124+ <Keywords color =" TypeKeywords" >
125+ <Word >as</Word >
126+ <Word >is</Word >
127+ <Word >new</Word >
128+ <Word >sizeof</Word >
129+ <Word >typeof</Word >
130+ <Word >stackalloc</Word >
131+ </Keywords >
132+
133+ <Keywords color =" TrueFalse" >
134+ <Word >true</Word >
135+ <Word >false</Word >
136+ </Keywords >
137+
138+ <Keywords color =" Keywords" >
139+ <Word >else</Word >
140+ <Word >if</Word >
141+ <Word >switch</Word >
142+ <Word >case</Word >
143+ <Word >default</Word >
144+ <Word >do</Word >
145+ <Word >for</Word >
146+ <Word >foreach</Word >
147+ <Word >in</Word >
148+ <Word >while</Word >
149+ <Word >lock</Word >
150+ </Keywords >
151+
152+ <Keywords color =" GotoKeywords" >
153+ <Word >break</Word >
154+ <Word >continue</Word >
155+ <Word >goto</Word >
156+ <Word >return</Word >
157+ </Keywords >
158+
159+ <Keywords color =" ContextKeywords" >
160+ <Word >yield</Word >
161+ <Word >partial</Word >
162+ <Word >global</Word >
163+ <Word >where</Word >
164+ <Word >select</Word >
165+ <Word >group</Word >
166+ <Word >by</Word >
167+ <Word >into</Word >
168+ <Word >from</Word >
169+ <Word >ascending</Word >
170+ <Word >descending</Word >
171+ <Word >orderby</Word >
172+ <Word >let</Word >
173+ <Word >join</Word >
174+ <Word >on</Word >
175+ <Word >equals</Word >
176+ <Word >var</Word >
177+ <Word >dynamic</Word >
178+ <Word >await</Word >
179+ </Keywords >
180+
181+ <Keywords color =" ExceptionKeywords" >
182+ <Word >try</Word >
183+ <Word >throw</Word >
184+ <Word >catch</Word >
185+ <Word >finally</Word >
186+ </Keywords >
187+
188+ <Keywords color =" CheckedKeyword" >
189+ <Word >checked</Word >
190+ <Word >unchecked</Word >
191+ </Keywords >
192+
193+ <Keywords color =" UnsafeKeywords" >
194+ <Word >fixed</Word >
195+ <Word >unsafe</Word >
196+ </Keywords >
197+
198+ <Keywords color =" ValueTypeKeywords" >
199+ <Word >bool</Word >
200+ <Word >byte</Word >
201+ <Word >char</Word >
202+ <Word >decimal</Word >
203+ <Word >double</Word >
204+ <Word >enum</Word >
205+ <Word >float</Word >
206+ <Word >int</Word >
207+ <Word >long</Word >
208+ <Word >sbyte</Word >
209+ <Word >short</Word >
210+ <Word >struct</Word >
211+ <Word >uint</Word >
212+ <Word >ushort</Word >
213+ <Word >ulong</Word >
214+ </Keywords >
215+
216+ <Keywords color =" ReferenceTypeKeywords" >
217+ <Word >class</Word >
218+ <Word >interface</Word >
219+ <Word >delegate</Word >
220+ <Word >object</Word >
221+ <Word >string</Word >
222+ <Word >void</Word >
223+ </Keywords >
224+
225+ <Keywords color =" OperatorKeywords" >
226+ <Word >explicit</Word >
227+ <Word >implicit</Word >
228+ <Word >operator</Word >
229+ </Keywords >
230+
231+ <Keywords color =" ParameterModifiers" >
232+ <Word >params</Word >
233+ <Word >ref</Word >
234+ <Word >out</Word >
235+ <Word >this</Word >
236+ </Keywords >
237+
238+ <Keywords color =" ThisOrBaseReference" >
239+ <Word >this</Word >
240+ <Word >base</Word >
241+ </Keywords >
242+
243+ <Keywords color =" Modifiers" >
244+ <Word >abstract</Word >
245+ <Word >const</Word >
246+ <Word >event</Word >
247+ <Word >extern</Word >
248+ <Word >override</Word >
249+ <Word >readonly</Word >
250+ <Word >sealed</Word >
251+ <Word >static</Word >
252+ <Word >virtual</Word >
253+ <Word >volatile</Word >
254+ <Word >async</Word >
255+ </Keywords >
256+
257+ <Keywords color =" Visibility" >
258+ <Word >public</Word >
259+ <Word >protected</Word >
260+ <Word >private</Word >
261+ <Word >internal</Word >
262+ <Word >file</Word >
263+ </Keywords >
264+
265+ <Keywords color =" NamespaceKeywords" >
266+ <Word >namespace</Word >
267+ <Word >using</Word >
268+ </Keywords >
269+
270+ <Keywords color =" GetSetAddRemove" >
271+ <Word >get</Word >
272+ <Word >set</Word >
273+ <Word >add</Word >
274+ <Word >remove</Word >
275+ </Keywords >
276+
277+ <Keywords color =" NullOrValueKeywords" >
278+ <Word >null</Word >
279+ <Word >value</Word >
280+ </Keywords >
281+
282+ <Keywords color =" SemanticKeywords" >
283+ <Word >nameof</Word >
284+ </Keywords >
285+
286+ <!-- Mark previous rule-->
287+ <Rule color =" MethodCall" >
288+ \b
289+ [\d\w_]+ # an identifier
290+ (?=\s*\() # followed by (
291+ </Rule >
292+
293+ <!-- Digits -->
294+ <Rule color =" NumberLiteral" >
295+ \b0[xX][0-9a-fA-F]+ # hex number
296+ |
297+ ( \b\d+(\.[0-9]+)? #number with optional floating point
298+ | \.[0-9]+ #or just starting with floating point
299+ )
300+ ([eE][+-]?[0-9]+)? # optional exponent
301+ </Rule >
302+
303+ <Rule color =" Punctuation" >
304+ [?,.;()\[\]{}+\-/%*<> ^+~!|& ]+
305+ </Rule >
306+ </RuleSet >
307+ </SyntaxDefinition >
0 commit comments