Expose DelayHelper as a public timing API in the Iot.Device namespace#2585
Conversation
| using System.Threading; | ||
|
|
||
| namespace System.Device | ||
| namespace Iot.Device |
There was a problem hiding this comment.
@copilot changing the namespace without moving the helper in the other assembly raise a problem in terms of binary compatibility for the future.
There was a problem hiding this comment.
Agreed — once Iot.Device.DelayHelper ships as public API of Iot.Device.Bindings, it's locked into that assembly. It can't be forwarded to System.Device.Gpio later (the dependency runs the other way, and the namespace differs), so honoring the original issue ("part of System.Device.Gpio") would then be a binary-breaking change.
The clean fix is to give it its permanent home now, before it's public: move DelayHelper into the System.Device.Gpio project with the System.Device namespace (where it already lives today), and drop the namespace change to Iot.Device. That does conflict with the earlier triage note to keep it in Iot.Device.Bindings, so I don't want to move assemblies unilaterally.
Which assembly should be the final home — System.Device.Gpio (matches the issue, avoids the compat trap) or Iot.Device.Bindings (earlier triage)? I'll implement whichever you confirm.
There was a problem hiding this comment.
@raffaeler As we don't have any plans in moving stuff from Iot.Device.Bindings to System.Device in the near future, I guess the Iot.Device namespace is the better one for this.
Binding authors had no public high-precision wait primitive in the .NET IoT libraries and were forced to roll their own. Per the issue triage,
DelayHelperis promoted to public API inIot.Device.Bindings, with the millisecond overload kept out of the public surface.Changes
DelayHelper→namespace Iot.Device, made public (DelayHelper.cs,ClassVisibility.cs).Delay(TimeSpan, bool)andDelayMicroseconds(int, bool)are the public surface.DelayMillisecondsstays out of the shipped API. It compiles asinternalin the packaged build (guarded by#if BUILDING_IOT_DEVICE_BINDINGS) and remains public in standalone device builds, whereCommonis a separate assembly — so existing callers keep working. Millisecond-scale waits should preferThread.Sleep.Iot.Device.*resolve the type via the enclosing namespace unchanged; onlySoftwarePwmChannel(inSystem.Device.Pwm.Drivers) needed an addedusing Iot.Device;.DelayHelperTestcovering the guaranteed lower-bound wait forDelayandDelayMicroseconds.Usage
Notes for reviewers
Iot.Device); the package location and internal-milliseconds constraint follow @krwq's. Confirm this split is the intended final shape.Iot.Device.Common→Iot.Device(mentioned in triage for the weather helper) is intentionally out of scope here.