{"record":{"id":"3d27331395a9cf9e","repo":"dotnet/reactive","slug":"action-observable-async","errorCode":null,"errorMessage":"action","messagePattern":"action","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs","lineNumber":3519,"sourceCode":"        /// <typeparam name=\"TArg6\">The type of the sixth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg7\">The type of the seventh argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg8\">The type of the eighth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg9\">The type of the ninth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg10\">The type of the tenth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg11\">The type of the eleventh argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg12\">The type of the twelfth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg13\">The type of the thirteenth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg14\">The type of the fourteenth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg15\">The type of the fifteenth argument passed to the action.</typeparam>\n        /// <param name=\"action\">Action to convert to an asynchronous action.</param>\n        /// <param name=\"scheduler\">Scheduler to invoke the original action on.</param>\n        /// <returns>Asynchronous action.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"action\"/> or <paramref name=\"scheduler\"/> is null.</exception>\n        public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IObservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(this Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15> action, IScheduler scheduler)\n        {\n            if (action == null)\n            {\n                throw new ArgumentNullException(nameof(action));\n            }\n\n            if (scheduler == null)\n            {\n                throw new ArgumentNullException(nameof(scheduler));\n            }\n\n            return s_impl.ToAsync(action, scheduler);\n        }\n\n        /// <summary>\n        /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.\n        /// </summary>\n        /// <typeparam name=\"TArg1\">The type of the first argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg2\">The type of the second argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg3\">The type of the third argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg4\">The type of the fourth argument passed to the action.</typeparam>\n        /// <typeparam name=\"TArg5\">The type of the fifth argument passed to the action.</typeparam>","sourceCodeStart":3501,"sourceCodeEnd":3537,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Async.cs#L3501-L3537","documentation":"The scheduler-taking 15-argument ToAsync overload throws ArgumentNullException with parameter name 'action' when the delegate is null. When calling the two-parameter form, both 'action' and 'scheduler' are validated, and 'action' is checked first, so this error fires before the scheduler is even examined.","triggerScenarios":"Calling Observable.ToAsync(action, scheduler) (15-arg Action overload) with a null delegate, regardless of whether the scheduler is valid.","commonSituations":"Same as the single-argument overload: dynamic delegate resolution returning null, uninitialized delegate fields, or method groups lost through conditional logic.","solutions":["Supply a non-null Action<...> delegate as the first argument.","Null-check the delegate before invoking ToAsync.","If both may be null, fix the delegate first - the check order means the scheduler error would be masked.","Substitute a default delegate when resolution fails."],"exampleFix":"// before\nObservable.ToAsync(null, Scheduler.Default);\n// after\nObservable.ToAsync(myAction, Scheduler.Default);","handlingStrategy":"validation","validationCode":"if (action == null || scheduler == null) throw new ArgumentNullException(action == null ? nameof(action) : nameof(scheduler));","typeGuard":"bool ValidArgs(Action<...> a, IScheduler s) => a != null && s != null;","tryCatchPattern":"try { Observable.ToAsync(action, scheduler); } catch (ArgumentNullException ex) when (ex.ParamName == \"action\") { /* fix delegate */ }","preventionTips":["Validate both arguments at the call site since 'action' is checked first and can mask the scheduler error","Use named arguments (action:, scheduler:) to make argument order mistakes obvious","Build wrappers around ToAsync that apply defaults for both parameters"],"tags":["csharp","rx","null-argument","delegate"],"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"}