Use C# 15 collection expression arguments for collections built with a comparer or capacity

オープン
#5,915 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp

調査の方向性

Start with Directory.Build.props to find the pinned LangVersion, then inspect the listed collection constructions, especially the 12 in Protocol/Envelopes/EnvelopeItem.cs. Raise the language version to 15 and replace eligible comparer or capacity constructor calls with collection expressions using with(...). Review the other named files and build the project for its target frameworks to confirm the cleanup compiles without behavior changes.

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

説明

Improvement State: Needs Discussion

C# 15 lets a collection expression pass constructor arguments with a with(...) element:

Dictionary<string, object?> data = [with(StringComparer.Ordinal), .. source];
HashSet<string> keys = [with(capacity: count)];

About 22 places in src/ (as of version7) build a Dictionary, HashSet or ConcurrentDictionary with a comparer or capacity argument, and could use this form. 12 of them are in Protocol/Envelopes/EnvelopeItem.cs. Others are in Envelope.cs, CocoaExtensions.cs, DynamicSamplingContext.cs, JsonExtensions.cs, SentrySpanProcessor.cs, SentryTracingMiddleware.cs, HttpContextExtensions.cs and AssemblyStoreExplorer.cs.

This is a readability cleanup only, with no behaviour change. The feature needs no runtime support, so it compiles for every TFM, including netstandard2.0 and net462.

Prerequisite

version7 builds with the .NET 11 SDK but pins <LangVersion>14.0</LangVersion> in Directory.Build.props. Raise it to 15 first, either as part of this change or separately.

See What's new in C# 15.

主要言語
C#
スター
775
フォーク
262
平均マージ
1日 16時間
マージ済み PR(30日)
118

環境構築

はじめの一歩

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

getsentry/sentry-dotnet のほかの issue

getsentry/sentry-dotnet の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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