Repository navigation
Conversation
Pin what the savepoint members do when a provider overrides none of them: Save and Rollback(string) and their asynchronous forms throw NotSupportedException (stored in the task for the async ones), Release and ReleaseAsync do nothing. Also cover the asynchronous members delegating to overridden synchronous ones, storing the exceptions those throw, and returning a canceled task for a canceled token.
The summary said that SaveAsync, RollbackAsync and ReleaseAsync, and their synchronous counterparts, are expected to throw NotSupportedException when SupportsSavepoints is false. Release and ReleaseAsync do not: Release is a no-op by design, as the API proposal for savepoints (dotnet#33397) describes. Say so on SupportsSavepoints, Release and ReleaseAsync. Fixes dotnet#137040
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @SamMonoRT, @dotnet/efteam |
alaricd
marked this pull request as ready for review
November 5, 2026 20:03
This was referenced Nov 5, 2026
1 of 3 tasks
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Approval should be deferred because the new System.Data.Common tests and documentation have not yet been built or executed, and CI validation remains pending.
No open issues 🎉
What changed in this PR
This PR corrects the DbTransaction XML documentation to match the existing default savepoint behavior, including the intentional no-op behavior of Release and ReleaseAsync. It also adds focused tests covering default savepoint members and asynchronous delegation behavior.
Changes:
- Clarifies
SupportsSavepoints,Release, andReleaseAsyncdocumentation. - Adds tests for default exceptions, no-op release behavior, cancellation, synchronous delegation, and task exception handling.
- Includes the new savepoint test file in the System.Data.Common test project.
| File | Description |
|---|---|
| src/libraries/System.Data.Common/tests/System/Data/Common/DbTransactionSavepointTests.cs | Adds coverage for default and asynchronous savepoint behavior. |
| src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj | Includes the new savepoint test file in the test project. |
| src/libraries/System.Data.Common/src/System/Data/Common/DbTransaction.cs | Corrects savepoint API documentation without changing runtime behavior. |
Review effort: Lite
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #137040
Problem
The XML documentation on
DbTransaction.SupportsSavepoints, which is also what learn.microsoft.com publishes, says that when it isfalsethe methodsSaveAsync,RollbackAsyncandReleaseAsync, "as well as their synchronous counterparts", are expected to throwNotSupportedException. The implementation does not do that forRelease/ReleaseAsync:That is the shape approved in #33397, whose notes explain that a
Releaseno-op by default "seems correct", since releasing has no user-visible behavior and should generally not throw. So the implementation is intentional and the sentence is what is out of step. A provider author, or anyone writing a conformance test from that sentence, will expectReleaseto throw, and every provider that does not override it appears to violate the contract.Change
Documentation only, no behavior change:
SupportsSavepoints:Save/SaveAsyncandRollback(string)/RollbackAsyncare the members expected to throw; a remark saysRelease/ReleaseAsyncdo nothing by default and do not throw when savepoints are unsupported.ReleaseandReleaseAsync: a remark states the default behavior.Tests
DbTransactionSavepointTestsis new. It pins the default behavior of all six members so the documentation and the implementation cannot drift apart again:SupportsSavepointsdefaults tofalse;SaveandRollback(string)throwNotSupportedException;Releasedoes nothing;SaveAsync/RollbackAsyncstore the exception in the task rather than throwing;ReleaseAsynccompletes. It also covers the async members delegating to overridden synchronous ones, storing the exceptions those throw, and returning a canceled task for a canceled token without calling the synchronous method.Because this is a documentation fix, the tests describe existing behavior and are expected to pass both before and after the doc change (they are in their own commit ahead of it).
I have not run these tests locally, and CI has not run them yet. Building dotnet/runtime's library tests needs a CoreCLR build, which my environment cannot do (no C++ toolchain). The PR is now ready for review, but the full build and test pipelines still need a maintainer to start them on this fork-based PR. I checked the code by reading it against the surrounding sources only; please run the pipelines, and until a green run exists, please treat the tests as unverified and tell me if anything fails to compile.
How this was found
Found by pengdows.AdoNetApiTest.conformance, an xUnit conformance suite for ADO.NET providers that checks the documented
System.Data.Commoncontract. Its savepoint tests asserted thatReleasethrows when savepoints are unsupported, built from that documentation sentence; they failed forSystem.Data.OleDband for Sqlite. Reading the source and #33397 showed the suite, not the base class, was wrong, so the suite has been corrected and this PR corrects the documentation.