Skip to content

fix(content): restore Content.Ebml build and port VInt tests to xUnit - #939

Merged
dotnetcadet merged 1 commit into
mainfrom
claude/amazing-greider-f1bebf
Jul 20, 2026
Merged

fix(content): restore Content.Ebml build and port VInt tests to xUnit#939
dotnetcadet merged 1 commit into
mainfrom
claude/amazing-greider-f1bebf

Conversation

@dotnetcadet

Copy link
Copy Markdown
Contributor

Summary

Assimalign.Cohesion.Content.Ebml has not compiled since the 10.0.0 bulk import (e24469bb) — the only commit its folder has ever received. VInt.Read called a ReadFully Stream extension that lives in a different assembly (Content.Media, namespace Assimalign.IO), producing CS1061, and .editorconfig:89 (csharp_prefer_braces = true:error) turned 12 brace omissions in the same file into build errors.

Fixing the build exposed a second, larger problem: the test suite was written for NUnit ([TestCase], Assert.AreEqual, ExpectedResult=) inside a project that references xunit only, so it had never compiled either. The CS1061 was not what kept those tests from running.

Type of change

  • fix — bug fix
  • test — tests only
  • chore — build / tooling / CI

Changes

  • VInt.Read: replaced the missing ReadFully with the BCL Stream.ReadExactly (.NET 7+) — precisely "read N bytes or throw EndOfStreamException". Both call sites map to it exactly, including extraBytes == 0 (no-op, no throw). The Content.Media copy uses the legacy this T extension syntax the repo forbids, so it was deliberately not reused; the BCL API also removes the cross-assembly helper dependency that issue [L01.01.05.08.01] Repair EBML VInt, reader, writer, and document lifecycle behavior #459 calls out.
  • IDE0011: added braces at all 12 sites. Write's null guard became ArgumentNullException.ThrowIfNull, and the redundant ReferenceEquals(null, obj) in Equals was dropped (obj is VInt already handles null); obj is now correctly object?.
  • Tests ported to xUnit + Shouldly, all 40 original cases preserved, with repo-standard [Theory(DisplayName = "Cohesion Test [Content.Ebml] - …")] naming and {Method}_{Scenario}_{ExpectedBehavior} methods. Added the missing Shouldly reference and removed Usings.cs (global usings are forbidden; Content.Text uses explicit ones).
  • New coverage for VInt.Read — previously untested, and the one path this fix changes. Includes a ChunkedReadStream fixture that yields one byte per Read call, which is exactly what distinguishes read-exactly from a naive read, plus truncation, empty-stream, over-width, and write/read round-trip cases.
  • CI: added Assimalign.Cohesion.Content.Ebml to the library-content.yml matrix.

Work items resolved

Advances #459 — the "consistent exact-read strategy / fails deterministically on truncated input / no reliance on unrelated namespaces" half of its acceptance criteria, plus the VInt encode-decode, truncated-input, and writer-round-trip test coverage.

Not closing it: EbmlReader and EbmlWriter are still empty stubs and EbmlDocument/EbmlBody/EbmlHeader are empty shells, so "reader iteration" and the document lifecycle remain unaddressed.

Discovered (out-of-scope) work

Not fixed here, flagged for follow-up:

  • Namespaces do not match assembly names. All 13 files use Assimalign.IO.Ebml, not Assimalign.Cohesion.Content.Ebml (Content.Media has the same problem with Assimalign.IO). Left as-is — renaming is a public-API break that deserves its own decision. Nothing outside each package consumes these namespaces, so the blast radius is small.
  • Content.Media still carries the duplicate ReadFully in forbidden legacy this syntax; it should move to Stream.ReadExactly too. Related: [L01.01.05.03] Build shared content stream, buffering, and exact-read primitives #438 (shared exact-read primitives).
  • The same bulk-import debt likely affects .Bmff, .Mkv, .Mpeg, .Pdf, .Exe — assume NUnit-era tests that never compiled, so adding them to CI is not a one-line change.
  • Pre-existing CS8618 warnings in EbmlDocument.cs are untouched.

Testing & verification

  • dotnet build and the affected dotnet test projects pass locally.
  • dotnet test libraries/Content/Assimalign.Cohesion.Content.Ebml/tests/60/60 passing, in both Debug and Release (CI builds Release).
  • dotnet pack --configuration Release succeeds — CI packs and pushes this project on main.
  • The partial-read test was mutation-checked: reverting ReadExactly to a naive Read fails 2 tests, confirming the new coverage is not vacuous.
  • ⚠️ Verified on Windows only. The code is pure arithmetic over in-memory buffers — no paths, encodings, or line endings — so cross-platform risk is low, but the ubuntu/macos legs are unconfirmed until this workflow runs.

Checklist

  • Deferred/backlog items are linked without a closing keyword.
  • Follows the repo coding rules (.claude/rules/): CohesionPackageReference for Shouldly; no Microsoft.Extensions.*; no global usings; Shouldly-only assertions.
  • Remains NativeAOT- and trimming-safe — ReadExactly introduces no reflection or dynamic codegen.
  • Tests added/updated and passing; the project was already wired into all three .slnx files and is now in the CI workflow.
  • No dangling solution/project references left behind.
  • Public APIs have XML docs — pre-existing gap in this package (several <summary> blocks are empty); not introduced or widened here.

🤖 Generated with Claude Code

Content.Ebml has not compiled since the 10.0.0 bulk import (e24469b).
VInt.Read called a ReadFully Stream extension that lives in a different
assembly (Content.Media, namespace Assimalign.IO), so the call failed
with CS1061; .editorconfig's csharp_prefer_braces=true:error turned 12
brace omissions in the same file into build errors.

Replace ReadFully with the BCL Stream.ReadExactly (.NET 7+), which is
exactly "read N bytes or throw EndOfStreamException" and needs no
cross-assembly helper. Both call sites map to it exactly, including the
extraBytes == 0 case. The Content.Media copy uses the legacy `this T`
extension syntax the repo forbids, so it was not reused.

The test suite was written for NUnit ([TestCase], Assert.AreEqual,
ExpectedResult=) inside a project referencing xunit only, so it had
never compiled -- the CS1061 was not what kept it from running. Port all
40 cases to xUnit + Shouldly with repo-standard naming, drop the
forbidden global-usings file, and add coverage for VInt.Read itself,
which was previously untested and is the one path this fix changes.

Add Content.Ebml to the library-content CI matrix. There was no
exclusion comment to remove -- the project had simply never been listed.

Advances #459 (the VInt exact-read half of its acceptance criteria).
EbmlReader and EbmlWriter are still empty stubs, so reader iteration and
document lifecycle remain open; not closing that item.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dotnetcadet
dotnetcadet merged commit 8112a2c into main Jul 20, 2026
9 checks passed
@dotnetcadet
dotnetcadet deleted the claude/amazing-greider-f1bebf branch July 20, 2026 18:56
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