Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] support lambdas in base class primary constructor calls #4106

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Loading