{"record":{"id":"8bc69fbb0b6a1f4c","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-actionasync","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'actionAsync')","messagePattern":"Value cannot be null\\. \\(Parameter 'actionAsync'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs","lineNumber":1281,"sourceCode":"        }\n\n        /// <summary>\n        /// Invokes the asynchronous action, surfacing the result through an observable sequence.\n        /// </summary>\n        /// <param name=\"actionAsync\">Asynchronous action to run.</param>\n        /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"actionAsync\"/> is null.</exception>\n        /// <remarks>\n        /// <list type=\"bullet\">\n        /// <item><description>The action is started immediately, not during the subscription of the resulting sequence.</description></item>\n        /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>\n        /// </list>\n        /// </remarks>\n        public static IObservable<Unit> StartAsync(Func<Task> actionAsync)\n        {\n            if (actionAsync == null)\n            {\n                throw new ArgumentNullException(nameof(actionAsync));\n            }\n\n            return s_impl.StartAsync(actionAsync);\n        }\n\n        /// <summary>\n        /// Invokes the asynchronous action, surfacing the result through an observable sequence.\n        /// </summary>\n        /// <param name=\"actionAsync\">Asynchronous action to run.</param>\n        /// <param name=\"scheduler\">Scheduler on which to notify observers.</param>\n        /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"actionAsync\"/> is null or <paramref name=\"scheduler\"/> is null.</exception>\n        /// <remarks>\n        /// <list type=\"bullet\">\n        /// <item><description>The action is started immediately, not during the subscription of the resulting sequence.</description></item>\n        /// <item><description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description></item>\n        /// </list>\n        /// </remarks>","sourceCodeStart":1263,"sourceCodeEnd":1299,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs#L1263-L1299","documentation":"Observable.StartAsync(Func<Task>) schedules the provided async function on the default concurrency scheduler and converts it into IObservable<Unit>. A null 'actionAsync' delegate throws ArgumentNullException at call time. The check happens eagerly so the failure is attributed to the caller, not to a later subscription.","triggerScenarios":"Calling Observable.StartAsync(Func<Task>) with a null delegate: an unassigned Func<Task> field, a factory method returning null, or a conditional lambda assignment with a missing branch.","commonSituations":"Passing a method group whose instance is null, DI/config-resolved delegates that were never registered, or refactorings that moved the async lambda into a nullable property.","solutions":["Pass a non-null async lambda or method group to StartAsync.","Guard the nullable delegate source with an explicit throw or fallback before the call.","Register the Func<Task> in DI/config if that is where it comes from."],"exampleFix":"// before\nFunc<Task> work = _workField; // may be null\nvar xs = Observable.StartAsync(work);\n// after\nvar work = _workField ?? throw new InvalidOperationException(\"work not set\");\nvar xs = Observable.StartAsync(work);","handlingStrategy":"validation","validationCode":"if (actionAsync is null)\n    throw new ArgumentNullException(nameof(actionAsync));\nObservable.StartAsync(actionAsync);","typeGuard":"bool IsValidDelegate<T>(T? d) where T : Delegate => d is not null;","tryCatchPattern":"try\n{\n    var xs = Observable.StartAsync(actionAsync);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"actionAsync\")\n{\n    // log: async delegate was null\n}","preventionTips":["Pass async lambdas inline rather than storing them in nullable fields.","Validate Func<Task> sources at assignment time.","Ensure DI registrations exist for async factories."],"tags":["csharp","rx","argument-null","async"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}