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

Abierto
#5,915 1 comentario 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
72/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
C#
Estrellas
775
Forks
262
Merge medio
1 d 16 h
PR fusionados (30 d)
118

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de getsentry/sentry-dotnet

Todos los issues de getsentry/sentry-dotnet

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.