Skip to content

Make RequestIdSTJsonConverter public for source generation - #1557

Merged
Andrew Arnott (AArnott) merged 4 commits into
microsoft:mainfrom
eerhardt:eerhardt-public-requestid-converter
Oct 2, 2026
Merged

Andrew Arnott (AArnott) merged 4 commits into
microsoft:mainfrom
eerhardt:eerhardt-public-requestid-converter

Conversation

@eerhardt

@eerhardt Eric Erhardt (eerhardt) commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Make RequestIdSTJsonConverter public so consumers can include RequestId in their source-generated JsonSerializerContext implementations without SYSLIB1220. Seal the converter, keep its singleton internal, document the source-generation scenario, and reject a null writer explicitly.

Add focused tests using the generated, typed JsonTypeInfo<RequestId> for numeric boundaries, string escaping, null and unspecified IDs, and invalid JSON token types, plus a null-writer guard test. Existing request ID tests are preserved.

Addresses the converter-accessibility portion of #1407. Automatic formatter resolver registration is NOT in this PR and remains separate follow-up work. This change does not claim general AOT compatibility.

Validation

  • dotnet build test\StreamJsonRpc.Tests\StreamJsonRpc.Tests.csproj -c Release --no-restore --nologo --verbosity quiet — succeeded for all test target frameworks with zero warnings and errors.
  • dotnet test --project test\StreamJsonRpc.Tests\StreamJsonRpc.Tests.csproj --no-build -c Release -- --filter-class RequestIdTests --filter-not-trait 'TestCategory=FailsInCloudTest' — 63 passed across net8.0, net9.0, and net472; no failures or skips.
  • dotnet pack src\StreamJsonRpc\StreamJsonRpc.csproj -c Release --no-restore --nologo --verbosity quiet — succeeded, including package API compatibility checks, with zero warnings and errors.

Expose the converter for consumer JsonSerializerContext implementations and validate typed JsonTypeInfo round trips, invalid tokens, and null writer handling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 00:11
@azure-pipelines

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The additive API change is documented, focused, and adequately covered by consumer-style source-generation tests.

Review effort: Balanced
Findings: None

What changed in this PR

Makes RequestIdSTJsonConverter publicly accessible for consumer source-generated serialization contexts.

Changes:

  • Exposes and documents the converter while retaining its internal singleton.
  • Adds explicit null-writer validation.
  • Adds focused source-generation serialization tests.
File Description
src/​StreamJsonRpc/​RequestIdSTJsonConverter.cs Exposes and documents the converter and validates the writer.
test/​StreamJsonRpc.Tests/​RequestIdTests.cs Tests source-generated request ID serialization and validation.

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

Comment thread src/StreamJsonRpc/RequestIdSTJsonConverter.cs Outdated
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 01:46

Copilot AI left a comment

Copy link
Copy Markdown

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 converter is sealed despite the PR’s explicit requirement that it remain unsealed.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)

Comment thread src/StreamJsonRpc/RequestIdSTJsonConverter.cs Outdated
Copilot AI balanced review requested due to automatic review settings October 1, 2026 20:12
@AArnott

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

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 test uses the newly nested converter without qualification, causing a compilation error.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (1)

Comment thread test/StreamJsonRpc.Tests/RequestIdTests.cs Outdated
@AArnott
Andrew Arnott (AArnott) force-pushed the eerhardt-public-requestid-converter branch from 38f1d91 to 099fd55 Compare October 1, 2026 20:27
Copilot AI balanced review requested due to automatic review settings October 1, 2026 20:27
@AArnott

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown

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 new public constructor needs API documentation per repository guidelines.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (1)

Comment thread src/StreamJsonRpc/SystemTextJsonFormatter.cs
@AArnott
Andrew Arnott (AArnott) enabled auto-merge (squash) October 1, 2026 21:00

@eerhardt Eric Erhardt (eerhardt) left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can't approve. :( But I can push a change and then Andrew Arnott (@AArnott) can approve.

Comment thread test/StreamJsonRpc.Tests/RequestIdTests.cs Outdated
auto-merge was automatically disabled October 1, 2026 23:02

Head branch was pushed to by a user without write access

Copilot AI balanced review requested due to automatic review settings October 1, 2026 23:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The accessibility change is consistent across consumers and is covered by focused boundary, token, and validation tests.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@AArnott
Andrew Arnott (AArnott) enabled auto-merge (squash) October 2, 2026 04:42
@AArnott

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@AArnott
Andrew Arnott (AArnott) merged commit bfe9de9 into microsoft:main Oct 2, 2026
6 checks passed
@eerhardt
Eric Erhardt (eerhardt) deleted the eerhardt-public-requestid-converter branch October 2, 2026 18:47
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.

Make RequestIdSTJsonConverter public for AOT/trimming compatibility

3 participants