How to use GitHub Copilot to test TarReader disposal
Copilot investigated TarReader disposal, found the runtime fix already present and added synchronous and asynchronous regression tests before the PR merged.
Original prompt
Shared by the source author. See source notes for context.
Disposing TarEntry.DataStream causes TarReader.GetNextEntry to throw ObjectDisposedException
Reach people exploring AI agents
See placements →What happened
Copilot investigated TarReader disposal, found the runtime fix already present and added synchronous and asynchronous regression tests before the PR merged; the pull request merged into dotnet/runtime main.
Reported by Copilot (on behalf of stephentoub) on GitHubHow the agent did it
- Investigated disposal bug and found production fix already present.
- Added full/partial/no-read cases for synchronous and asynchronous GetNextEntry.
- Ran Tar test suite.
Where a person stepped in
Human scoped task and reviewed/merged.
A TarReader report described an ObjectDisposedException when a caller disposed an entry's DataStream before advancing through an unseekable archive. Stephen Toub delegated the issue to GitHub Copilot, which investigated the current code rather than assuming a production change was still required.
The agent found that the underlying bug had already been fixed. SubReadStream.AdvanceToEnd now used internal fields instead of properties that throw after disposal. The useful remaining work was regression coverage to keep that behavior from being lost later.
Copilot added cases for a disposed stream after a full read, after a partial read and without reading any data. It covered both synchronous GetNextEntry and the asynchronous variant. The PR reports the archive library's test results, including skipped cases requiring privileges, and classifies the patch as test-only.
Maintainer review led to a merge on January 14, 2026. The outcome should be described as added coverage for an existing fix, not as Copilot repairing the runtime defect in this PR.
Prompt
Original prompt
Source: GitHub · Copilot (on behalf of stephentoub)
Frequently asked questions
Did this PR fix the production bug?
No. Copilot found the runtime correction already present and added regression tests to preserve the corrected behavior.
Which disposal cases were covered?
The tests dispose DataStream after a full read, a partial read or no read before advancing to the next archive entry.
Was asynchronous behavior covered too?
Yes. The PR adds corresponding cases for GetNextEntryAsync alongside synchronous GetNextEntry coverage.
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. No new runtime fix: correct story is coverage for already-fixed behavior. 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 6 Jan 2026
Source checked 14 Oct 2026
Tools and topics
GitHub Copilot · TarReader · System.Formats.Tar · GitHub
Regression coverage · Archive streams · Test-only change
Editorial completeness: 100/100. Measures documented fields, not agent performance or verified outcomes.