Skip to content

refactor(generator)!: drop IEnumerable member support - #17

Merged
OleRoss merged 1 commit into
codex/fix-floating-enum-collectionsfrom
codex/drop-enumerable-support
Oct 4, 2026
Merged

OleRoss merged 1 commit into
codex/fix-floating-enum-collectionsfrom
codex/drop-enumerable-support

Conversation

@OleRoss

@OleRoss OleRoss commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Lazy IEnumerable<T> members do not fit the separate sizing and writing API: counting can consume a sequence before serialization, and repeating a sequence can produce different data. No consumer needs this support. Reject these members, including declarations with BinaryElementCount, and keep arrays, memory, lists, and the four counted collection interfaces.

Stacked on #16; the base is codex/fix-floating-enum-collections.

Changes

  • Report DBO009 with a materialization suggestion for IEnumerable<T> members. Ignored members remain allowed.
  • Use Count directly for ICollection<T>, IReadOnlyCollection<T>, IList<T>, and IReadOnlyList<T>; sizing never enumerates.
  • Delete the enum-enumerable helper, list writer wrappers, repeated utility selection, unused collection metadata, and runtime array/list shortcuts in interface writers. All retained interfaces share a bounded iteration path; primitive and enum elements reuse span writers. Generator source is roughly 380 lines smaller.
  • Apply the same short-collection checks to primitives, enums, and objects. A declared count of two with one element now returns false instead of reporting unwritten bytes as successfully written. Surplus elements remain ignored for declared-count members.

Testing

  • Windows, .NET 9 and .NET 10: all 211 runtime tests and 47 generator tests passed on each framework (516 executions total). Built with isolated outputs and ran the compiled xUnit test assemblies directly after the local dotnet test launcher failed.
  • Verified both endian round trips through all four retained interfaces using non-array collections, member-defined boundaries and trailing fields, sizing without enumeration, one-pass writes, zero counts, exact iteration bounds, short-collection failure, and nested child failure progress.
  • Snapshot tests verify rejection in Read, Write, and All modes, preservation of ignored enumerable members, and the simplified generated output.
  • CSharpier and git diff --check passed. Independent local review found no remaining substantive issues.

Impact

Breaking source change: replace IEnumerable<T> declarations with supported collection types and explicitly materialize lazy sequences with ToArray() or ToList(). Writes below a declared or minimum count now consistently fail. Valid retained declarations keep their binary layout. Keep collections unchanged between sizing and writing and throughout serialization.

Checklist

  • PR is scoped and not oversized
  • Documentation (and changelog) is updated if needed
  • CI Pipeline is successful
  • Self-review was done

Require counted collection members and reuse the existing span writers. Remove enum enumerable handling, list wrappers, runtime collection shortcuts, and duplicate utility selection.

BREAKING CHANGE: IEnumerable<T> members are rejected. Materialize lazy sequences explicitly; collections below declared or minimum counts now fail consistently.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T10:50:59.072806Z 9b6007c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@OleRoss
OleRoss added this pull request to stack #18 September 29, 2026 19:35
@OleRoss
OleRoss merged commit 7d93063 into main Oct 4, 2026
1 check passed
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