Skip to content

Commit

Permalink
[C#] support lambdas in base class primary constructor calls (#4106)
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-hall authored Dec 5, 2024
1 parent 3a86036 commit 1fb3a48
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
15 changes: 14 additions & 1 deletion C#/C#.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -787,6 +798,8 @@ contexts:

method_param_type:
- include: attribute
- include: lambdas

- match: (?=[^\s\[])
set:
- match: '\s*\b(out|ref|this|params|in)\s+'
Expand Down
24 changes: 24 additions & 0 deletions C#/tests/syntax_test_C#8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1fb3a48

Please sign in to comment.