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

Aperta
#5,915 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
775
Fork
262
Merge medio
1g 16h
PR unite (30g)
118

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-dotnet

Tutte le issue di getsentry/sentry-dotnet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.