Repository navigation
Conversation
Render the .NET operation options from core/core/src/types/options.rs so new core options reach the binding through `just generate dotnet` instead of hand-written mirrors. For each options struct the generator emits the public `*Options` class, a `#[repr(C)]` mirror with its C# interop struct, and the conversion into core options. Each operation receives its options as one pointer to that struct, null for the defaults, so no signature grows past clippy's argument limit and each operation crosses the FFI once instead of building and releasing a native options handle around the call. Optional values follow the metadata mirror's `*_has_value` convention, strings are null-terminated UTF-8, and string maps are parallel key and value arrays. C# writes the struct and everything it points to into one buffer per call, on the stack when it fits and in native memory otherwise. Native code only borrows it and copies everything into core options before the call returns, so async operations keep no reference to it. This fills the options the binding was missing: - `IfVersionMatch`/`IfVersionNotMatch` on read, stat, write, delete, and copy. - `IfNotChanged` on write, delete, and copy. The metadata crosses the FFI in full as the same `OpendalMetadata` struct the binding returns, written and rebuilt by code generated from core `Metadata`, so the binding never tracks which members a condition reads. - `ContentLengthHint` on read and `SuffixLength` for suffix reads. - `IfNoneMatch` on delete. - New `CopyOptions` and `RenameOptions`, accepted by `Copy`/`CopyAsync` and `Rename`/`RenameAsync`. Constructor options cross as key and value arrays. A null option value is reported as ConfigInvalid naming its key. The .NET guides document suffix reads, conditional copy and rename, and `IfNotChanged`. BREAKING CHANGE: `CopyAsync` and `RenameAsync` take an optional options argument before the cancellation token, matching the other operations. Pass the token by name, e.g. `CopyAsync(from, to, cancellationToken: ct)`. `IOptions` is now internal and `NativeOptionsHandle` is removed; both exposed interop details that callers had no use for.
This branch has not been deployed
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.
Which issue does this PR close?
Closes #8436.
Rationale for this change
The .NET options classes are hand-written and have fallen behind core. This generates them from
core/core/src/types/options.rsas described in the issue. As noted in the issue comment, options cross the FFI as one generated#[repr(C)]struct per operation instead of JSON, which avoids serializing on both sides of every call.What changes are included in this PR?
dev/src/generate/dotnet.rsmaps each core option shape to flat FFI fields and renders the public C#*Optionsclasses, their interop structs, and the Rust mirrors with their conversion into core options. The parser indev/src/generate/core_options.rsstays binding-agnostic.if_not_changedpasses the sameOpendalMetadatastruct the binding returns, rebuilt in Rust by code generated from coreMetadata.IfVersionMatch/IfVersionNotMatch,IfNotChanged,ContentLengthHint,SuffixLength,IfNoneMatchon delete, and newCopyOptions/RenameOptions.Tested on Windows against memory, fs, and the Silo image CI uses (versioned and plain buckets; net8.0 and net10.0).
Are there any user-facing changes?
Yes. The options above are now available, and
Copy/CopyAsyncandRename/RenameAsyncaccept options. The .NET guides document suffix reads, conditional copy and rename, andIfNotChanged.Breaking changes
Affected packages: bindings/dotnet
Migration:
CopyAsyncandRenameAsynctake an optional options argument before the cancellation token. Pass the token by name, e.g.CopyAsync(from, to, cancellationToken: ct).IOptionsis now internal andNativeOptionsHandleis removed; neither had a use outside the binding.AI Usage Statement