CA2007 and set streamer mic device - #7
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
It introduces breaking changes to the public API surface (public interface method addition and a positional record signature change) that should be redesigned for compatibility or explicitly treated as a major/breaking release.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the SteelSeries Sonar .NET library to (1) enforce CA2007 library-await behavior by consistently using ConfigureAwait(false) within the core library project, and (2) add support for routing the streamer-mode mic passthrough device plus corresponding event diffing and tests.
Changes:
- Enforced CA2007 in
SteelSeriesAPIvia a library-scoped.editorconfigand updated awaits to useConfigureAwait(false). - Added a mic passthrough redirection route +
SetMicDeviceAsyncAPI surface and a corresponding Explorer/Sample usage. - Extended redirection change diffing to detect mic device changes and added test coverage.
File summaries
| File | Description |
|---|---|
| SteelSeriesAPI/SteelSeriesAPI.csproj | Bumps package version to 2.0.0-alpha.2. |
| SteelSeriesAPI/Sonar/SonarRoutes.cs | Adds a dedicated route builder for mic passthrough device redirection. |
| SteelSeriesAPI/Sonar/Managers/VolumeSettingsManager.cs | Adds ConfigureAwait(false) to library awaits. |
| SteelSeriesAPI/Sonar/Managers/RedirectionsManager.cs | Adds SetMicDeviceAsync implementation and applies ConfigureAwait(false) to awaits. |
| SteelSeriesAPI/Sonar/Managers/ModeManager.cs | Applies ConfigureAwait(false) throughout mode get/set + polling loop. |
| SteelSeriesAPI/Sonar/Managers/IRedirectionsManager.cs | Adds SetMicDeviceAsync to the public redirections interface. |
| SteelSeriesAPI/Sonar/Managers/ConfigManager.cs | Adds ConfigureAwait(false) to library awaits. |
| SteelSeriesAPI/Sonar/Managers/ChatMixManager.cs | Adds ConfigureAwait(false) to library awaits. |
| SteelSeriesAPI/Sonar/Managers/AudioDeviceManager.cs | Adds ConfigureAwait(false) to library awaits. |
| SteelSeriesAPI/Sonar/Managers/AppRoutingManager.cs | Adds ConfigureAwait(false) to library awaits. |
| SteelSeriesAPI/Sonar/Events/SonarEventListener.cs | Adds ConfigureAwait(false) to listener stop/connect/receive/delay awaits. |
| SteelSeriesAPI/Sonar/Events/RedirectionChanges.cs | Adds MicDeviceChange and extends RedirectionDiff to include it. |
| SteelSeriesAPI/Sonar/Events/Listener/SonarEventListener.Volumes.cs | Adds ConfigureAwait(false) in polling loop and refresh calls. |
| SteelSeriesAPI/Sonar/Events/Listener/SonarEventListener.Redirections.cs | Raises a new MicDeviceChanged event and adds mic device diff logic. |
| SteelSeriesAPI/Sonar/Events/Listener/SonarEventListener.Configs.cs | Adds ConfigureAwait(false) to selected-config refresh. |
| SteelSeriesAPI/Sonar/Events/Listener/DebouncedRefresher.cs | Adds ConfigureAwait(false) to debounce/delay/lock awaits. |
| SteelSeriesAPI/Core/SonarHttpClient.cs | Adds ConfigureAwait(false) and adjusts async stream disposal pattern. |
| SteelSeriesAPI/Core/ServerDiscovery.cs | Adds ConfigureAwait(false) to GG subApps fetch. |
| SteelSeriesAPI/.editorconfig | Introduces library-only CA2007 enforcement as an error. |
| SteelSeriesAPI.Tests/SonarEventListenerTests.cs | Adds tests for mic device change detection in redirection diffs. |
| SteelSeriesAPI.Tests/RedirectionsManagerTests.cs | Adds a test asserting the mic redirection route shape/escaping. |
| SteelSeriesAPI.Sample/Program.cs | Demonstrates subscribing to MicDeviceChanged. |
| SteelSeriesAPI.Explorer/Program.cs | Adds an end-to-end “mic device round-trip” explorer step. |
Review details
- Files reviewed: 23/23 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| /// <summary>Routes a streamer-mode mix to a different output device.</summary> | ||
| Task SetMixDeviceAsync(Mix mix, string deviceId, CancellationToken ct = default); | ||
|
|
||
| /// <summary> | ||
| /// Routes the streamer-mode mic passthrough to a different capture device. | ||
| /// </summary> | ||
| /// <param name="deviceId">The id of the capture device to capture the mic from.</param> | ||
| /// <param name="ct">A token to cancel the operation.</param> | ||
| Task SetMicDeviceAsync(string deviceId, CancellationToken ct = default); |
| /// <summary>Everything that changed between two redirection snapshots.</summary> | ||
| public sealed record RedirectionDiff( | ||
| IReadOnlyList<ClassicDeviceChange> ClassicDeviceChanges, | ||
| IReadOnlyList<MixDeviceChange> MixDeviceChanges, | ||
| IReadOnlyList<MixChannelToggle> MixChannelToggles, | ||
| StreamMonitoringChange? MonitoringChange) | ||
| StreamMonitoringChange? MonitoringChange, | ||
| MicDeviceChange? MicDeviceChange) | ||
| { | ||
| /// <summary>True when nothing actually changed between the two snapshots.</summary> | ||
| public bool IsEmpty => | ||
| ClassicDeviceChanges.Count == 0 && MixDeviceChanges.Count == 0 && | ||
| MixChannelToggles.Count == 0 && MonitoringChange is null; | ||
| MixChannelToggles.Count == 0 && MonitoringChange is null && MicDeviceChange is null; |
No description provided.