{"record":{"id":"73950ae8b3053ff5","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-resultselector-73950a","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'resultSelector')","messagePattern":"Value cannot be null\\. \\(Parameter 'resultSelector'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.StandardSequenceOperators.cs","lineNumber":866,"sourceCode":"\n            if (right == null)\n            {\n                throw new ArgumentNullException(nameof(right));\n            }\n\n            if (leftDurationSelector == null)\n            {\n                throw new ArgumentNullException(nameof(leftDurationSelector));\n            }\n\n            if (rightDurationSelector == null)\n            {\n                throw new ArgumentNullException(nameof(rightDurationSelector));\n            }\n\n            if (resultSelector == null)\n            {\n                throw new ArgumentNullException(nameof(resultSelector));\n            }\n\n            return s_impl.GroupJoin(left, right, leftDurationSelector, rightDurationSelector, resultSelector);\n        }\n\n        #endregion\n\n        #region + Join +\n\n        /// <summary>\n        /// Correlates the elements of two sequences based on overlapping durations.\n        /// </summary>\n        /// <typeparam name=\"TLeft\">The type of the elements in the left source sequence.</typeparam>\n        /// <typeparam name=\"TRight\">The type of the elements in the right source sequence.</typeparam>\n        /// <typeparam name=\"TLeftDuration\">The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence.</typeparam>\n        /// <typeparam name=\"TRightDuration\">The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence.</typeparam>\n        /// <typeparam name=\"TResult\">The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration.</typeparam>\n        /// <param name=\"left\">The left observable sequence to join elements for.</param>","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.StandardSequenceOperators.cs#L848-L884","documentation":"GroupJoin threw ArgumentNullException because the resultSelector delegate was null. The result selector combines each left element with the observable of overlapping right elements; the public operator validates it synchronously.","triggerScenarios":"Calling left.GroupJoin(right, leftDurationSelector, rightDurationSelector, null) — e.g. a projection lambda stored in a nullable Func field or forwarded parameter.","commonSituations":"Dynamic query building where the projection is optional; storing lambdas in configuration; refactoring that left the result selector parameter unfilled.","solutions":["Pass a non-null result selector, e.g. (l, rights) => ... .","Null-check the delegate before the call and fail with context.","If projection should be identity-like, write an explicit lambda rather than null."],"exampleFix":"// before\nvar joined = left.GroupJoin(right, l => l.Window(), r => r.Window(), _projector); // null\n// after\nvar joined = left.GroupJoin(right, l => l.Window(), r => r.Window(), (l, rights) => new Pair(l, rights));","handlingStrategy":"validation","validationCode":"if (resultSelector == null)\n    throw new ArgumentException(\"resultSelector is required to combine joined streams.\", nameof(resultSelector));","typeGuard":"bool HasResultSelector<TLeft,TRight,TResult>(Func<TLeft, IObservable<TRight>, TResult>? f) => f is not null;","tryCatchPattern":"try\n{\n    var joined = left.GroupJoin(right, ld, rd, resultSelector);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"resultSelector\")\n{\n    // supply a default projection\n}","preventionTips":["Write result selectors inline at the call site.","Never model 'no projection' as null; write an explicit combining lambda.","Type projection delegate fields as non-nullable and initialize them at construction."],"tags":["null-argument","linq","reactive-extensions","groupjoin"],"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"}