docs: update CLAUDE.md with NAudio testability pattern and Copilot review rule#36
Merged
MiguelTVMS merged 1 commit intodevelopfrom Mar 19, 2026
Merged
docs: update CLAUDE.md with NAudio testability pattern and Copilot review rule#36MiguelTVMS merged 1 commit intodevelopfrom
MiguelTVMS merged 1 commit intodevelopfrom
Conversation
…view rule - Document that MMDevice/MMDeviceEnumerator are sealed COM classes and cannot be mocked; explain the delegate injection + generic type pattern to make such code unit-testable without COM - Clarify [Fact] vs [WindowsFact] guidance: pure-logic tests using string stubs use [Fact]; tests that reference NAudio COM types use [WindowsFact] - Update VolumeWatcherServiceTests row: now mixed ([Fact] for ResolveMonitoredDevice string-stub tests, [WindowsFact] for the rest) - Add PR process section: Copilot review is mandatory before merging; steps to check reviews and inline comments before squash-merging
Contributor
There was a problem hiding this comment.
Pull request overview
Updates CLAUDE.md to capture team learnings around Windows/NAudio testability and the expected PR workflow, helping prevent recurring CI/test issues and standardize review practices.
Changes:
- Clarifies when to use
[Fact]vs[WindowsFact](including the “pure logic only” case). - Documents a delegate-injection + generic-type pattern for unit-testing logic that would otherwise depend on sealed NAudio COM types.
- Adds a “Pull Request Process” section requiring Copilot review before merge and outlining recommended checks.
Comment on lines
+311
to
+312
| id => (MMDevice?)_enumerator.GetDevice(id), | ||
| () => (MMDevice?)_enumerator.GetDefaultAudioEndpoint(...), |
| When a method needs to be unit-tested without COM, extract the logic into a `static` (or standalone) method that accepts delegates returning a generic `TDevice` instead of `MMDevice`, plus a `getName` delegate to get the device name: | ||
|
|
||
| ```csharp | ||
| internal static TDevice? ResolveSomething<TDevice>( |
| Func<string, TDevice?> getDevice, | ||
| Func<TDevice?> getDefault, | ||
| Func<TDevice, string?> getName, | ||
| Action<COMException, string> logWarning, |
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.
What
Updates
CLAUDE.mdto document the lessons learned from recent PR review cycles.Changes
NAudio COM testability
MMDeviceandMMDeviceEnumeratorare sealed COM classes — explicitly documented as unmockablenull!null-forgiveness workarounds (they mask the real problem)[Fact]vs[WindowsFact]clarification[Fact]is correct when the test exercises pure logic only (no Windows/COM/NAudio type references)VolumeWatcherServiceTests.cstable row: now accurately described as mixed (some[Fact], most[WindowsFact])PR Process section
Why
Several recent CI failures and iterative review cycles stemmed from the absence of this guidance:
null!stubs forMMDevice, causingNullReferenceExceptionuntil the generic-delegate pattern was applied