Agents In Use
What’s new todayLast update
108 use cases added today

How to use GitHub Copilot to support byref JSON

A Copilot PR added byref constructor support to System.Text.Json across reflection and source generation, with modifier tests and human review before merge.

FROM THE SOURCE

Original prompt

Shared by the source author. See source notes for context.

System.Text.Json does not support constructors with byref parameters.

Evidence at a glance

Sourced account
Original account
Read the source ↗
Published
Source link checked
Reported result
A Copilot PR added byref constructor support to System.Text.Json across reflection and source generation, with modifier tests and human review before merge; the pull request merged into dotnet/runtime main.
Human involvement
Maintainers guided expected behavior and eiriktsarpalis merged.

A linked account supports attribution. It does not mean we independently reproduced its result.

Report an issue with this caseOpen correction email

Opens your email app with the case link included. Nothing is sent automatically.

How the agent did it

  1. Unwrapped byref element types during validation/converter creation.
  2. Handled in/ref/out across reflection emit and source generator.
  3. Added modifier/type permutations and regression baselines.

A System.Text.Json issue reported failure for types whose constructors used byref parameters such as in DateTime and in TimeSpan. GitHub Copilot worked on a pull request that addressed the mismatch between byref parameter metadata and the types needed by serializer converters.

The implementation used underlying element types for validation and generic converter construction. Reflection-based invocation also needed temporary values and addresses appropriate to the parameter kind. The work extended into source generation, recording modifier information and emitting suitable calls for in, ref, out and ref readonly parameters.

The PR documents special handling for out parameters: they are excluded from JSON parameter metadata and initialized for the constructor rather than receiving values as ordinary input arguments. It added permutations involving primitive, struct and reference types, plus source-generator baselines.

This was an extended review process, not a one-shot completion. The pull request opened on January 6 and merged through eiriktsarpalis on March 20, 2026, after many commits. The resulting support spans reflection and generated serializers.

Prompt
Original prompt

Source: GitHub · Copilot (on behalf of stephentoub)

Frequently asked questions

Why did byref constructors fail?

Parameter metadata returned a byref type such as DateTime&, which failed validation and could not be used directly as a generic converter argument.

How are out parameters treated?

They are excluded from input parameter metadata and receive default-initialized constructor values; matching properties can be set afterward.

Did the fix cover source generation?

Yes. The PR changed reflection-based handling and source-generator parsing/emission, with modifier/type tests and generator baselines.

More details

About this account

GitHub Copilot investigated or implemented the scoped repository task and produced a pull request, with work and checks recorded for maintainer review.

Primary pull request and public API timeline opened and checked on 2026-10-14. PR creation date is the original publication date; merge dates are separate result evidence. 30 commits; avoid framing as immediate autonomous completion. Special out semantics documented. Outcomes and test claims are attributed to the source and were not independently reproduced. Original prompt excerpt: reproduced verbatim from the public PR prompt; the full task contains additional context.

Credit: Copilot (on behalf of stephentoub) on GitHub

Source published

Added to Agents In Use

Source checked

Tools and topics

GitHub Copilot · System.Text.Json · Reflection.Emit · C# · GitHub

JSON serialization · Byref parameters · Review iteration

Editorial completeness: 100/100. Measures documented fields, not agent performance or verified outcomes.