Skip to content

C#: compile-time gate for scalar AsSpan() (pin welder-csharp unmanaged-constraint) - #7

Merged
skarndev merged 3 commits into
mainfrom
feature/csharp-asspan-constraint
Aug 23, 2026
Merged

skarndev merged 3 commits into
mainfrom
feature/csharp-asspan-constraint

Conversation

@skarndev

Copy link
Copy Markdown
Owner

Pins skarndev/welder-csharp#7: the non-generic AsSpan() becomes a where T : unmanaged extension, so calling it on a record- or nested-container-element vector (e.g. chunk.AlphaMaps.AsSpan()) is a compile error instead of a runtime throw. Scalar call sites are unchanged.

Adds a test (scalar span works through the extension; no non-generic instance AsSpan remains) and a guide note with the AlphaMaps[i].AsSpan() idiom.

Binary-breaking on the managed side (instance → extension); flag it in the next release notes.

Merge after the welder-csharp PR; the pin already points at its head.

🤖 Generated with Claude Code

skarndev and others added 3 commits August 23, 2026 20:09
…is now a compile error

welder-csharp da87061 moves the non-generic Vector<T>/FixedArray<T>
AsSpan() from an instance method to a `where T : unmanaged` extension:
call sites are unchanged for scalar/enum elements, but the record- and
nested-element calls that used to throw at runtime (the AlphaMaps
report) no longer compile and never appear in IntelliSense.
AsSpan<TData>() keeps its runtime size gate; AsDataSpan() stays the
safe bulk spelling.

Binary-breaking on the managed side (instance -> extension), so the
next release wants a version bump note.

Test: a scalar vector still spans zero-copy through the extension, and
reflection confirms no non-generic instance AsSpan remains to bind
misuse to. Guide: the maps page now states the compile-time gate and
the AlphaMaps indexing idiom. dotnet test 36/36.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@skarndev
skarndev merged commit e6bd2a5 into main Aug 23, 2026
8 checks passed
@skarndev
skarndev deleted the feature/csharp-asspan-constraint branch August 23, 2026 18:26
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