{"record":{"id":"06c06d76af14c80a","repo":"dotnet/reactive","slug":"provider","errorCode":null,"errorMessage":"provider","messagePattern":"provider","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs","lineNumber":90,"sourceCode":"                    source.Expression,\n                    selector\n                )\n            );\n        }\n\n        /// <summary>\n        /// Joins together the results from several patterns.\n        /// </summary>\n        /// <typeparam name=\"TResult\">The type of the elements in the result sequence, obtained from the specified patterns.</typeparam>\n        /// <param name=\"provider\">Query provider used to construct the <see cref=\"IQbservable{T}\"/> data source.</param>\n        /// <param name=\"plans\">A series of plans created by use of the Then operator on patterns.</param>\n        /// <returns>An observable sequence with the results from matching several patterns.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"provider\"/> or <paramref name=\"plans\"/> is null.</exception>\n        public static IQbservable<TResult> When<TResult>(this IQbservableProvider provider, params QueryablePlan<TResult>[] plans)\n        {\n            if (provider == null)\n            {\n                throw new ArgumentNullException(nameof(provider));\n            }\n\n            if (plans == null)\n            {\n                throw new ArgumentNullException(nameof(plans));\n            }\n\n            return provider.CreateQuery<TResult>(\n                Expression.Call(\n                    null,\n                    new Func<IQbservableProvider, QueryablePlan<TResult>[], IQbservable<TResult>>(When).Method,\n                    Expression.Constant(provider, typeof(IQbservableProvider)),\n                    Expression.NewArrayInit(\n                        typeof(QueryablePlan<TResult>),\n                        plans.Select(p => p.Expression)\n                    )\n                )\n            );","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Joins.cs#L72-L108","documentation":"When<TResult>(plans) is an extension on IQbservableProvider that matches a set of QueryablePlan objects; the provider itself must be non-null. The method throws ArgumentNullException(\"provider\") when the receiver is null, since CreateQuery cannot be invoked on a null provider. The check precedes building the Expression.Call for the When operator.","triggerScenarios":"Calling When(plans) through a null IQbservableProvider reference, or invoking the static method with provider: null explicitly.","commonSituations":"Using an IQbservableProvider obtained from a service locator or test harness that returned null instead of a real provider (e.g. TestScheduler-backed or remote provider).","solutions":["Obtain a valid IQbservableProvider instance (e.g. from your Rx query service) before calling When.","Verify the DI registration that supplies the provider.","Guard with a null check and fail with a clearer application-level message if the provider is unavailable."],"exampleFix":"// before\nIQbservableProvider provider = ResolveProvider(); // null\nvar result = provider.When(plan1, plan2);\n// after\nIQbservableProvider provider = ResolveProvider() ?? throw new InvalidOperationException(\"No IQbservableProvider configured\");\nvar result = provider.When(plan1, plan2);","handlingStrategy":"validation","validationCode":"if (provider is null) throw new InvalidOperationException(\"No IQbservableProvider configured\");\nvar result = provider.When(plans);","typeGuard":"bool HasProvider(IQbservableProvider? p) => p is not null;","tryCatchPattern":"try { var result = provider.When(plans); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"provider\") { throw new InvalidOperationException(\"Provider not initialized\", ex); }","preventionTips":["Register and resolve IQbservableProvider through DI and validate at startup","Do not call qbservable extension methods on possibly-null receiver variables","Use TestScheduler-based providers in tests rather than null stand-ins"],"tags":["argument-null","qbservable-provider","when-operator","rx","dotnet"],"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"}