{"record":{"id":"fb174b679bb205a1","repo":"dotnet/reactive","slug":"source-parameter-source-asyncinfoobservable","errorCode":null,"errorMessage":"source (Parameter 'source')","messagePattern":"source \\(Parameter 'source'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Platforms/WinRT/Linq/AsyncInfoObservable.cs","lineNumber":34,"sourceCode":"    /// </summary>\n    [CLSCompliant(false)]\n    public static class AsyncInfoObservable\n    {\n        #region IAsyncAction\n\n        /// <summary>\n        /// Creates a Windows Runtime asynchronous action that represents the completion of the observable sequence.\n        /// Upon cancellation of the asynchronous action, the subscription to the source sequence will be disposed.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence.</typeparam>\n        /// <param name=\"source\">Source sequence to expose as an asynchronous action.</param>\n        /// <returns>Windows Runtime asynchronous action object representing the completion of the observable sequence.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> is null.</exception>\n        public static IAsyncAction ToAsyncAction<TSource>(this IObservable<TSource> source)\n        {\n            if (source == null)\n            {\n                throw new ArgumentNullException(nameof(source));\n            }\n\n            return AsyncInfo.Run(ct => (Task)source.DefaultIfEmpty().ToTask(ct));\n        }\n\n        #region Progress\n\n        /// <summary>\n        /// Creates a Windows Runtime asynchronous action that represents the completion of the observable sequence, reporting incremental progress for each element produced by the sequence.\n        /// Upon cancellation of the asynchronous action, the subscription to the source sequence will be disposed.\n        /// </summary>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequence.</typeparam>\n        /// <param name=\"source\">Source sequence to expose as an asynchronous action.</param>\n        /// <returns>Windows Runtime asynchronous action object representing the completion of the observable sequence, reporting incremental progress for each source sequence element.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> is null.</exception>\n        public static IAsyncActionWithProgress<int> ToAsyncActionWithProgress<TSource>(this IObservable<TSource> source)\n        {\n            if (source == null)","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Platforms/WinRT/Linq/AsyncInfoObservable.cs#L16-L52","documentation":"The ToAsyncAction extension method converts an IObservable<TSource> into a WinRT IAsyncAction. It throws ArgumentNullException with parameter name 'source' when called on a null observable, because there is nothing to convert.","triggerScenarios":"Invoking source.ToAsyncAction() where source is a null IObservable<TSource> reference.","commonSituations":"Chaining conversions from a nullable field/return value, e.g. a factory method that returned null before the conversion, or a misconfigured service locator yielding null.","solutions":["Check that the observable is non-null before calling ToAsyncAction","Use the null-coalescing operator to supply a default (e.g. Observable.Empty<TSource>())","Fix the upstream code that produced the null observable"],"exampleFix":"// before\nvar action = maybeNull.ToAsyncAction();\n// after\nvar action = (maybeNull ?? Observable.Empty<TSource>()).ToAsyncAction();","handlingStrategy":"validation","validationCode":"if (source == null) throw new ArgumentNullException(nameof(source));","typeGuard":"static bool IsValidSource<TSource>(IObservable<TSource>? source) => source is not null;","tryCatchPattern":"try { action = source.ToAsyncAction(); } catch (ArgumentNullException ex) when (ex.ParamName == \"source\") { action = Observable.Empty<TSource>().ToAsyncAction(); }","preventionTips":["Never return null observables — return Observable.Empty instead","Enable nullable reference types to catch nulls at compile time","Null-check inputs at API boundaries before conversions"],"tags":["null-argument","argumentnull","winrt","extension-method"],"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"}