Repository navigation
feat: assertions on a Task or ValueTask, and CMTK0003 reports one left unawaited - #95
Merged
Merged
Conversation
…t unawaited Every assertion of CodoMetis.TypeKit.Testing has a form on a Task and on a ValueTask of what it checks, beside its synchronous form: it awaits the task and answers as the synchronous form does, the same content back and the same message. A task that faults propagates its own exception, and a null task is refused by the parameter's name. An assertion on a task fails the test only through the task it returns, so `service.FindAsync(id).ShouldBeSome();` without await passed whatever the task held, and C# warns only in an async method. CMTK0003 reports such a statement, through ConfigureAwait and in a lambda's body too. It knows the assertions by the Testing assembly's identity, as it knows the Generators assembly, so a consumer's own extension on a pending result stays silent: every reported call is new in 2.3, and no build that worked before breaks. The C20 seed whichever-of-its-types is regenerated against the new FaultAssertions.cs. Closes #87 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
The changelog keeps every entry and the roadmap drops both items; the prober seed this branch edited is deleted, as #108 retired the prober. Co-Authored-By: Claude Opus 5.5 <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 #87
Problem
The Testing assertions worked only on a value the test already held, so a test of an async method wrote
(await service.Find(id)).ShouldBeSuccess(). An async form adds a trap of its own. It fails the test only through the task it returns, soservice.FindAsync(id).ShouldBeSome();left withoutawaitpasses whatever the task holds. C# warns about that only inside anasyncmethod.Change
Taskand aValueTaskform, placed next to its synchronous form. Each awaits the task and then answers as the synchronous form does, with the same content back and the same message. A task that throws propagates its own exception. A null task is refused, naming the parameter. Every form returnsTask, as the core package's asynchronous members do.await, including throughConfigureAwaitand in a lambda's body. The rule knows the assertions by the Testing assembly's identity, as it already knows.Generators. So a consumer's own extension on a pending result is not reported. Every call it reports is new in 2.3, so the Error severity breaks no build that worked before.docs/testing.md, the changelog. The roadmap item is removed.whichever-of-its-typesis regenerated against the newFaultAssertions.cs.Tests
AsyncAssertionTests:Taskand a pendingValueTask, on inputs it passes and fails.TaskorTask<T>of what the synchronous form returns.IgnoredOutcomeAnalyzerTests, against the real Testing assembly:asyncand in one that is, throughConfigureAwait, and in a lambda.Taskform that doesn't assert.🤖 Generated with Claude Code