diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage
index 6b6a385..52460cf 100644
--- a/grammars/csharp.tmLanguage
+++ b/grammars/csharp.tmLanguage
@@ -4784,6 +4784,10 @@
include
#local-variable-declaration
+
+ include
+ #attribute-section
+
include
#local-function-declaration
diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson
index 3f09e3e..14d4ac6 100644
--- a/grammars/csharp.tmLanguage.cson
+++ b/grammars/csharp.tmLanguage.cson
@@ -2920,6 +2920,9 @@ repository:
{
include: "#local-variable-declaration"
}
+ {
+ include: "#attribute-section"
+ }
{
include: "#local-function-declaration"
}
diff --git a/src/csharp.tmLanguage.yml b/src/csharp.tmLanguage.yml
index 360b7d2..ce57e32 100644
--- a/src/csharp.tmLanguage.yml
+++ b/src/csharp.tmLanguage.yml
@@ -1732,6 +1732,7 @@ repository:
patterns:
- include: '#local-constant-declaration'
- include: '#local-variable-declaration'
+ - include: '#attribute-section'
- include: '#local-function-declaration'
- include: '#local-tuple-var-deconstruction'
diff --git a/test/local.tests.ts b/test/local.tests.ts
index 9b342c4..f7b5fd3 100644
--- a/test/local.tests.ts
+++ b/test/local.tests.ts
@@ -280,5 +280,31 @@ int Add(int x, int y)
Token.Punctuation.CloseBrace
]);
});
+
+ it("local function with attribute (issue #304)", async () => {
+ const input = Input.InMethod(`
+[Attribute]
+static void M([Attribute]object obj) {}
+`);
+ const tokens = await tokenize(input);
+
+ tokens.should.deep.equal([
+ Token.Punctuation.OpenBracket,
+ Token.Type("Attribute"),
+ Token.Punctuation.CloseBracket,
+ Token.Keyword.Modifier.Static,
+ Token.PrimitiveType.Void,
+ Token.Identifier.MethodName("M"),
+ Token.Punctuation.OpenParen,
+ Token.Punctuation.OpenBracket,
+ Token.Type("Attribute"),
+ Token.Punctuation.CloseBracket,
+ Token.PrimitiveType.Object,
+ Token.Identifier.ParameterName("obj"),
+ Token.Punctuation.CloseParen,
+ Token.Punctuation.OpenBrace,
+ Token.Punctuation.CloseBrace
+ ]);
+ });
});
});
\ No newline at end of file