Skip to content

feat(csharp): add map type support#1603

Open
yordis wants to merge 6 commits intobytecodealliance:mainfrom
yordis:yordis/feat-csharp-map-support
Open

feat(csharp): add map type support#1603
yordis wants to merge 6 commits intobytecodealliance:mainfrom
yordis:yordis/feat-csharp-map-support

Conversation

@yordis
Copy link
Copy Markdown
Contributor

@yordis yordis commented Apr 21, 2026

  • Dictionary<K,V> provides a familiar, zero-dependency host representation for WIT maps in C# and unblocks runtime interop with components that use them without requiring a custom collection type.
  • Parity with the Rust, Go, and MoonBit backends that already ship map support, reducing the per-language divergence in should_fail_verify as new features land.

yordis added 2 commits April 22, 2026 02:42
Dictionary<K,V> provides a familiar, zero-dependency host representation
for WIT maps in C#, and unblocks runtime interop with components that
use them without requiring a custom collection type.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
The `map<K, V>` WIT syntax is a gated feature that the default wit-parser
used by wasm-component-ld's `--component-type` flag cannot parse, so the
text-based component type path was blocking any world that uses maps.
Switching to the same object-file approach already used by the C and C++
backends lets the component type flow through as a custom section without
round-tripping through the text parser.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/feat-csharp-map-support branch from 5f4aa9e to 1388017 Compare April 22, 2026 06:46
yordis added 2 commits April 22, 2026 03:23
Earlier attempt used `NativeFileReference` on the component-type object,
but NativeAOT's LLVM pipeline did not propagate the custom section into
the final module, leaving every C# component import unresolvable. Using
a binary-encoded WIT package (which `wasm-component-ld --component-type`
accepts alongside the text form) preserves the existing linker path and
also lets map<K,V> round-trip since decoding skips the default WIT
parser that rejects gated features.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis marked this pull request as draft April 22, 2026 08:08
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis yordis force-pushed the yordis/feat-csharp-map-support branch from 3f349cc to 00b67da Compare April 22, 2026 08:22
@yordis yordis marked this pull request as ready for review April 22, 2026 16:54
@yordis yordis marked this pull request as draft April 22, 2026 16:55
@yordis yordis marked this pull request as ready for review April 22, 2026 19:09
Copy link
Copy Markdown
Collaborator

@yowl yowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do we need the cargo.lock changes?

@yordis yordis force-pushed the yordis/feat-csharp-map-support branch 2 times, most recently from 996ba04 to 00b67da Compare April 23, 2026 02:52
Comment thread crates/csharp/src/world_generator.rs Outdated

files.push(
&format!("{world_namespace}_component_type.o"),
wit_bindgen_c::component_type_object::object(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does adding map support mean we need this library?

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
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.

2 participants