{"record":{"id":"75e49adb7629b781","repo":"dotnet/reactive","slug":"predicate-skipwhile","errorCode":null,"errorMessage":"predicate","messagePattern":"predicate","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/SkipWhile.cs","lineNumber":16,"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<TSource> SkipWhile<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<TSource>.From(\n                source,\n                predicate,\n                static (source, predicate, observer) => source.SubscribeSafeAsync(AsyncObserver.SkipWhile(observer, predicate)));\n        }\n\n        public static IAsyncObservable<TSource> SkipWhile<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<TSource>.From(\n                source,\n                predicate,\n                static (source, predicate, observer) => source.SubscribeSafeAsync(AsyncObserver.SkipWhile(observer, predicate)));","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/SkipWhile.cs#L1-L34","documentation":"The synchronous-predicate SkipWhile extension validates its predicate and throws ArgumentNullException with paramName \"predicate\" when the Func<TSource, bool> is null. A null predicate cannot decide whether elements should be skipped.","triggerScenarios":"Calling source.SkipWhile(predicate) with a null delegate, typically a predicate stored in a variable/field that was never assigned or returned null from a factory.","commonSituations":"Predicates passed in from configuration or caller arguments; test setups where the lambda variable is conditionally assigned.","solutions":["Pass a non-null lambda or method group as the predicate.","Fix the code path that yields a null predicate delegate.","Coalesce to a default predicate if a null is acceptable in the domain."],"exampleFix":"// before\nFunc<int, bool> pred = GetPredicate(); // may be null\nvar res = src.SkipWhile(pred);\n// after\nvar res = src.SkipWhile(pred ?? (_ => true));","handlingStrategy":"validation","validationCode":"if (predicate is null) throw new ArgumentException(\"predicate required\", nameof(predicate));\nvar res = source.SkipWhile(predicate);","typeGuard":"bool HasPredicate<TSource>(Func<TSource, bool>? p) => p is not null;","tryCatchPattern":"try { var res = source.SkipWhile(pred); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"predicate\") { /* use default predicate */ }","preventionTips":["Default predicate parameters to non-null lambdas at call sites","Validate delegates coming from config/options before composing","Prefer method groups over nullable delegate fields"],"tags":["argumentnull","predicate","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"}