Skip to content

Fix native signatures for ydoc_clear, XML navigation and bool returns - #136

Merged
SebastianStehle merged 1 commit into
y-crdt:mainfrom
jcannon98188:fix/native-signature-mismatches
Oct 12, 2026
Merged

SebastianStehle merged 1 commit into
y-crdt:mainfrom
jcannon98188:fix/native-signature-mismatches

Conversation

@jcannon98188

Copy link
Copy Markdown
Contributor

Summary

Fixes #133

Corrects five P/Invoke declarations that did not match the yffi C API.

Changes

  • ydoc_clear now receives its parent write transaction. For a document with a parent we open a write transaction on the parent. A root document has no parent, so a transaction on a throwaway Doc is used. yffi 0.19 and 0.26 panic on null.
  • yxmlelem_parent and yxmlelem_first_child no longer pass an extra transaction argument.
  • ydoc_should_load and ydoc_auto_load return a single byte: [return: MarshalAs(UnmanagedType.U1)].

Tests

Added to Document/ClearTests:

  • ClearsManyDocumentsWithContent
  • ClearsSubDocumentReadFromParent
  • ReportsLoadFlagsFromOptions

Full unit suite against yrs 0.19.1: 441 passed, 8 skipped.

These are regression guards. The original bugs read indeterminate values, so they cannot be made to fail deterministically.

Notes

  • Native yrs 0.28 accepts a null parent transaction, so a later 0.28 migration can pass nint.Zero here.
  • No public API change.

🤖 Generated with Claude Code

Comment thread YDotNet/Native/Document/DocChannel.cs Resolved
…returns

ydoc_clear takes a parent write transaction that was never passed, so the
native side read an indeterminate pointer. yxmlelem_parent and
yxmlelem_first_child take only the branch, and ydoc_should_load and
ydoc_auto_load return uint8_t, which must not be marshalled as a 4-byte BOOL.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jcannon98188
jcannon98188 force-pushed the fix/native-signature-mismatches branch from ef69107 to 145d107 Compare October 11, 2026 16:31
@SebastianStehle
SebastianStehle merged commit 365150f into y-crdt:main Oct 12, 2026
15 checks 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.

Several native calls are declared with the wrong signature (ydoc_clear, yxmlelem_parent, yxmlelem_first_child, ydoc_should_load, ydoc_auto_load)

2 participants