{"record":{"id":"01593fe5dc8d0f02","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-windowboundaries","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'windowBoundaries')","messagePattern":"Value cannot be null\\. \\(Parameter 'windowBoundaries'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Window.cs","lineNumber":141,"sourceCode":"            if (timeSpan < TimeSpan.Zero)\n                throw new ArgumentOutOfRangeException(nameof(timeSpan));\n            if (count <= 0)\n                throw new ArgumentOutOfRangeException(nameof(count));\n            if (scheduler == null)\n                throw new ArgumentNullException(nameof(scheduler));\n\n            return CreateAsyncObservable<IAsyncObservable<TSource>>.From(\n                source,\n                (timeSpan, count, scheduler),\n                static (source, state, observer) => WindowAsyncCore(source, observer, (o, d) => AsyncObserver.Window(o, d, state.timeSpan, state.count, state.scheduler)));\n        }\n\n        public static IAsyncObservable<IAsyncObservable<TSource>> Window<TSource, TWindowBoundary>(this IAsyncObservable<TSource> source, IAsyncObservable<TWindowBoundary> windowBoundaries)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (windowBoundaries == null)\n                throw new ArgumentNullException(nameof(windowBoundaries));\n\n            return CreateAsyncObservable<IAsyncObservable<TSource>>.From(\n                source,\n                windowBoundaries,\n                static async (source, windowBoundaries, observer) =>\n                {\n                    var d = new CompositeAsyncDisposable();\n\n                    var (sourceObserver, boundariesObserver, subscription) = await AsyncObserver.Window<TSource, TWindowBoundary>(observer, d).ConfigureAwait(false);\n\n                    var sourceSubscription = await source.SubscribeSafeAsync(sourceObserver).ConfigureAwait(false);\n                    await d.AddAsync(sourceSubscription).ConfigureAwait(false);\n\n                    var boundariesSubscription = await windowBoundaries.SubscribeSafeAsync(boundariesObserver).ConfigureAwait(false);\n                    await d.AddAsync(boundariesSubscription).ConfigureAwait(false);\n\n                    return subscription;\n                });","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Window.cs#L123-L159","documentation":"The Window(source, windowBoundaries) overload throws ArgumentNullException when the windowBoundaries observable is null (runtime message names parameter 'windowBoundaries'). Window openings are driven by emissions from the boundary observable, so null is invalid and rejected before the operator is created.","triggerScenarios":"Calling source.Window(windowBoundaries) with a null boundary observable — e.g. a boundaries factory returning null, or a variable assigned conditionally.","commonSituations":"A 'tick source' or timer pipeline that failed to initialize; mocking a boundary observable and returning null; configuration that disables the boundary stream without substituting an empty one.","solutions":["Create a real boundary observable (e.g. timer-based) before calling Window.","Substitute AsyncObservable.Empty<TWindowBoundary>() when boundaries are intentionally absent.","Fix the factory producing windowBoundaries so it never returns null.","Guard: if (windowBoundaries == null) throw with a clear message at pipeline setup."],"exampleFix":"// before\nvar windows = events.Window(boundaries); // boundaries == null\n// after\nvar boundaries = boundariesFactory ?? AsyncObservable.Empty<long>();\nvar windows = events.Window(boundaries);","handlingStrategy":"validation","validationCode":"if (windowBoundaries is null) throw new ArgumentNullException(nameof(windowBoundaries));\nvar windows = source.Window(windowBoundaries);","typeGuard":"static bool HasBoundaries<TSource, B>(IAsyncObservable<TSource> source, IAsyncObservable<B>? boundaries) => boundaries is not null;","tryCatchPattern":"try { var windows = source.Window(boundaries); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"windowBoundaries\") { /* fall back to time-based Window overload */ }","preventionTips":["Substitute AsyncObservable.Empty<B>() when the boundary stream is disabled","Ensure boundary/timer factories cannot return null","Validate both arguments at the pipeline-composition layer"],"tags":["null-argument","argument-validation","async-rx","window-operator"],"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"}