{"record":{"id":"34df4703de3e97f6","repo":"dotnet/reactive","slug":"observer-isempty","errorCode":null,"errorMessage":"observer","messagePattern":"observer","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/IsEmpty.cs","lineNumber":23,"sourceCode":"namespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        public static IAsyncObservable<bool> IsEmpty<TSource>(this IAsyncObservable<TSource> source)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n\n            return Create<TSource, bool>(source, static (source, observer) => source.SubscribeSafeAsync(AsyncObserver.IsEmpty<TSource>(observer)));\n        }\n    }\n\n    public partial class AsyncObserver\n    {\n        public static IAsyncObserver<TSource> IsEmpty<TSource>(IAsyncObserver<bool> observer)\n        {\n            if (observer == null)\n                throw new ArgumentNullException(nameof(observer));\n\n            return Any<TSource>(Select<bool, bool>(observer, b => !b));\n        }\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":29,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/IsEmpty.cs#L5-L29","documentation":"AsyncObserver.IsEmpty(observer) throws ArgumentNullException with paramName \"observer\" when the downstream IAsyncObserver<bool> is null. It composes Any over a negated Select on the given observer and requires a valid downstream observer.","triggerScenarios":"Calling AsyncObserver.IsEmpty<TSource>(null) while authoring custom observers or wiring a custom IAsyncObservable where the downstream observer is null.","commonSituations":"Custom operator implementations that forget to forward the observer parameter, or custom observers holding a nullable observer field that was never assigned.","solutions":["Pass the actual downstream observer (from SubscribeSafeAsync) into AsyncObserver.IsEmpty.","Fix the custom observable implementation so the observer received in SubscribeAsync is forwarded, not a null field.","Add your own ArgumentNullException guard when defining operator overloads."],"exampleFix":"// before\nreturn source.SubscribeSafeAsync(AsyncObserver.IsEmpty(_observer)); // _observer is null\n// after\nreturn source.SubscribeSafeAsync(AsyncObserver.IsEmpty(observer));","handlingStrategy":"validation","validationCode":"if (observer is null) throw new ArgumentNullException(nameof(observer));\n// before calling AsyncObserver.IsEmpty<TSource>(observer)","typeGuard":"static bool HasObserver(IAsyncObserver<bool> o) => o is not null;","tryCatchPattern":"try { var o = AsyncObserver.IsEmpty<int>(observer); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"observer\") { /* fix observer forwarding */ }","preventionTips":["Forward the SubscribeAsync observer argument directly","Avoid nullable observer fields in custom observables","Guard observer parameters in custom operator code"],"tags":["argument-null","observer","reactive"],"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"}