test: clear all 504 xunit analyzer warnings - #588
Merged
Conversation
A clean rebuild emitted 504 xunit analyzer warnings, burying genuinely
interesting output. That 504 is 129 unique source locations - the rest is
per-TFM and per-node duplication - which made hand-fixing every one of
them practical, so nothing is suppressed wholesale.
xUnit1013 (26 locations) - triaged by hand, as the issue asked, and it
was worth it:
- ProjectionRebuildSelectionTests implemented IProjectionHost on itself.
Interface members must be public, so every one read as an
un-attributed test method. That is the same self-stub shape that broke
all 16 SliceGroupTests in #577. Extracted to RecordingProjectionHost.
- RetryBlockTests.retry_within_threshold was a commented-out //[Fact].
Now [Fact(Skip = "Unreliable in CI")] so it is visibly skipped rather
than silently nonexistent. CoreTests totals 476 with 1 skipped.
- Documentation samples on test classes (ResourceHostExtensionsTests,
UsingSourceWriter) moved to sibling non-test classes, which keeps the
#region snippet text byte-for-byte identical - one of those regions
includes its method signature.
- Reflection targets (EventExtensionsTests x2,
event_parameter_naming_convention) made private, with BindingFlags
added where the lookup needed it.
xUnit1026 (2) - one was a real gap. AggregateVersioningTests
set_version_single_stream_on_internal ran ten InlineData cases and
asserted nothing at all; 'expected' was unused because the assertion was
missing entirely. It only ever proved TrySetVersion() doesn't throw. Now
asserts GetVersion() == expected, and passes.
xUnit1031 (4) - StoreUriStampingObserverTests had two sync tests calling
.Wait() on tasks. Both are now async/await.
xUnit1012 (8) - theory parameters that take null are now nullable.
xUnit1051 (89) - TestContext.Current.CancellationToken threaded through.
One documented #pragma exception in TaskExtensionsTests: SetCanceled(ct)
records which token DID cancel a task rather than observing one, so
passing the test's uncancelled token would assert something false.
Verified: 504 -> 0 xunit warnings on a clean rebuild, and the CS warning
count is unchanged at exactly 1920, so nothing was traded away.
Test counts against the #581 baseline: CoreTests 475+1 skipped,
CodegenTests 419, CommandLineTests 295, EventTests 648, EventStoreTests
72, CodegenTests.FSharp 1, JasperFx.SourceGenerator.Tests 19,
JasperFx.Events.SourceGenerator.Tests 26. CoreTests and EventTests also
run green on net10.0.
Closes #582
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #582
The 504 is really 129
Parsing the build log by unique
(rule, file, line, col)shows the 504 warnings come from 129 distinct source locations — the rest is per-TFM (net9.0/net10.0) and per-node duplication. That changed the plan: 129 is small enough to fix every one by hand, so nothing is suppressed wholesale and there is no blanketNoWarn.TestContext.Current.CancellationTokenthreaded throughxUnit1013 was worth the hand triage
The issue predicted actual bugs could hide here. Two did:
ProjectionRebuildSelectionTestsimplementedIProjectionHoston itself. Interface members have to be public, so all four read as un-attributed test methods — the exact self-stub shape that broke all 16SliceGroupTestsin #577, where a self-stubbedIAsyncDisposable.DisposeAsyncran as test lifecycle instead of as a stub. Extracted to aRecordingProjectionHostclass, which removes the warnings and the footgun together.RetryBlockTests.retry_within_thresholdwas a commented-out//[Fact]— a test that had silently ceased to exist. Now[Fact(Skip = "Unreliable in CI - timing sensitive under load")], so it shows up as skipped on every run instead of vanishing. This is the one intentional baseline change: CoreTests reports 476 total, 475 passed, 1 skipped.The rest were benign but fixed properly rather than suppressed:
ResourceHostExtensionsTests,UsingSourceWriter) moved to sibling non-test classes. Deliberately not made private —sample_programmatically_control_resourcesincludes its own method signature inside the#region, so reducing visibility would have changed published docs. Moving keeps the snippet text byte-for-byte identical.EventExtensionsTests×2,event_parameter_naming_convention) made private, withBindingFlags.Instance | BindingFlags.NonPublicadded where the lookup needed it. The expression-tree lookups bind private methods fine from inside the class.xUnit1026 found a test asserting nothing
AggregateVersioningTests.set_version_single_stream_on_internalran tenInlineDatacases and had an empty body afterTrySetVersion— no assertion at all.expectedwas unused because the assertion was never written. It only ever provedTrySetVersion()doesn't throw.It passes — the behavior was right, the test just wasn't checking it.
xUnit1031
StoreUriStampingObserverTestshad two sync tests calling.Wait()on tasks. Both are nowasync Taskwithawait.xUnit1051 — one documented exception
All 89 got the token threaded through, except one where the analyzer's advice is wrong:
Verification
The CS count is the check that matters — no warnings were traded for others, and no nullable-annotation changes leaked new ones.
CoreTests and EventTests also verified green on
net10.0.Not included
I did not add
WarningsAsErrorsfor these rules to stop them creeping back — that changes your build's failure behavior and wasn't part of the ask. Happy to add it if you want the guard.🤖 Generated with Claude Code