From c7a10134a6df1fc26c2419a4c958a3f17e14890d Mon Sep 17 00:00:00 2001 From: Keith Hall Date: Wed, 4 Dec 2024 21:44:04 +0200 Subject: [PATCH] [C#] support lambdas in base class primary constructor calls --- C#/C#.sublime-syntax | 15 ++++++++++++++- C#/tests/syntax_test_C#8.cs | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/C#/C#.sublime-syntax b/C#/C#.sublime-syntax index d16f813b25..c63d597085 100644 --- a/C#/C#.sublime-syntax +++ b/C#/C#.sublime-syntax @@ -442,11 +442,19 @@ contexts: - match: (?=\S) push: [method_param, method_param_type] - delegate_end: + terminator: - match: \s*(;) captures: 1: punctuation.terminator.statement.cs pop: true + + maybe_terminator: + - include: terminator + - match: (?=\S) + pop: true + + delegate_end: + - include: terminator - match: \s*(?=\S) scope: invalid.illegal.expected.colon pop: true @@ -546,6 +554,9 @@ contexts: - include: type_constraint_common - match: '{{name}}' scope: entity.other.inherited-class.cs + push: + - maybe_terminator + - maybe_constructor_parameters - include: type type_constraint_common: @@ -787,6 +798,8 @@ contexts: method_param_type: - include: attribute + - include: lambdas + - match: (?=[^\s\[]) set: - match: '\s*\b(out|ref|this|params|in)\s+' diff --git a/C#/tests/syntax_test_C#8.cs b/C#/tests/syntax_test_C#8.cs index 3655e6301e..9b6dc84daf 100644 --- a/C#/tests/syntax_test_C#8.cs +++ b/C#/tests/syntax_test_C#8.cs @@ -314,3 +314,27 @@ public static string RockPaperScissors(string first, string second) /// ^ punctuation.section.group.end /// ^ punctuation.terminator.statement } + +using AutoFixture; +using AutoFixture.Xunit2; + +namespace CommonTests.Attributes; + +[AttributeUsage(AttributeTargets.Method)] +public class CustomAutoDataAttribute() : AutoDataAttribute( + () => +///^^^^^^ meta.class.constructor.parameters.cs +/// ^^^^^ meta.function.anonymous.cs meta.group.cs +/// ^ punctuation.section.group.begin.cs +/// ^ meta.group.cs punctuation.section.group.end.cs +/// ^^ keyword.declaration.function.arrow.cs + { + var fixture = new Fixture(); + fixture.Customizations.Add(new DateOnlySpecimenBuilder()); + return fixture; + }); +///^^^ meta.class.constructor.parameters.cs +/// ^ punctuation.section.block.end.cs +/// ^ punctuation.section.parameters.end.cs +/// ^ meta.class.cs punctuation.terminator.statement.cs +