Skip to content

Switch .NET to exact JSON FFI ingress - #1351

Merged
Gudge (MGudgin) merged 1 commit into
mainfrom
user/gudge/dotnet-json-ffi
Oct 2, 2026
Merged

Gudge (MGudgin) merged 1 commit into
mainfrom
user/gudge/dotnet-json-ffi

Conversation

@MGudgin

@MGudgin Gudge (MGudgin) commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

This PR maps V1 .NET execution and request probing to the SDK-owned exact
1.0.0 JSON contract. It generates C# wire types from the registered Rust
contract and uses one writer for all native entry points, preserving Native
AOT through source-generated serialization.

Details

  • Generate closed C# contract types and drift checks, preserving unsigned
    numeric bounds and required nullable fields under null-omitting options.
  • Move Run, Spawn, and Probe onto exact JSON FFI with shared source-generated
    serialization and actionable errors for unsupported policy.
  • Preserve environment order and caller IDs; reject invalid keys, enum
    values, and unsupported stable experimental authorization before native.
  • Correct lifecycle guidance and keep managed API parity checks precise for
    attribute ordering, ignored fields, and sandbox-id prefix dispatch.

Tests

  • Cargo format, compiler, clippy and schema emitter tests passed.
  • Contract codegen, .NET API parity and exact fixture gates passed.
  • dotnet test --solution Microsoft.Mxc.Sdk.slnx: 329 passed, 29 skipped.
  • XML docs and reflection-disabled win-x64 Native AOT publish/run passed.
  • Native Linux/macOS and elevated live-host tests were not run locally.
Microsoft Reviewers: Open in CodeFlow

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 0492605 to 53f0bfa Compare September 30, 2026 17:18
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch 2 times, most recently from eafb96a to 8d1b835 Compare September 30, 2026 17:32
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 8d1b835 to 83eb313 Compare September 30, 2026 20:29
@MGudgin
Gudge (MGudgin) changed the base branch from user/gudge/rust_ffi_json_ingress to user/gudge/node-json-ffi September 30, 2026 20:29
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 83eb313 to eaffaf6 Compare September 30, 2026 20:31
@MGudgin
Gudge (MGudgin) added this pull request to stack #1356 September 30, 2026 21:26
@MGudgin
Gudge (MGudgin) marked this pull request as ready for review September 30, 2026 21:27
@MGudgin
Gudge (MGudgin) requested review from a team and a balanced review from Copilot September 30, 2026 21:27
@MGudgin
Gudge (MGudgin) requested a review from a team as a code owner September 30, 2026 21:27
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from eaffaf6 to 9fe4ac0 Compare September 30, 2026 21:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Exact-wire numeric and environment mappings are incorrect, and two public API paths provide misleading experimental behavior.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Moves the .NET V1 SDK to exact 1.0.0 JSON FFI ingress.

Changes:

  • Adds generated C# wire types and drift validation.
  • Maps public .NET policies to exact JSON requests.
  • Routes one-shot APIs through JSON FFI and expands conformance tests.
File Description
src/​tools/​mxc_schema_gen/​tests/​cli.rs Tests C# generation.
src/​tools/​mxc_schema_gen/​src/​main.rs Adds the csharp command.
src/​core/​mxc_schema_support/​src/​lib.rs Exposes C# emission.
src/​core/​mxc_schema_support/​src/​cs_emit.rs Implements the C# emitter.
src/​core/​mxc_config_contract/​src/​registry.rs Registers C# artifact paths.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​MxcSandbox.cs Uses JSON FFI entry points.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​MxcLifecycle.cs Rejects stable wsb: lifecycle IDs.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​ExactOneShotRequestWriter.cs Maps V1 requests to exact wire types.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​Generated/​MxcConfigV1_0_0.g.cs Adds generated 1.0.0 models.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​SandboxPolicyTests.cs Updates exact-contract assertions.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​MxcSandboxTests.cs Updates one-shot serialization tests.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​MxcLifecycleTests.cs Tests wsb: rejection.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​ExactOneShotRequestWriterTests.cs Adds writer conformance tests.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​Microsoft.Mxc.Sdk.Tests.csproj Embeds SDK-v1 fixtures.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​JsonAssert.cs Generalizes JSON comparison.
scripts/​versioning/​check-contract-codegen.js Adds C# drift checks.
scripts/​check-dotnet-bindings-codegen.js Marks JSON exports as consumed.
scripts/​check-dotnet-api-parity.js Checks against the exact contract.
docs/​schema-codegen.md Documents C# generation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/core/mxc_schema_support/src/cs_emit.rs Outdated
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/ExactOneShotRequestWriter.cs
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/MxcSandbox.cs
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/MxcLifecycle.cs
Copilot AI balanced review requested due to automatic review settings September 30, 2026 21:33
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 9fe4ac0 to 885b720 Compare September 30, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The generated wire model narrows valid u64 values, while request mapping also changes supplied IDs and environment ordering.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity · 1 Low severity

Open (5)

Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/ExactOneShotRequestWriter.cs Outdated
Copilot AI balanced review requested due to automatic review settings September 30, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Valid ulong memory values regress, environment validation is weakened, and the public experimental opt-in becomes silently ineffective.

Review effort: Balanced
Findings: 2 High severity · 3 Medium severity · 1 Low severity

Open (6)

Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/ExactOneShotRequestWriter.cs
Copilot AI balanced review requested due to automatic review settings October 2, 2026 22:13
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 885b720 to 4bb99c7 Compare October 2, 2026 22:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread src/core/mxc_schema_support/src/cs_emit.rs
Comment thread scripts/check-dotnet-api-parity.js Outdated
Comment thread scripts/check-dotnet-api-parity.js Outdated
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/ExactOneShotRequestWriter.cs
Copilot AI balanced review requested due to automatic review settings October 2, 2026 23:18
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 4bb99c7 to 44e58a0 Compare October 2, 2026 23:18
Base automatically changed from user/gudge/node-json-ffi to main October 2, 2026 23:29
This PR maps V1 .NET execution and request probing to the SDK-owned exact
1.0.0 JSON contract. It generates C# wire types from the registered Rust
contract and uses one writer for all native entry points, preserving Native
AOT through source-generated serialization.

Details

* Generate closed C# contract types and drift checks, preserving unsigned
  numeric bounds and required nullable fields under null-omitting options.
* Move Run, Spawn, and Probe onto exact JSON FFI with shared source-generated
  serialization and actionable errors for unsupported policy.
* Preserve environment order and caller IDs; reject invalid keys, enum
  values, and unsupported stable experimental authorization before native.
* Correct lifecycle guidance and keep managed API parity checks precise for
  attribute ordering, ignored fields, and sandbox-id prefix dispatch.

Tests

* Cargo format, compiler, clippy and schema emitter tests passed.
* Contract codegen, .NET API parity and exact fixture gates passed.
* dotnet test --solution Microsoft.Mxc.Sdk.slnx: 329 passed, 29 skipped.
* XML docs and reflection-disabled win-x64 Native AOT publish/run passed.
* Native Linux/macOS and elevated live-host tests were not run locally.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 30c4f940-9c8e-4d3e-89ff-b1776045bb1c
Generated-with: gpt-6-sol

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread sdk/node/src/bindings/one-shot.ts Outdated
if (cwd !== undefined) process.cwd = cwd;
const env = environment(config, options);
if (env !== undefined) process.env = env;
if (inheritDefaultEnv(config, options)) process.inheritDefaultEnv = true;
Comment thread scripts/check-dotnet-api-parity.js
Copilot AI balanced review requested due to automatic review settings October 2, 2026 23:36
@MGudgin
Gudge (MGudgin) force-pushed the user/gudge/dotnet-json-ffi branch from 44e58a0 to 260bd1c Compare October 2, 2026 23:36
@MGudgin
Gudge (MGudgin) merged commit 232ab9e into main Oct 2, 2026
12 checks passed
@MGudgin
Gudge (MGudgin) deleted the user/gudge/dotnet-json-ffi branch October 2, 2026 23:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +290 to +291
const hasCsharpPath =
typeof contract.csharpPath === "string" && contract.csharpPath.length > 0;
{
ArgumentNullException.ThrowIfNull(request);
return MxcJson.Serialize(PrepareRequest(request), MxcJson.Options);
return ExactOneShotRequestWriter.Serialize(request);
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.

3 participants