Skip to content

chore: declare record-synthesized public API to clear RS0016#1176

Merged
phmatray merged 1 commit into
mainfrom
chore/rs0016-record-public-api
Jul 7, 2026
Merged

chore: declare record-synthesized public API to clear RS0016#1176
phmatray merged 1 commit into
mainfrom
chore/rs0016-record-public-api

Conversation

@phmatray

@phmatray phmatray commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

Declares the compiler-generated members of the public record types in each project's PublicAPI.Unshipped.txt, clearing ~1200 RS0016 warnings.

Why

The Microsoft.CodeAnalysis.PublicApiAnalyzers 3.3.4 → v5 bump (#1014) started reporting the members the C# compiler auto-generates for a public recordDeconstruct, Equals, GetHashCode, ToString, operator ==/!=, <Clone>$, copy-constructors, EqualityContract — which 3.3.4 had suppressed. That surfaced RS0016 across three projects:

Project Members
Koine.Compiler 1153
Koine.Emit.Docs 40
Koine.Emit.Common 7

They were warnings only (TreatWarningsAsErrors is intentionally off), but RS0016 is a deliberate gate — the root .editorconfig silences it only for the ANTLR-generated lexer/parser files, and Koine.Compiler.csproj documents it as "unintended public API cannot ship silently."

Approach

Declared the members — the analyzer's own code-fix behavior — rather than blanket-suppressing RS0016 (which would also stop catching genuinely-forgotten hand-written public members; there is no config to exclude record members selectively). Each symbol was attributed to its declaring project by the […csproj] diagnostic suffix and appended verbatim (sorted, deduped).

Verification: all 1200 entries confirmed record-synthesized boilerplate — no hand-written API among them. dotnet build Koine.slnx0 warnings, 0 errors. Diff is purely additive to the three contract files; no source touched.

Note

Because v5 now tracks these, a future change to a record's parameter list will re-trip RS0016 for its regenerated members, so those Unshipped.txt entries will need updating alongside.

The PublicApiAnalyzers 3.3.4 -> v5 bump (#1014) started reporting the
compiler-generated members of public records (Deconstruct, Equals,
GetHashCode, ToString, operator ==/!=, <Clone>$, copy-ctors,
EqualityContract), which 3.3.4 suppressed. That surfaced ~1200 RS0016
warnings across Koine.Compiler (1153), Koine.Emit.Docs (40) and
Koine.Emit.Common (7).

RS0016 is a deliberate gate here (only silenced for the ANTLR generated
lexer/parser files) so unintended public API cannot ship silently.
Blanket-suppressing it would also stop catching genuinely-forgotten
hand-written public members, so instead declare the members in each
project's PublicAPI.Unshipped.txt -- the analyzer's own code-fix
behavior. All 1200 entries are verified record-synthesized boilerplate;
no hand-written API was among them. Solution build is now warning-clean.
@phmatray phmatray merged commit 654ec2d into main Jul 7, 2026
8 checks passed
@phmatray phmatray deleted the chore/rs0016-record-public-api branch July 7, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant