docs: correct five claims the code had already outgrown - #73
Merged
Conversation
EMN0005's message was false on half the shapes it reports. Both the
analyzer's wording and EnumContractException's said the shadowed member
was "only reachable through a different casing". That holds when the
declared name is spelled like the C# name it shadows, and not otherwise:
on [JsonStringEnumMemberName("blue")] beside a Blue member, Blue still
answers to Blue and it is blue it loses. The member loses the declared
spelling and keeps every other casing, which is true either way.
Measured against System.Text.Json, since this package refuses both
shapes and has no contract to ask — which is also why the claim went
unchecked: a message describing a shape nothing can build is a sentence
no test was reaching for. There is a test now. The rule pages were
already right, and are left alone: they state it of their own example,
which is the same-casing one, and describe the mirror correctly.
The binder called the undefined-value refusal "the one input where a
channel and the body disagree". The paragraph below it already
contradicted that, and so did the test suite two methods apart: the
[Flags] half is a second input and a name carrying a character a route
or a header cannot transport is a third, which is what EMN0006 reports.
The test that named itself "the one thing only the body accepts" is
renamed with it.
EMN0001 still said the first-declared alias name is used when writing.
It is the first in Enum.GetNames order — the correction that went into
the value-to-name map never reached that page, in either language.
The README said ASP.NET Core formats route values without the value's
own ToString(), then explained that the link therefore carries the C#
name, which is what ToString() returns. It formats them with it.
limitations credited the refusal to EnumTypeModelBinder and called it
"not reachable from here". This package registers its binder ahead of
the provider ASP.NET Core uses for enums, so EnumTypeModelBinder never
sees the value: the check is reproduced here, deliberately, and the
refusal a caller meets is this package's own.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M5U2BZXpHQr7YcfNHVx9dA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five statements in the repository are false. Each was verified by measurement before being rewritten, and one of them is a diagnostic message a user reads.
1.
EMN0005's message, false on half the shapes it reportsBoth the analyzer's wording and
EnumContractException's said the shadowed member was "only reachable through a different casing". Measured againstSystem.Text.Json:Blueblue[JsonStringEnumMemberName("Blue")] RedbesideBlueRedBlue[JsonStringEnumMemberName("blue")] RedbesideBlueBlueRedblueThe member loses the declared spelling and keeps every other casing, which is true either way. The oracle has to be the serializer, because this package refuses both shapes outright and there is no contract to ask — which is also why the claim went unchecked so long: a message describing a shape nothing can build is a sentence no test was reaching for.
the_shadowed_member_loses_the_declared_spelling_and_no_otheris that test now.The rule pages are left alone: they state it of their own example, which is the same-casing one, and already describe the mirror correctly. Only the generic wordings were wrong — the two messages, two remarks, and the changelog's summary of the rule.
2. "the one input where a channel and the body disagree"
The binder's remark said that; the paragraph directly below it already contradicted it, and so did the test suite two methods apart —
a_flags_combination_naming_no_member_is_refused_toosays in its own text "which is what makes this a divergence". There are at least three: the non-[Flags]combination, the[Flags]one refused by a different platform test, and a declared name carrying a character a route or a header cannot transport, which is whatEMN0006exists to report. The test that named itself..._is_the_one_thing_only_the_body_acceptsis renamed with it.3.
EMN0001on alias writingIt still said the first-declared alias name is used when writing. It is the first in
Enum.GetNamesorder, which is neither declaration order nor the arithmetic one — the correction that went into the value-to-name map never reached that page, in either language.4. The README on link generation
Self-contradictory: the C# name is what
ToString()returns. Measured —ProductStatus.OutOfStock.ToString()andConvert.ToString(…, InvariantCulture)both give"OutOfStock", and/status/link-rawin the suite produces that path. It formats them with it, which is the whole reason the workaround exists.5.
limitationson who refuses an undefined valueIt credited the refusal to
EnumTypeModelBinderand called it "not reachable from here". This package registers its binder ahead of the provider ASP.NET Core uses for enums, soEnumTypeModelBindernever sees the value: the check is reproduced here, deliberately — as the binder's own remark says — and the refusal a caller meets is this package's own. Both halves rewritten, in both languages.Type of change
Testing
dotnet build -c Release— clean, warnings are errors heredotnet test -c Release— 956 passed, 0 failedtests/PackageSmokeTest/run.sh— run because the analyzer's resources changed; "The published package behaves as documented."Also run:
tools/style/lint-layout.sh(nothing to report).Public API
Two diagnostic message strings change; no symbol does.
Documentation
docs/updatedCHANGELOG.mdanddocs/for-users/CHANGELOG.fr.mdboth updated🤖 Generated with Claude Code
https://claude.ai/code/session_01M5U2BZXpHQr7YcfNHVx9dA
Generated by Claude Code