Repository navigation
Throw argument exceptions synchronously in Core's Task extensions - #181
Merged
Merged
Conversation
EnsureSuccessAsync, MapAsync and BindAsync on Task<...> were async and checked their arguments inside, so a null task or delegate came back as a faulted task. They now check their arguments and return the task of a private async method. ADR-0002 extends the synchronous rule to every public method of a public type that returns a task; CLAUDE.md, reviewer.md and CONTRIBUTING follow. Null-argument tests of the task-returning methods now assert a synchronous throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeQL cs/useless-upcast: MapAsync has one overload, so explicit type arguments replace the cast of null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 30, 2026
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 #159
What
EnsureSuccessAsync(both overloads),MapAsyncandBindAsync(both overloads) inOpenUrzednikResultExtensionsare no longerasync: they check their arguments and return the task of a private…CoreAsyncmethod, so anulltask or delegate throwsArgumentNullExceptionat the call instead of faulting the returned task. XML docs list the exception.2026-10-30): the synchronous argument-exception rule now covers every public method of a public type that returns a task, not only provider clients. The rule states the requirement (notasync, check before creating the task); the private…CoreAsyncmethod is the usual way. CLAUDE.md, reviewer.md and CONTRIBUTING follow.OpenUrzednikResult.BindAsync. The existing null tests ofOpenUrzednikResult<T>.BindAsyncandNbpDateOnlyExtensionsusedThrowAsyncor an expression lambda, which also pass on a faulted task; they now useShould.Throw(() => { _ = …; }), which passes only on a synchronous throw.Breaking change
Callers who observed the
ArgumentNullExceptionon the returned task now get it from the call. Signatures are unchanged.Checks
dotnet build: 0 warnings, 0 errors-f net10.0tests, all projects: pass (Core 171, Nbp 567, Http 93, Logging 38, Diagnostics 23, DI 18, Integration 91 + 21 explicit not run)-f net472: 171 passdotnet format --verify-no-changes: cleandotnet pack OpenUrzednik.Packages.slnf -c Releasewith package validation: passrevieweragent: no blocking findings; its test and wording points are applied🤖 Generated with Claude Code