Skip to content

Commit fb0b19c

Browse files
authored
enh(csharp) add keywords record and init (C# 9.0) (highlightjs#2660)
1 parent 639da2c commit fb0b19c

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ Big picture:
1010

1111
Language Improvements:
1212

13+
- enh(csharp) Add `init` and `record` keywords for C# 9.0 (#2660) [Youssef Victor][]
1314
- enh(matlab) Add new R2019b `arguments` keyword and fix `enumeration` keyword (#2619) [Andrew Janke][]
1415
- fix(kotlin) Remove very old keywords and update example code (#2623) [kageru][]
1516
- fix(night) Prevent object prototypes method values from being returned in `getLanguage` (#2636) [night][]
1617
- enh(java) Add support for `enum`, which will identify as a `class` now (#2643) [ezksd][]
1718
- enh(nsis) Add support for NSIS 3.06 commands (#2653) [idleberg][]
1819

20+
[Youssef Victor]: https://github.com/Youssef1313
1921
[Josh Goebel]: https://github.com/yyyc514
2022
[Andrew Janke]: https://github.com/apjanke
2123
[Samia Ali]: https://github.com/samiaab1990

src/languages/csharp.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function(hljs) {
1313
// Normal keywords.
1414
'abstract as base bool break byte case catch char checked const continue decimal ' +
1515
'default delegate do double enum event explicit extern finally fixed float ' +
16-
'for foreach goto if implicit in int interface internal is lock long ' +
16+
'for foreach goto if implicit in init int interface internal is lock long ' +
1717
'object operator out override params private protected public readonly ref sbyte ' +
1818
'sealed short sizeof stackalloc static string struct switch this try typeof ' +
1919
'uint ulong unchecked unsafe ushort using virtual void volatile while ' +
@@ -164,6 +164,16 @@ export default function(hljs) {
164164
hljs.C_BLOCK_COMMENT_MODE
165165
]
166166
},
167+
{
168+
beginKeywords: 'record', end: /[{;=]/,
169+
illegal: /[^\s:]/,
170+
contains: [
171+
TITLE_MODE,
172+
GENERIC_MODIFIER,
173+
hljs.C_LINE_COMMENT_MODE,
174+
hljs.C_BLOCK_COMMENT_MODE
175+
]
176+
},
167177
{
168178
// [Attributes("")]
169179
className: 'meta',

test/markup/csharp/records.expect.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span class="hljs-keyword">public</span> <span class="hljs-keyword">record</span> <span class="hljs-title">MyRecord</span>
2+
{
3+
<span class="hljs-keyword">public</span> <span class="hljs-keyword">string</span> SomeMember { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
4+
}

test/markup/csharp/records.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public record MyRecord
2+
{
3+
public string SomeMember { get; set; }
4+
}

0 commit comments

Comments
 (0)