Skip to content

Commit 6f75735

Browse files
committed
Support for generic methods in csharp
1 parent 964450e commit 6f75735

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

components/prism-csharp.js

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ Prism.languages.csharp = Prism.languages.extend('clike', {
88
});
99

1010
Prism.languages.insertBefore('csharp', 'keyword', {
11+
'generic-method': {
12+
pattern: /[a-z0-9_]+\s*<[^>\r\n]+?>\s*(?=\()/i,
13+
alias: 'function',
14+
inside: {
15+
keyword: Prism.languages.csharp.keyword,
16+
punctuation: /[<>(),.:]/
17+
}
18+
},
1119
'preprocessor': {
1220
pattern: /(^\s*)#.*/m,
1321
lookbehind: true,

components/prism-csharp.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
void method<T, U>();
2+
method<int, char>();
3+
4+
----------------------------------------------------
5+
6+
[
7+
["keyword", "void"],
8+
["generic-method", [ "method",
9+
["punctuation", "<"],
10+
"T",
11+
["punctuation", ","],
12+
" U",
13+
["punctuation", ">"]
14+
]],
15+
["punctuation", "("],
16+
["punctuation", ")"],
17+
["punctuation", ";"],
18+
["generic-method", [ "method",
19+
["punctuation", "<"],
20+
["keyword", "int"],
21+
["punctuation", ","],
22+
["keyword", "char"],
23+
["punctuation", ">"]
24+
]],
25+
["punctuation", "("],
26+
["punctuation", ")"],
27+
["punctuation", ";"]
28+
]
29+
30+
----------------------------------------------------
31+
32+
Checks for generic methods

0 commit comments

Comments
 (0)