{"record":{"id":"93cfa11821266a27","repo":"dotnet/reactive","slug":"throw-new-argumentnullexception-nameof-sources","errorCode":null,"errorMessage":"throw new ArgumentNullException(nameof(sources))","messagePattern":"throw new ArgumentNullException\\(nameof\\(sources\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs","lineNumber":1087,"sourceCode":"#endif\n\n#if !STABLE\n        /// <summary>\n        /// Runs all specified observable sequences in parallel and collects their last elements.\n        /// </summary>\n        /// <param name=\"provider\">Query provider used to construct the <see cref=\"IQbservable{T}\"/> data source.</param>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequences.</typeparam>\n        /// <param name=\"sources\">Observable sequence to collect the last elements for.</param>\n        /// <returns>An observable sequence with an array collecting the last elements of all the input sequences.</returns>\n        /// <exception cref=\"ArgumentNullException\">\n        /// <paramref name=\"sources\" /> is null.</exception>\n        [Experimental]\n        public static IQbservable<TSource[]> ForkJoin<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)\n        {\n            if (provider == null)\n                throw new ArgumentNullException(nameof(provider));\n            if (sources == null)\n                throw new ArgumentNullException(nameof(sources));\n\n            return provider.CreateQuery<TSource[]>(\n                Expression.Call(\n                    null,\n                    new Func<IQbservableProvider, IObservable<TSource>[], IQbservable<TSource[]>>(ForkJoin<TSource>).Method,\n                    Expression.Constant(provider, typeof(IQbservableProvider)),\n                    GetSourceExpression(sources)\n                )\n            );\n        }\n#endif\n\n#if !STABLE\n        /// <summary>\n        /// Runs all observable sequences in the enumerable sources sequence in parallel and collect their last elements.\n        /// </summary>\n        /// <param name=\"provider\">Query provider used to construct the <see cref=\"IQbservable{T}\"/> data source.</param>\n        /// <typeparam name=\"TSource\">The type of the elements in the source sequences.</typeparam>","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs#L1069-L1105","documentation":"ForkJoin(params IObservable<TSource>[]) throws ArgumentNullException when the sources array itself is null (as opposed to empty, which is allowed). The guard exists before building the MethodCallExpression so the expression tree has a valid arguments array.","triggerScenarios":"Calling provider.ForkJoin(null) where the null literal or null array variable is passed for the params sources parameter.","commonSituations":"Passing a null IObservable<TSource>[] variable, or forwarding a null collection converted with .ToArray() from a null source list.","solutions":["Pass at least one non-null observable or an empty array instead of null","Check the array for null before calling ForkJoin","Ensure the upstream list used to build the array is non-null"],"exampleFix":"// before\nprovider.ForkJoin((IObservable<int>[])null);\n// after\nprovider.ForkJoin(new IObservable<int>[] { src1, src2 });","handlingStrategy":"validation","validationCode":"if (sources is null) throw new ArgumentNullException(nameof(sources));","typeGuard":"bool IsValidSources(IObservable<T>[] s) => s is not null;","tryCatchPattern":"try { var q = provider.ForkJoin(sources); } catch (ArgumentNullException ex) when (ex.ParamName == \"sources\") { /* handle null sources */ }","preventionTips":["Pass an empty array instead of null when there are no sources","Null-check arrays built from external lists before passing them"],"tags":["csharp","null-argument","rx","qbservable"],"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"}