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

未关闭
#10 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
12/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp
领域
testing-qa

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.
主要语言
C#
星标
0
派生
0
平均合并
20 小时 34 分钟
30 天内合并 PR
5

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

iokode/WireShape 的其他 Issue

查看 iokode/WireShape 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。