Skip to content

Commit

Permalink
enh(csharp) add keywords record and init (C# 9.0) (#2660)
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Aug 20, 2020
1 parent 639da2c commit fb0b19c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ Big picture:

Language Improvements:

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

[Youssef Victor]: https://github.com/Youssef1313
[Josh Goebel]: https://github.com/yyyc514
[Andrew Janke]: https://github.com/apjanke
[Samia Ali]: https://github.com/samiaab1990
Expand Down
12 changes: 11 additions & 1 deletion src/languages/csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function(hljs) {
// Normal keywords.
'abstract as base bool break byte case catch char checked const continue decimal ' +
'default delegate do double enum event explicit extern finally fixed float ' +
'for foreach goto if implicit in int interface internal is lock long ' +
'for foreach goto if implicit in init int interface internal is lock long ' +
'object operator out override params private protected public readonly ref sbyte ' +
'sealed short sizeof stackalloc static string struct switch this try typeof ' +
'uint ulong unchecked unsafe ushort using virtual void volatile while ' +
Expand Down Expand Up @@ -164,6 +164,16 @@ export default function(hljs) {
hljs.C_BLOCK_COMMENT_MODE
]
},
{
beginKeywords: 'record', end: /[{;=]/,
illegal: /[^\s:]/,
contains: [
TITLE_MODE,
GENERIC_MODIFIER,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
},
{
// [Attributes("")]
className: 'meta',
Expand Down
4 changes: 4 additions & 0 deletions test/markup/csharp/records.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span class="hljs-keyword">public</span> <span class="hljs-keyword">record</span> <span class="hljs-title">MyRecord</span>
{
<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 changes: 4 additions & 0 deletions test/markup/csharp/records.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public record MyRecord
{
public string SomeMember { get; set; }
}

0 comments on commit fb0b19c

Please sign in to comment.