Files
UA-.NETStandard/tests
Marc Schier 84d6387a4f Make request cancellation own exactly one terminal state (#4744)
# Description

`RequestLifetime` now publishes the winning cancellation status and
terminal ownership in a single atomic state, so concurrent client
Cancel, Session close and timeout can never overwrite each other's
status or double-own the terminal transition. External token
registrations are owned by the lifetime and released on completion, and
disposal is deferred until running cancellation callbacks have finished
(no use-after-dispose of the CancellationTokenSource).

Adds regression tests: 16384-iteration race tests asserting
status/owner/callback outcomes with a finite 2 min watchdog
(`RequestLifetimeTests`, `RequestManagerTests`) and `WaitAsync`
cancellation tests (`TaskWaitAsyncTests`; the polyfill change is only 2
XML doc lines, no runtime change).

Files: `RequestLifetime.cs`, `System.Threading.Tasks.cs` (docs), and the
three test files. `StandardServer.cs` is intentionally untouched
(already on master).

## Related Issues

- None.

## Checklist

- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [ ] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [ ] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.

Validation actually run (net10.0 and net48, all passed): Types.Tests
`TaskWaitAsync` 23/23; Core.Tests `RequestLifetime` 16/16; Server.Tests
`RequestManager` 56/56; `dotnet format whitespace --verify-no-changes`
on owned files. Full UA.slnx not run.
2026-10-12 18:14:15 +00:00
..