{"record":{"id":"ece677f5be5882bd","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source5-observable-multiple","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source5')","messagePattern":"Value cannot be null\\. \\(Parameter 'source5'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs","lineNumber":138,"sourceCode":"\n            if (source2 == null)\n            {\n                throw new ArgumentNullException(nameof(source2));\n            }\n\n            if (source3 == null)\n            {\n                throw new ArgumentNullException(nameof(source3));\n            }\n\n            if (source4 == null)\n            {\n                throw new ArgumentNullException(nameof(source4));\n            }\n\n            if (source5 == null)\n            {\n                throw new ArgumentNullException(nameof(source5));\n            }\n\n            if (resultSelector == null)\n            {\n                throw new ArgumentNullException(nameof(resultSelector));\n            }\n\n            return s_impl.CombineLatest(source1, source2, source3, source4, source5, resultSelector);\n        }\n\n        /// <summary>\n        /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.\n        /// </summary>\n        /// <typeparam name=\"TSource1\">The type of the elements in the first source sequence.</typeparam>\n        /// <typeparam name=\"TSource2\">The type of the elements in the second source sequence.</typeparam>\n        /// <typeparam name=\"TSource3\">The type of the elements in the third source sequence.</typeparam>\n        /// <typeparam name=\"TSource4\">The type of the elements in the fourth source sequence.</typeparam>\n        /// <typeparam name=\"TSource5\">The type of the elements in the fifth source sequence.</typeparam>","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.CombineLatest.cs#L120-L156","documentation":"Observable.CombineLatest (5-source overload) throws ArgumentNullException when the resultSelector delegate is null. The selector combines the latest value of each of the five sources into a result; Rx checks it eagerly at call time with parameter name 'resultSelector'.","triggerScenarios":"Calling Observable.CombineLatest(s1, s2, s3, s4, s5, null) — e.g. the selector was computed at runtime, returned null from a factory, or a conditional expression like (useA ? selA : selB) yielded null.","commonSituations":"Building query DSLs where the projection is optional; reflection-based or config-driven composition where the selector method name failed to resolve to a delegate; nullable Func fields not yet initialized.","solutions":["Pass a concrete non-null Func<TSource1,...,TSource5,TResult> as the last argument","If the projection is optional, supply a default projection (e.g. tuple or array of latest values) instead of null","Check the code path that builds the selector and make it return a fallback delegate rather than null","Validate the selector before composing: if (resultSelector == null) throw new InvalidOperationException(\"No projection configured\")"],"exampleFix":"// before\nFunc<int, int, int, int, int, string> selector = _config.Mode == \"sum\" ? Sum : null;\nvar combined = Observable.CombineLatest(a, b, c, d, e, selector); // throws in default mode\n\n// after\nFunc<int, int, int, int, int, string> selector = _config.Mode == \"sum\" ? Sum : Default;\nvar combined = Observable.CombineLatest(a, b, c, d, e, selector);","handlingStrategy":"validation","validationCode":"if (resultSelector is null) throw new ArgumentNullException(nameof(resultSelector));\nvar combined = Observable.CombineLatest(source1, source2, source3, source4, source5, resultSelector);","typeGuard":"static bool IsUsable<T1,T2,T3,T4,T5,TResult>(Func<T1,T2,T3,T4,T5,TResult>? f) => f is not null;","tryCatchPattern":"try\n{\n    combined = Observable.CombineLatest(s1, s2, s3, s4, s5, resultSelector);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"resultSelector\")\n{\n    resultSelector = DefaultProjection;\n    combined = Observable.CombineLatest(s1, s2, s3, s4, s5, resultSelector);\n}","preventionTips":["Always provide a concrete projection; use _ => default or a tuple builder when no transformation is needed","When resolving selectors dynamically, fall back to a default delegate rather than null","Type nullable Func fields and coalesce at use site: selector ?? DefaultSelector","Cover selector-resolution branches with tests so null paths are caught early"],"tags":["rx","null-argument","combine-latest","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"}