fix(content): restore Content.Ebml build and port VInt tests to xUnit - #939
Merged
Conversation
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>
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
Assimalign.Cohesion.Content.Ebmlhas not compiled since the 10.0.0 bulk import (e24469bb) — the only commit its folder has ever received.VInt.Readcalled aReadFullyStreamextension that lives in a different assembly (Content.Media, namespaceAssimalign.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 fixtest— tests onlychore— build / tooling / CIChanges
VInt.Read: replaced the missingReadFullywith the BCLStream.ReadExactly(.NET 7+) — precisely "read N bytes or throwEndOfStreamException". Both call sites map to it exactly, includingextraBytes == 0(no-op, no throw). TheContent.Mediacopy uses the legacythis Textension 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.Write's null guard becameArgumentNullException.ThrowIfNull, and the redundantReferenceEquals(null, obj)inEqualswas dropped (obj is VIntalready handles null);objis now correctlyobject?.[Theory(DisplayName = "Cohesion Test [Content.Ebml] - …")]naming and{Method}_{Scenario}_{ExpectedBehavior}methods. Added the missingShouldlyreference and removedUsings.cs(global usings are forbidden;Content.Textuses explicit ones).VInt.Read— previously untested, and the one path this fix changes. Includes aChunkedReadStreamfixture that yields one byte perReadcall, which is exactly what distinguishes read-exactly from a naive read, plus truncation, empty-stream, over-width, and write/read round-trip cases.Assimalign.Cohesion.Content.Ebmlto thelibrary-content.ymlmatrix.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:
EbmlReaderandEbmlWriterare still empty stubs andEbmlDocument/EbmlBody/EbmlHeaderare empty shells, so "reader iteration" and the document lifecycle remain unaddressed.Discovered (out-of-scope) work
Not fixed here, flagged for follow-up:
Assimalign.IO.Ebml, notAssimalign.Cohesion.Content.Ebml(Content.Mediahas the same problem withAssimalign.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.Mediastill carries the duplicateReadFullyin forbidden legacythissyntax; it should move toStream.ReadExactlytoo. Related: [L01.01.05.03] Build shared content stream, buffering, and exact-read primitives #438 (shared exact-read primitives)..Bmff,.Mkv,.Mpeg,.Pdf,.Exe— assume NUnit-era tests that never compiled, so adding them to CI is not a one-line change.CS8618warnings inEbmlDocument.csare untouched.Testing & verification
dotnet buildand the affecteddotnet testprojects 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 Releasesucceeds — CI packs and pushes this project onmain.ReadExactlyto a naiveReadfails 2 tests, confirming the new coverage is not vacuous.Checklist
.claude/rules/):CohesionPackageReferencefor Shouldly; noMicrosoft.Extensions.*; no global usings; Shouldly-only assertions.ReadExactlyintroduces no reflection or dynamic codegen..slnxfiles and is now in the CI workflow.<summary>blocks are empty); not introduced or widened here.🤖 Generated with Claude Code