{"record":{"id":"9c844a90a0435a4f","repo":"dotnet/reactive","slug":"continuation","errorCode":null,"errorMessage":"continuation","messagePattern":"continuation","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs","lineNumber":360,"sourceCode":"\n        #region Await support\n\n        /// <summary>\n        /// Gets an awaitable object for the current AsyncSubject.\n        /// </summary>\n        /// <returns>Object that can be awaited.</returns>\n        public AsyncSubject<T> GetAwaiter() => this;\n\n        /// <summary>\n        /// Specifies a callback action that will be invoked when the subject completes.\n        /// </summary>\n        /// <param name=\"continuation\">Callback action that will be invoked when the subject completes.</param>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"continuation\"/> is <c>null</c>.</exception>\n        public void OnCompleted(Action continuation)\n        {\n            if (continuation == null)\n            {\n                throw new ArgumentNullException(nameof(continuation));\n            }\n\n            //\n            // [OK] Use of unsafe Subscribe: this type's Subscribe implementation is safe.\n            //\n            Subscribe/*Unsafe*/(new AwaitObserver(continuation));\n        }\n\n        private sealed class AwaitObserver : IObserver<T>\n        {\n            private readonly SynchronizationContext? _context;\n            private readonly Action _callback;\n\n            public AwaitObserver(Action callback)\n            {\n                _context = SynchronizationContext.Current;\n                _callback = callback;\n            }","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Subjects/AsyncSubject.cs#L342-L378","documentation":"The AsyncSubject.OnCompleted(Action continuation) overload throws ArgumentNullException when the continuation callback is null. The continuation is wrapped in an AwaitObserver and invoked when the subject completes, so it must be a real delegate.","triggerScenarios":"Calling AsyncSubject<T>.OnCompleted((Action)null) to await subject completion with a callback.","commonSituations":"Async/await bridging code where a callback variable is uninitialized or conditionally assigned.","solutions":["Always supply a non-null continuation; use an empty lambda () => {} if no action is needed.","Prefer await subject over the callback overload when using async/await.","Null-check the callback before invoking OnCompleted."],"exampleFix":"// before\nsubject.OnCompleted(callback); // callback may be null\n// after\nsubject.OnCompleted(callback ?? (System.Action)(() => { }));","handlingStrategy":"validation","validationCode":"if (continuation == null) continuation = () => { };\nsubject.OnCompleted(continuation);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use await subject instead of the callback overload when possible.","Substitute an empty lambda when no continuation work is needed."],"tags":["argument-null","rx","async-await"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}