Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug]: Top-level brace-scoped `using` declaration with object initializer containing `string` collection initializer with `;`, `{`, or `}` tokens in items break brace highlighting

オープン
#336 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp, typescript

調査の方向性

まず、提供された top-level C# の例を再現し、top-level using 宣言、オブジェクト初期化子、コレクション初期化子、文字列の文法規則を調べます。";"、"{"、"}"、"//" のケースで動作を確認し、その後、top-level と明示的なスコープ内の両方でブレースの対応が正しいままであることを確認します。

索引モデルが issue の本文から書いたものです。

説明

Issue Description

This seems to be an edge case that has not been noticed.
In a top-level file, a brace-scoped using declaration with an object initialized which contains a collection initializer containing strings will break brace highlighting if any of the strings contain a ;, {, }, or // (maybe others?) token.

Steps to Reproduce
  1. Open a top-level C# file.
  2. using MyClass braceScopedInstance = new() // Target-typed or not does not appear to matter.
    {
        Strings = { ";" } // <~ Brace highlighting starts breaking here.
    };
    
    class MyClass : IDisposable
    {
        public List<string> Strings { get; }
    
        public void Dispose() { }
    }
    
Expected Behavior

Brace highlighting continues to be correct.

Actual Behavior

Visual Studio Code highlights the closing braces after the ";" incorrectly. It also believes that the first opening brace does not have a closing match.

The behavior is slightly different for {, } and // tokens.

The expected behavior happens when the code is within any kind of scope:

// Something as simple as this in the top-level file is enough.
{
    using MyClass braceScopedInstance = new()
    {
        Strings = { ";" } // Brace highlighting is correct.
    };
}
Logs

extension-logs.zip

C# Trace Logs

c#-trace-logs.txt

C# LSP Trace Logs

c#-lsp-trace-logs.txt

Environment information

VSCode version: 1.85.2
C# Extension: 2.15.30
Using OmniSharp: false

Dotnet Information
.NET SDK:
 Version:   8.0.100-rc.2.23502.2
 Commit:    0abacfc2b6

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\

.NET workloads installed:
 [wasi-experimental]
   Installation Source: SDK 8.0.100-rc.2
   Manifest Version:    8.0.0-rc.2.23479.6/8.0.100-rc.2
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-rc.2\microsoft.net.workload.mono.toolchain.current\8.0.0-rc.2.23479.6\WorkloadManifest.json
   Install Type:              Msi


Host:
  Version:      8.0.0-rc.2.23479.6
  Architecture: x64
  Commit:       0b25e38ad3

.NET SDKs installed:
  8.0.100-rc.2.23502.2 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.0-rc.2.23480.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-rc.2.23479.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-rc.2.23479.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
Visual Studio Code Extensions
Extension Author Version Folder Name
csdevkit ms-dotnettools 1.3.6 ms-dotnettools.csdevkit-1.3.6-win32-x64
csharp ms-dotnettools 2.15.30 ms-dotnettools.csharp-2.15.30-win32-x64
vscode-dotnet-runtime ms-dotnettools 2.0.1 ms-dotnettools.vscode-dotnet-runtime-2.0.1
vscodeintellicode-csharp ms-dotnettools 0.1.26 ms-dotnettools.vscodeintellicode-csharp-0.1.26-win32-x64
主要言語
TypeScript
スター
78
フォーク
43
平均マージ
34分
マージ済み PR(30日)
1

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/csharp-tmLanguage のほかの issue

dotnet/csharp-tmLanguage の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。