{"record":{"id":"c951036c11c7c3fa","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-first-sequenceequal","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'first')","messagePattern":"Value cannot be null\\. \\(Parameter 'first'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/SequenceEqual.cs","lineNumber":18,"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.Collections.Generic;\nusing System.Reactive.Disposables;\nusing System.Threading;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        // TODO: Add SequenceEqual<T>(IAsyncObservable<T>, IAsyncEnumerable<T>).\n\n        public static IAsyncObservable<bool> SequenceEqual<TSource>(this IAsyncObservable<TSource> first, IAsyncObservable<TSource> 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 CreateAsyncObservable<bool>.From(\n                first,\n                second,\n                static async (first, second, observer) =>\n                {\n                    var (firstObserver, secondObserver) = AsyncObserver.SequenceEqual<TSource>(observer);\n\n                    var firstTask = first.SubscribeSafeAsync(firstObserver);\n                    var secondTask = second.SubscribeSafeAsync(secondObserver);\n\n                    // REVIEW: Consider concurrent subscriptions.\n\n                    var d1 = await firstTask.ConfigureAwait(false);\n                    var d2 = await secondTask.ConfigureAwait(false);\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/SequenceEqual.cs#L1-L36","documentation":"SequenceEqual(this first, second) validates both source sequences up front. A null first observable makes the comparison meaningless, so the operator throws ArgumentNullException named 'first' before any subscription occurs.","triggerScenarios":"Invoking firstObservable.SequenceEqual(secondObservable) where firstObservable is null — typically the result of a factory/lookup method that returned null and is chained with the extension-call syntax.","commonSituations":"Chaining .SequenceEqual(...) onto a method that can return null (cache miss, dictionary TryGetValue ignored); test fixtures building sequences conditionally.","solutions":["Ensure the receiver expression is non-null before calling SequenceEqual.","If the first sequence may be absent, substitute AsyncObservable.Empty<TSource>().","Guard with a null check and throw a more meaningful exception or return a known result.","Fix the upstream factory so it never returns null (return an empty observable instead)."],"exampleFix":"// before\nIAsyncObservable<int> left = maybeNull;\nvar eq = left.SequenceEqual(right);\n// after\nvar eq = (left ?? AsyncObservable.Empty<int>()).SequenceEqual(right);","handlingStrategy":"validation","validationCode":"if (first is null) first = AsyncObservable.Empty<TSource>();\nif (second is null) second = AsyncObservable.Empty<TSource>();","typeGuard":"static bool HasSequence<TSource>(IAsyncObservable<TSource>? s) => s is not null;","tryCatchPattern":"try { var eq = first.SequenceEqual(second); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"first\") { /* handle missing left sequence */ }","preventionTips":["Enable nullable reference types so null flows are caught at compile time.","Never let factories return null observables; return empty sequences.","Null-check results of nullable lookups before chaining operators."],"tags":["argument-null","sequenceequal","asyncrx"],"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"}