{"record":{"id":"6a8155da07ade2d3","repo":"dotnet/reactive","slug":"first-qbservableex-homoicon","errorCode":null,"errorMessage":"first","messagePattern":"first","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs","lineNumber":35,"sourceCode":"\nnamespace System.Reactive.Linq\n{\n    public static partial class QbservableEx\n    {\n        /// <summary>\n        /// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element.\n        /// </summary>\n        /// <typeparam name=\"TFirst\">The type of the elements in the first source sequence.</typeparam>\n        /// <typeparam name=\"TSecond\">The type of the elements in the second source sequence.</typeparam>\n        /// <param name=\"first\">First observable source.</param>\n        /// <param name=\"second\">Second observable source.</param>\n        /// <returns>An observable sequence containing the result of combining elements of the sources using tuple values.</returns>\n        /// <exception cref=\"ArgumentNullException\">\n        /// <paramref name=\"first\" /> or <paramref name=\"second\" /> is null.</exception>\n        public static IQbservable<(TFirst First, TSecond Second)> CombineLatest<TFirst, TSecond>(this IQbservable<TFirst> first, IObservable<TSecond> second)\n        {\n            if (first == null)\n                throw new ArgumentNullException(nameof(first));\n            if (second == null)\n                throw new ArgumentNullException(nameof(second));\n\n            return first.Provider.CreateQuery<(TFirst First, TSecond Second)>(\n                Expression.Call(\n                    null,\n                    new Func<IQbservable<TFirst>, IObservable<TSecond>, IQbservable<(TFirst First, TSecond Second)>>(CombineLatest<TFirst, TSecond>).Method,\n                    first.Expression,\n                    GetSourceExpression(second)\n                )\n            );\n        }\n\n        /// <summary>\n        /// Merges the specified observable sequences into one observable sequence of tuple values whenever any of the observable sequences produces an element.\n        /// </summary>\n        /// <typeparam name=\"TFirst\">The type of the elements in the first source sequence.</typeparam>\n        /// <typeparam name=\"TSecond\">The type of the elements in the second source sequence.</typeparam>","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs#L17-L53","documentation":"QbservableEx.CombineLatest<TFirst,TSecond>(IQbservable<TFirst>, IObservable<TSecond>) throws ArgumentNullException when the first (qbservable) source is null. The method uses first.Provider and first.Expression to build the resulting query, so a null first sequence is rejected before expression construction.","triggerScenarios":"Calling first.CombineLatest(second) where first is a null IQbservable<TFirst>; e.g. a pipeline stage that produced null instead of a qbservable, or passing null as the first argument of the static call.","commonSituations":"Conditional query construction where the first branch was skipped; mocks in tests returning null; chaining off results of provider.CreateQuery paths that failed silently upstream.","solutions":["Ensure the primary qbservable source is produced by a valid IQbservableProvider before combining.","Null-check first (and second) before calling CombineLatest.","If the first source can be absent, substitute an empty/never qbservable or restructure so a non-null source always exists."],"exampleFix":"// before\nIQbservable<int> first = null;\nvar combined = first.CombineLatest(second);\n// after\nvar first = provider.FromNumbers();\nvar combined = first.CombineLatest(second);","handlingStrategy":"validation","validationCode":"if (first is null || second is null) throw new InvalidOperationException(\"CombineLatest requires non-null first and second sources.\");","typeGuard":"static bool IsCombinable<T>(IQbservable<T> q) => q is not null && q.Provider is not null;","tryCatchPattern":"try { var combined = first.CombineLatest(second); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"first\") { /* rebuild the primary qbservable */ }","preventionTips":["Build qbservable sources through providers only; avoid nullable source variables.","Default optional sources to Observable.Never instead of null.","Cover stream-construction branches with tests so null producers fail in CI."],"tags":["csharp","null-reference","argument-validation","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-15T23:17:13.987Z"}