Nothing checks that what a declaration says a value looks like is what it is written as

Abierto
#10 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

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

Línea de trabajo

The rule belongs in the WireShape.Testing project, alongside the existing WireShape.OpenApi.Testing rule that reads Format. Start by reading how ISerializer.WriteAsText and ReadFromText are defined, since the issue depends on #9 and #11 for them. The work is design-heavy across Kind, Format, Pattern and closed lists, so it is not a first contribution; done means every declared value is checked or reported as uncheckable.

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

Descripción

Description

A declaration says what a value looks like once written — its Kind, its Format, for a text its Pattern, and for an enumeration the closed list of what each of its values travels as — and a document writes each of them into the schema of the value. None of it is checked against what is written. The only rule that reads Format (WireShape.OpenApi.Testing) compares the declaration with the document, never with the writer, so a declaration and the wire can say two different things and every test passes. #9 is what that looked like: three carriers of time shipped with a Format that the text they are written as does not have.

A document saying one thing while the wire writes another must not happen, and nothing guarantees it today.

Proposal

A rule in WireShape.Testing that writes values of every form a wire declares with the writer of that wire, through ISerializer.WriteAsText (#9), and reports every value whose written form contradicts what is declared about it. It is complete: every declared value is checked, and one that cannot be checked is reported, never skipped.

What is checked of each value
  • Kind: a Text is written as a text, an Integer as a number with no fractional part, a Decimal as a number, a Boolean as a truth. This needs the writer to say what it wrote, and not only its text, which is what #11 adds to writing a value: a value written whole with its ValueKind, or one written with members or as a list.
  • Format: the text satisfies the format as the OpenAPI format registry defines it.
  • Pattern: the text matches it.
  • A closed list (#11): each value of the enumeration is written as the word or the number the list gives it, and nothing the list does not hold is written for any of them.
Where the values come from
Form Values written
A carrier of Carrier.Known Values the rule makes itself, covering what changes the text: each DateTimeKind of a DateTime, an offset of zero and one that is not, a time of day and a moment with and without a fraction, a negative span, the bounds of each number, -0
A type declared to travel as one of those carriers The same values of its carrier, read into the declared type with ReadFromCarrier and written as the declared type, so that the converter of the application is what is checked
An enumeration declared or worked out as AsText or AsInteger with a closed list Every value of the enumeration, which the type itself lists, so no example is needed
A text declared with Shape.AsText, or a carrier of one's own Examples the declaration itself carries, read with the converter of the wire and written back. Nothing else can make one: a text in a format can only be written by someone who already knows the format, and writing it back unread would prove nothing

So Shape.AsText and Carrier can carry examples. A declaration with a Format or a Pattern and no examples is reported as one that cannot be checked.

What it knows how to check

Every format a carrier of Carrier.Known declares, after #9: uuid, int32, int64, float, double, decimal, date, date-time, time-local. A Format it has no check for is reported as one that cannot be checked, so that a word nobody verifies — email, or date-tme — does not pass in silence. Adding a format means adding its check.

Expected Behavior

  • Over the wire of the documentation, with every declaration as it is meant to be, it reports nothing.
  • A carrier declared time and written without an offset is reported, naming the type, the format and the text written.
  • A value declared as an Integer and written as a string is reported.
  • A text declared with a Pattern whose example is written in a form the pattern does not match is reported.
  • A value of an enumeration written as a word or a number other than the one its closed list gives it is reported, naming the member, what the list says and what was written.
  • A declaration with a Format or a Pattern and no examples is reported as one that cannot be checked.
  • A Format the rule has no check for is reported as one that cannot be checked.
  • A converter of the application that changes how a carrier is written — a TimeOnly with an offset — is checked as what it writes, not as what the carrier says.

Depends on

  • #9, for ISerializer.WriteAsText and ReadFromText, and for the formats of time that the rule would otherwise report.
  • #11, for what writing a value says it wrote, and for the closed lists of AsText and AsInteger.
Lenguaje dominante
C#
Estrellas
0
Forks
0
Merge medio
20 h 34 min
PR fusionados (30 d)
5

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

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 iokode/WireShape

Todos los issues de iokode/WireShape

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.