Add more C# language features and syntax sugar to highlightning
还没有人认领这个 Issue。
评估
调研方向
阅读链接的 github/linguist issue 5838,并将列出的 C# 功能与当前语法行为进行比较。使用提供的示例(包括 extension-method resolving)作为验收用例;当所请求的语法能够正确高亮时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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?
}
}
}
- 主要语言
- TypeScript
- 星标
- 78
- 派生
- 43
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/csharp-tmLanguage 的其他 Issue
-
C# syntax highlighting broken with collection expressions and string interpolation in method calls未关闭
难度 3/5 1-2 天 新手友好度 35/100
dotnet/csharp-tmLanguage#332 · 7 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
dotnet/csharp-tmLanguage#336 · 3 条评论 ·
-
[Textmate] `scoped ref` modifier可能已有人在做 @JoeRobich 于 1018 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
dotnet/csharp-tmLanguage#306 ·
-
[Textmate] Local function with attribute可能已有人在做 @JoeRobich 于 1018 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
dotnet/csharp-tmLanguage#304 ·
-
[Textmate] Lambda with attribute可能已有人在做 @JoeRobich 于 1018 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 38/100
dotnet/csharp-tmLanguage#303 ·
查看 dotnet/csharp-tmLanguage 的全部 Issue
相似的 Issue
-
status: needs-triage
难度 2/5 1-3 小时 新手友好度 83/100
a2ui-project/a2ui#3158 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
hemilabs/ui-monorepo#2475 ·
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 82/100
lingdojo/kana-dojo#32279 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
code-quality refactoring
难度 2/5 1-3 小时 新手友好度 77/100
github/gh-aw-firewall#9879 ·
维护者通常 1 天内回复
-
[Bug]: Arrow-key cursor movement in combined diff view doesn't scroll to keep the cursor visible未关闭os:macos
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复