Skip to content

Commit

Permalink
Support for generic methods in csharp
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitgeist87 committed Apr 30, 2016
1 parent 964450e commit 6f75735
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
8 changes: 8 additions & 0 deletions components/prism-csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ Prism.languages.csharp = Prism.languages.extend('clike', {
});

Prism.languages.insertBefore('csharp', 'keyword', {
'generic-method': {
pattern: /[a-z0-9_]+\s*<[^>\r\n]+?>\s*(?=\()/i,
alias: 'function',
inside: {
keyword: Prism.languages.csharp.keyword,
punctuation: /[<>(),.:]/
}
},
'preprocessor': {
pattern: /(^\s*)#.*/m,
lookbehind: true,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-csharp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions tests/languages/csharp/generic_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
void method<T, U>();
method<int, char>();

----------------------------------------------------

[
["keyword", "void"],
["generic-method", [ "method",
["punctuation", "<"],
"T",
["punctuation", ","],
" U",
["punctuation", ">"]
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"],
["generic-method", [ "method",
["punctuation", "<"],
["keyword", "int"],
["punctuation", ","],
["keyword", "char"],
["punctuation", ">"]
]],
["punctuation", "("],
["punctuation", ")"],
["punctuation", ";"]
]

----------------------------------------------------

Checks for generic methods

0 comments on commit 6f75735

Please sign in to comment.