diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage
index 3906d58..aeaeb81 100644
--- a/grammars/csharp.tmLanguage
+++ b/grammars/csharp.tmLanguage
@@ -668,7 +668,7 @@
attribute-section
begin
- (\[)(assembly|module|field|event|method|param|property|return|type)?(\:)?
+ (\[)(assembly|module|field|event|method|param|property|return|typevar|type)?(\:)?
beginCaptures
1
diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson
index 0fb74a7..7fed1a0 100644
--- a/grammars/csharp.tmLanguage.cson
+++ b/grammars/csharp.tmLanguage.cson
@@ -447,7 +447,7 @@ repository:
}
]
"attribute-section":
- begin: "(\\[)(assembly|module|field|event|method|param|property|return|type)?(\\:)?"
+ begin: "(\\[)(assembly|module|field|event|method|param|property|return|typevar|type)?(\\:)?"
beginCaptures:
"1":
name: "punctuation.squarebracket.open.cs"
diff --git a/src/csharp.tmLanguage.yml b/src/csharp.tmLanguage.yml
index 4576f37..a012a52 100644
--- a/src/csharp.tmLanguage.yml
+++ b/src/csharp.tmLanguage.yml
@@ -189,7 +189,7 @@ repository:
- include: '#operator-assignment'
attribute-section:
- begin: (\[)(assembly|module|field|event|method|param|property|return|type)?(\:)?
+ begin: (\[)(assembly|module|field|event|method|param|property|return|typevar|type)?(\:)?
beginCaptures:
'1': { name: punctuation.squarebracket.open.cs }
'2': { name: keyword.other.attribute-specifier.cs }
diff --git a/test/attribute.tests.ts b/test/attribute.tests.ts
index e1f9def..cc367fb 100644
--- a/test/attribute.tests.ts
+++ b/test/attribute.tests.ts
@@ -253,5 +253,36 @@ describe("Attributes", () => {
Token.Punctuation.TypeParameter.End,
Token.Punctuation.CloseBracket]);
});
+
+ it("typevar attribute specifier", async () => {
+
+ const input = `[typevar: MyAttribute]`;
+ const tokens = await tokenize(input);
+
+ tokens.should.deep.equal([
+ Token.Punctuation.OpenBracket,
+ Token.Keyword.AttributeSpecifier("typevar"),
+ Token.Punctuation.Colon,
+ Token.Type("MyAttribute"),
+ Token.Punctuation.CloseBracket]);
+ });
+
+ it("typevar attribute specifier on generic type parameter", async () => {
+
+ const input = `class Foo<[typevar: MyAttribute] T>`;
+ const tokens = await tokenize(input);
+
+ tokens.should.deep.equal([
+ Token.Keyword.Definition.Class,
+ Token.Identifier.ClassName("Foo"),
+ Token.Punctuation.TypeParameter.Begin,
+ Token.Punctuation.OpenBracket,
+ Token.Keyword.AttributeSpecifier("typevar"),
+ Token.Punctuation.Colon,
+ Token.Type("MyAttribute"),
+ Token.Punctuation.CloseBracket,
+ Token.Identifier.TypeParameterName("T"),
+ Token.Punctuation.TypeParameter.End]);
+ });
});
});