Skip to content

docs(core): correct the WaitBetterAsync comments and listed version - #125

Merged
framinosona merged 1 commit into
mainfrom
framinosona/docs-waitbetter-comments
Nov 23, 2026
Merged

framinosona merged 1 commit into
mainfrom
framinosona/docs-waitbetter-comments

Conversation

@framinosona

Copy link
Copy Markdown
Member

Summary

Corrects three code comments that say WaitBetterAsync ignores the cancellation token when there is no timeout, and the Plugin.BaseTypeExtensions version in Docs/COPILOT_INSTRUCTIONS.md. Comments and one doc line only; no code changes.

Why

Since Plugin.BaseTypeExtensions 1.0.35 (#123), WaitBetterAsync observes the token with no timeout, so the comments are wrong. They sit on WaitForStopAsync (scanner and broadcaster) and WaitForAttemptAsync (remote device), which wait with Task.WaitAsync. The real difference from WaitBetterAsync is how a zero timeout is read, and the comments now say that.

Change Type

  • Feature
  • Bug fix
  • Refactor (refa)
  • Docs only
  • CI/build/tooling

Affected Areas

  • Abstractions
  • Core
  • Platform: Android
  • Platform: iOS/macOS
  • Platform: Windows
  • Platform: DotNetCore fallback
  • Facade (Bluetooth.Maui)
  • Documentation

Behavior And Compatibility

  • Public API changed
  • Exception behavior changed
  • DI registration behavior changed
  • Capability matrix impact
  • No externally visible behavior change

Platform Notes

None.

Tests

  • Unit tests added/updated
  • Integration/smoke tests added/updated
  • Manual platform validation performed
  • Not applicable (explain)

Validation notes: comments and a doc line only. Bluetooth.Core.Scanning and Bluetooth.Core.Broadcasting build in Release with --no-incremental, 0 warnings and 0 errors (the new <see cref="RemainingTimeout" /> resolves).

Documentation

  • Docs updated in same PR
  • Capability claims verified against implementation
  • Links validated
  • Not applicable (explain)

Logging / Diagnostics

  • New logs added
  • EventId range validated
  • No logging changes

Risks And Follow-ups

Risk level:

  • Low
  • Medium
  • High

Known limitations or deferred follow-ups:

  • The three helpers stay. They are no longer token workarounds, but they are not interchangeable with WaitBetterAsync: with a zero timeout and a task that has not finished, Task.WaitAsync throws TimeoutException while WaitBetterAsync waits for the task, and a negative timeout other than Timeout.InfiniteTimeSpan throws ArgumentOutOfRangeException in Task.WaitAsync but means "no timeout" in WaitBetterAsync (checked against 1.0.35). The broadcaster passes zero on purpose through RemainingTimeout when the budget has run out, so swapping the helpers would turn that into an unbounded wait.
  • That leaves two readings of a zero timeout: a caller that runs the operation waits with WaitBetterAsync ("no timeout"), a caller that joins an operation already running waits with Task.WaitAsync ("time out now"). Picking one reading for both is a behavior change and is not part of this PR.
  • The dependency list in Docs/COPILOT_INSTRUCTIONS.md still shows older numbers for the other packages (ByteArrays 1.0.30, ExceptionListeners 1.0.5, Microsoft.Extensions 10.0.3); the doc itself says to read Directory.Packages.props.

Checklist

  • I reviewed Docs/Best-Practices/Contribution-DoD.md
  • Commit header follows type (scope): short imperative and is <= 72 chars
  • Commit type is one of: feat, fix, refa, perf, docs, ci, chore, test, build
  • Commit body is 1-2 factual sentences (what/why), no emojis, refs, or co-authors
  • If architectural behavior changed, an ADR was added or updated under Docs/Architecture/ADR

Three comments said WaitBetterAsync ignores the cancellation token without a timeout, which stopped being true in Plugin.BaseTypeExtensions 1.0.35; they now state the real difference, how a zero timeout is read. The dependency list in COPILOT_INSTRUCTIONS.md names version 1.0.35.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 23:51

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.

🟢 Approval recommended

No active review issues are recorded for the documentation and comment updates.

No open issues 🎉

What changed in this PR

Updates comments and documentation after the Plugin.BaseTypeExtensions 1.0.35 upgrade in #123. No executable code or runtime behavior changes.

Changes:

  • Replaces outdated cancellation-token claims with the zero-timeout distinction between Task.WaitAsync and WaitBetterAsync.
  • Explains the broadcaster’s reliance on immediate timeout when its remaining budget reaches zero.
  • Updates the documented Plugin.BaseTypeExtensions version to 1.0.35.
File Description
Docs/​COPILOT_INSTRUCTIONS.md Corrects the listed dependency version.
Bluetooth.Core.Scanning/​BaseBluetoothScanner.StartStop.cs Clarifies zero-timeout behavior in the stop-wait comment.
Bluetooth.Core.Scanning/​BaseBluetoothRemoteDevice.Connection.cs Corrects the comment explaining the use of Task.WaitAsync.
Bluetooth.Core.Broadcasting/​BaseBluetoothBroadcaster.StartStop.cs Clarifies zero-timeout behavior and its connection to RemainingTimeout.

Review effort: Balanced

@framinosona
framinosona merged commit 0f70fe6 into main Nov 23, 2026
10 checks passed
@framinosona
framinosona deleted the framinosona/docs-waitbetter-comments branch November 23, 2026 00:00
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.

2 participants