{"record":{"id":"c567be994be0af38","repo":"dotnet/reactive","slug":"progressselector-parameter-progressselector","errorCode":null,"errorMessage":"progressSelector (Parameter 'progressSelector')","messagePattern":"progressSelector \\(Parameter 'progressSelector'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Platforms/WinRT/Linq/AsyncInfoObservable.cs","lineNumber":83,"sourceCode":"        /// Creates a Windows Runtime asynchronous action that represents the completion of the observable sequence, using a selector function to map the source sequence on a progress reporting 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        /// <typeparam name=\"TProgress\">The type of the elements in the progress sequence.</typeparam>\n        /// <param name=\"source\">Source sequence to expose as an asynchronous action and to compute a progress sequence that gets reported through the asynchronous action.</param>\n        /// <param name=\"progressSelector\">Selector function to map the source sequence on a progress reporting sequence.</param>\n        /// <returns>Windows Runtime asynchronous action object representing the completion of the result sequence, reporting progress computed through the progress sequence.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"source\"/> or <paramref name=\"progressSelector\"/> is null.</exception>\n        public static IAsyncActionWithProgress<TProgress> ToAsyncActionWithProgress<TSource, TProgress>(this IObservable<TSource> source, Func<IObservable<TSource>, IObservable<TProgress>> progressSelector)\n        {\n            if (source == null)\n            {\n                throw new ArgumentNullException(nameof(source));\n            }\n\n            if (progressSelector == null)\n            {\n                throw new ArgumentNullException(nameof(progressSelector));\n            }\n\n            return AsyncInfo.Run<TProgress>((ct, progress) =>\n            {\n                return Observable.Create<TSource?>(observer =>\n                {\n                    var obs = Observer.Synchronize(observer);\n\n                    var data = source.Publish();\n\n                    var progressSubscription = progressSelector(data).Subscribe(progress.Report, obs.OnError);\n                    var dataSubscription = data.DefaultIfEmpty().Subscribe(obs);\n                    var connection = data.Connect();\n\n                    return StableCompositeDisposable.CreateTrusted(progressSubscription, dataSubscription, connection);\n                }).ToTask(ct);\n            });\n        }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Platforms/WinRT/Linq/AsyncInfoObservable.cs#L65-L101","documentation":"This ToAsyncActionWithProgress overload throws ArgumentNullException named 'progressSelector' when the supplied progressSelector function is null. The selector defines how source elements map to progress values reported through the WinRT progress handler.","triggerScenarios":"Calling source.ToAsyncActionWithProgress(null) or passing a nullable Func variable that was never assigned.","commonSituations":"Building the selector dynamically (e.g. from config or reflection) and the construction silently produced null; or forwarding an optional parameter straight through.","solutions":["Provide a valid progressSelector, e.g. o => o.Select((_, i) => i) for count-based progress","Guard the selector argument before the call if it is optional and fall back to a default selector","Fix the code path that yields a null Func"],"exampleFix":"// before\nsource.ToAsyncActionWithProgress(progressSelector); // progressSelector is null\n// after\nsource.ToAsyncActionWithProgress(progressSelector ?? (o => o.Select((_, i) => (int)i)));","handlingStrategy":"validation","validationCode":"if (progressSelector == null) throw new ArgumentNullException(nameof(progressSelector));","typeGuard":"static bool IsValidSelector<TSource,TProgress>(Func<IObservable<TSource>, IObservable<TProgress>>? selector) => selector is not null;","tryCatchPattern":"try { op = source.ToAsyncActionWithProgress(selector); } catch (ArgumentNullException ex) when (ex.ParamName == \"progressSelector\") { /* supply default selector */ }","preventionTips":["Provide default selectors when the argument is optional","Avoid building delegates via reflection without null checks","Use nullable annotations (Func<...>?) to make nullability explicit"],"tags":["null-argument","argumentnull","winrt","progress"],"backgroundTag":"missing-required-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"}