Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(csharp) add keywords record and init (C# 9.0) #2660

Merged
merged 5 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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; }
}