Skip to content

Commit

Permalink
enh(csharp) add support for @identifier style identifiers (#2414)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Feb 23, 2020
1 parent 5dcc628 commit 48a3ba9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -16,6 +16,7 @@ Core Changes:

Language Improvements:

- (csharp) add support for `@identifier` style identifiers (#2414) [Josh Goebel][]
- fix(elixir) Support function names with a slash (#2406) [Josh Goebel][]
- fix(javascript) comma is allowed in a "value container" (#2403) [Josh Goebel][]
- enh(apache) add `deny` and `allow` keywords [Josh Goebel][]
Expand Down
9 changes: 8 additions & 1 deletion src/languages/csharp.js
Expand Up @@ -93,6 +93,12 @@ export default function(hljs) {
keywords: "in out"
};
var TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?';
var AT_IDENTIFIER = {
// prevents expressions like `@class` from incorrect flagging
// `class` as a keyword
begin: "@" + hljs.IDENT_RE,
relevance: 0
};

return {
name: 'C#',
Expand Down Expand Up @@ -195,7 +201,8 @@ export default function(hljs) {
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
]
}
},
AT_IDENTIFIER
]
};
}
3 changes: 3 additions & 0 deletions test/markup/csharp/identifiers.expect.txt
@@ -0,0 +1,3 @@
<span class="hljs-keyword">var</span> @class = <span class="hljs-keyword">new</span> MyClass();
doSomething(@var, @foo);
<span class="hljs-keyword">var</span> a;
4 changes: 4 additions & 0 deletions test/markup/csharp/identifiers.txt
@@ -0,0 +1,4 @@
var @class = new MyClass();
doSomething(@var, @foo);
var a;

0 comments on commit 48a3ba9

Please sign in to comment.