{"record":{"id":"7b88efe0cec71fe9","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source-all","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source')","messagePattern":"Value cannot be null\\. \\(Parameter 'source'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/All.cs","lineNumber":14,"sourceCode":"﻿// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT License.\n// See the LICENSE file in the project root for more information. \n\nusing System.Threading.Tasks;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        public static IAsyncObservable<bool> All<TSource>(this IAsyncObservable<TSource> source, Func<TSource, bool> predicate)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (predicate == null)\n                throw new ArgumentNullException(nameof(predicate));\n\n            return CreateAsyncObservable<bool>.From(\n                source,\n                predicate,\n                static (source, predicate, observer) => source.SubscribeSafeAsync(AsyncObserver.All(observer, predicate)));\n        }\n\n        public static IAsyncObservable<bool> All<TSource>(this IAsyncObservable<TSource> source, Func<TSource, ValueTask<bool>> predicate)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (predicate == null)\n                throw new ArgumentNullException(nameof(predicate));\n\n            return CreateAsyncObservable<bool>.From(\n                source,","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/All.cs#L1-L32","documentation":"The synchronous All operator (IAsyncObservable<bool> All<TSource>(source, Func<TSource, bool> predicate)) throws ArgumentNullException when the source observable is null. AsyncRx.NET validates operator arguments eagerly so that a null source fails at query construction instead of at subscription time.","triggerScenarios":"Calling source.All(predicate) via the extension method with source == null, or AsyncObservable.All(null, predicate) directly — e.g. a field holding the observable that was never assigned.","commonSituations":"Chained queries where an earlier factory returned null, lazy-initialized observables used before assignment, or null propagating from a configuration-provided source.","solutions":["Ensure the source is created before the query: var src = AsyncObservable.FromArray(items); then src.All(x => ...).","Null-check or null-coalesce the source before composing: source ?? AsyncObservable.Empty<T>().","Fix the upstream producer so it never returns null (throw its own descriptive error instead)."],"exampleFix":"// before\nIAsyncObservable<int> source = null;\nvar anyFail = source.All(x => x > 0); // throws\n// after\nvar source = AsyncObservable.FromArray(new[] { 1, 2, 3 });\nvar anyFail = source.All(x => x > 0);","handlingStrategy":"validation","validationCode":"if (source == null) throw new ArgumentNullException(nameof(source));\n// or: var safe = source ?? AsyncObservable.Empty<TSource>();","typeGuard":"static bool HasSource<TSource>(IAsyncObservable<TSource> s) => s is not null;","tryCatchPattern":"try { var q = source.All(x => x > 0); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source\") { /* initialize source and retry composition */ }","preventionTips":["Initialize observables eagerly (constructor or field initializer), not lazily.","Never let factory methods return null observables; return Empty instead.","Compose query pipelines immediately after source creation."],"tags":["argument-null","source","all","async-rx"],"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"}