Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add more C# language features and syntax sugar to highlightning

Đang mở
#239 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
tooling

Hướng nghiên cứu

Đọc issue 5838 được liên kết của github/linguist và so sánh các tính năng C# được liệt kê với hành vi hiện tại của grammar. Sử dụng các ví dụ được cung cấp, bao gồm extension-method resolving, làm các trường hợp chấp nhận; hoàn thành nghĩa là cú pháp được yêu cầu được tô sáng chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

See https://github.com/github/linguist/issues/5838

Describe the enhancement

Currently not all syntax features of C# are highlighted.
My suggestion includes the following (if you would find something missing, feel free to add):

Missing features

For the sake of completeness, I have tried to explicitly assign a feature to a language version here. I could not find the associated standard/proposal for each feature but they do exist.

Standard (Draft v6)

C# language standard - ECMA-TC49-TG2

Unsafe blocks (ECMA Draftv6 22.2)

public void Method() {
    unsafe {
        // Unsafe operations
    }
}

Pointers & pointer fixture (ECMA Draftv6 22.7)

public unsafe void Method() {
    fixed(int* ptr = &refVar) {
        // Some cool pointer operations
    }
}
C# 9

Native Integer Primitives (CSharp 9.0 Proposal)

public void Method() {
    nint myNativeInteger = -123;
    nuint myNativeUnsignedInteger = 123;
}
public void Method(nint param1, nuint param2) {}

Function pointers (CSharp 9.0 Proposal)

public void Method() {
    delegate* managed<int, int>;
    delegate* unmanaged<int, int>;
    delegate* unmanaged[Cdecl] <int, int>;
    delegate* unmanaged[Stdcall, SuppressGCTransition] <int, int>;
}

Static anonymous functions (CSharp 9.0 Proposal)

public void X() {
    Y(static (i) => i + 1);
    Y(static i => i + 1);
}

public void Y(Func<int, int> x) {}

With expressions (CSharp 9.0 Proposal)

public record MyRecord(string Name);
public MyRecord ModifyName(MyRecord rec) {
    return rec with { Name = "My new name" };
}
C# 10

Global Using Directives (CSharp 10.0 Proposal)

global using System;
global using System.Linq;
global using System.Runtime.CompilerServices;

Records (CSharp 10.0 Proposal)

public partial record struct Record {}
public partial sealed record Record {}
public record struct Record {}
public sealed record Record {}

Enhanced Pattern Matching (CSharp 9.0 Proposal + CSharp 10.0 Proposal)

void M(object o1, object o2)
{
    var t = (o1, o2);
    if (t is (int, string)) {} 
    switch (o1) {
        case int: break; 
        case string: break; 
    }
}

bool IsLetter(char c) => c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z');

Null checks

public void Method(object? nullable) {
    if(nullable is null) {}
    if(nullable is not null) {}
}

Defaults

public void X() {
    int x = default;
}

implicit new

public void Method() {
    MyKnownType value = new();
}

Wrong implemented features

Extension method resolving

namespace N1
{
    public static class D
    {
        public static void F(this int i) => Console.WriteLine($"D.F({i})");
    }
}

namespace N2
{
    using N1;

    class Test
    {
        static void Main(string[] args)
        {
            1.F();
            // ^^ Why is this red?
        }
    }
}
Ngôn ngữ chính
TypeScript
Star
78
Fork
43
Merge trung bình
34 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/csharp-tmLanguage

Tất cả issue của dotnet/csharp-tmLanguage

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.