[API Proposal]: Save comma flag in `JsonReaderState`.

Abierto
#137,957 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp
Área
backend

Línea de trabajo

Start by reading the JsonReaderState and Utf8JsonReader code that tracks commas, including the existing _trailingCommaBeforeComment flag. The issue proposes preserving comma state so streamed reads can advance to the next token; check the reader’s state and streaming tests to understand current behavior. Done means partial-token reads can resume at the token start after consuming the comma, with existing reader behavior covered.

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

Descripción

api-suggestion area-System.Text.Json untriaged
Background and motivation

When large json is iterated in streamed way and doesn't fit the buffer, it is preferred to leave the buffer at the start of the next token since token is what we are gonna read. Commas are for syntax only, they are not meant to be consumed, reader doesn't even return them.
However, at the moment reader stops consuming right before the comma when next token is partial.
Assume that we are reading [ "token 1" , "token 2" ]. Minimum reading steps are: [, , "token 1", , , "token 2", , ].
First two whitespaces are independent since they are handled by SkipWhiteSpace(). However, since encountered comma is not saved in a JsonReaderState, reader can't advance past comma between two tokens, thus both comma and all whitespaces after it have to be present along with token 2, otherwise token 2 will throw as unexpected(because reader expects a comma).

API Proposal

Add a flag to JsonReaderState to note that comma is encountered. Thus reader will be able to consume past comma and stop right at the beginning of the token.
The flag probably can replace previous _trailingCommaBeforeComment as well.

API Usage
Alternative Designs

No response

Risks

No response

Lenguaje dominante
C#
Estrellas
18.5k
Forks
5.8k
Merge medio
2 d 18 h
PR fusionados (30 d)
588

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

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 dotnet/runtime

Todos los issues de dotnet/runtime

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.