diff --git a/CHANGES.md b/CHANGES.md
index a5542c2ccb..70b0bcd9f4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -14,6 +14,7 @@ Core Changes:
Language Improvements:
+- enh(csharp) Add generic modifiers (in, out) (#2378) [Josh Goebel][]
- (fortran) Add Fortran 2018 keywords and coarray intrinsics (#2361) [Sam Miller][]
- (delphi) highlight hexadecimal, octal, and binary numbers (#2370) [Robert Riebisch]()
- enh(plaintext) added `text` and `txt` as alias (#2360) [Taufik Nurrohman][]
@@ -22,6 +23,7 @@ Developer Tools:
- none.
+[Josh Goebel]: https://github.com/yyyc514
[Sam Miller]: https://github.com/smillerc
[Robert Riebisch]: https://github.com/bttrx
[Taufik Nurrohman]: https://github.com/taufik-nurrohman
diff --git a/src/languages/csharp.js b/src/languages/csharp.js
index 5891bfa670..69c7cbfb4e 100644
--- a/src/languages/csharp.js
+++ b/src/languages/csharp.js
@@ -18,7 +18,9 @@ function(hljs) {
'uint ulong unchecked unsafe ushort using virtual void volatile while ' +
// Contextual keywords.
'add alias ascending async await by descending dynamic equals from get global group into join ' +
- 'let nameof on orderby partial remove select set value var when where yield',
+ 'let nameof on orderby partial remove select set value var when where yield ' +
+ // generic modifiers
+ 'in out',
literal:
'null false true'
};
@@ -86,6 +88,11 @@ function(hljs) {
]
};
+ GENERIC_var MODIFIER = {
+ begin: "<",
+ end: ">",
+ keywords: "in out"
+ };
var TYPE_IDENT_RE = hljs.IDENT_RE + '(<' + hljs.IDENT_RE + '(\\s*,\\s*' + hljs.IDENT_RE + ')*>)?(\\[\\])?';
return {
@@ -131,6 +138,7 @@ function(hljs) {
beginKeywords: 'class interface', end: /[{;=]/,
illegal: /[^\s:,]/,
contains: [
+ GENERIC_MODIFIER,
hljs.TITLE_MODE,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
diff --git a/test/markup/csharp/generic_modifiers.expect.txt b/test/markup/csharp/generic_modifiers.expect.txt
new file mode 100644
index 0000000000..bf6d8c3fba
--- /dev/null
+++ b/test/markup/csharp/generic_modifiers.expect.txt
@@ -0,0 +1,7 @@
+interface IObserver<in T>;
+{}
+
+interface IObservable<out T>;
+{}
+
+public delegate void DContravariant<in A>(A argument);
diff --git a/test/markup/csharp/generic_modifiers.txt b/test/markup/csharp/generic_modifiers.txt
new file mode 100644
index 0000000000..0af70e5c53
--- /dev/null
+++ b/test/markup/csharp/generic_modifiers.txt
@@ -0,0 +1,7 @@
+interface IObserver;
+{}
+
+interface IObservable;
+{}
+
+public delegate void DContravariant(A argument);