Repository navigation
test(bodies): cover the remaining typed JSON Lines branches - #2339
Merged
Merged
Conversation
Adds reflection request-builder and JsonLinesContent<T> tests to close the Codecov patch-coverage gaps on PR #2338: - FindAsyncJsonLinesElementType: a class implementing IAsyncEnumerable<T> is found through GetInterfaces (rather than being that interface itself), and a type implementing two distinct IAsyncEnumerable<> interfaces is treated as ambiguous and returns null. - JsonLinesContent<T>.MoveNextAsync: a stream whose FlushAsync throws while the producer's next step is still pending propagates the failure only after that step completes, so the enumerator is never disposed while it is in flight. Two lines remain uncovered and are genuinely unreachable, not contorted around: - JsonLinesContent<T>'s 2-arg SerializeToStreamAsync override: on NET8_0_OR_GREATER, HttpContent's internal plumbing always invokes the 3-arg CancellationToken overload (verified empirically), so the 2-arg override is dead code once both are overridden; it only matters on the netfx targets that lack the 3-arg overload. - The closing brace of the catch block in MoveNextAsync: that catch always ends with 'throw;', so the sequence point for falling through the catch normally can never fire.
…lify the flush wait
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2339 +/- ##
==========================================
+ Coverage 99.93% 99.97% +0.03%
==========================================
Files 217 217
Lines 11531 11528 -3
Branches 2223 2221 -2
==========================================
+ Hits 11524 11525 +1
+ Misses 7 3 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Summary
The typed JSON Lines code from #2338 is fully covered, and its flush wait no longer needs a catch block.
JsonLinesContent<T>waits on the flush and the producer's pending step together withTask.WhenAll, so a failed flush still lets the producer's step finish before the exception propagates and the enumerator is disposed. Behaviour is unchanged; the unreachable catch-block exit is gone.IAsyncEnumerable<T>and a type implementing two of them in the reflection builder's element lookup, a flush that fails while the producer's step is pending, and the token-less serialize override that .NET Framework calls.Why
#2338 merged below the repository's 100% patch coverage target. These commits landed on its branch after the merge.
Breaking changes
None.
How this was verified
Tests cover every new line of
JsonLinesContent<T>and the reflection builder's JSON Lines lookup on .NET 8 and later.Notes for the reviewer
The only production change is
JsonLinesContent<T>.MoveNextAsyncand its smallFlushAsynchelper; the rest is tests.FlushAsyncis awaited on purpose so a synchronous throw fromStream.FlushAsyncbecomes a faulted task thatTask.WhenAllobserves.HttpContenton .NET 8 and later always calls the cancellable overload.Checklist