{"record":{"id":"77501ead63347f14","repo":"dotnet/reactive","slug":"clock","errorCode":null,"errorMessage":"clock","messagePattern":"clock","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/SkipLast.cs","lineNumber":57,"sourceCode":"            if (duration == TimeSpan.Zero)\n            {\n                return source;\n            }\n\n            return CreateAsyncObservable<TSource>.From(\n                source,\n                duration,\n                static (source, duration, observer) => source.SubscribeSafeAsync(AsyncObserver.SkipLast(observer, duration)));\n        }\n\n        public static IAsyncObservable<TSource> SkipLast<TSource>(this IAsyncObservable<TSource> source, TimeSpan duration, IClock clock)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n            if (duration < TimeSpan.Zero)\n                throw new ArgumentOutOfRangeException(nameof(duration));\n            if (clock == null)\n                throw new ArgumentNullException(nameof(clock));\n\n            if (duration == TimeSpan.Zero)\n            {\n                return source;\n            }\n\n            return CreateAsyncObservable<TSource>.From(\n                source,\n                (duration, clock),\n                static (source, state, observer) => source.SubscribeSafeAsync(AsyncObserver.SkipLast(observer, state.duration, state.clock)));\n        }\n    }\n\n    public partial class AsyncObserver\n    {\n        public static IAsyncObserver<TSource> SkipLast<TSource>(IAsyncObserver<TSource> observer, int count)\n        {\n            if (observer == null)","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/SkipLast.cs#L39-L75","documentation":"The SkipLast(duration, clock) overload throws ArgumentNullException(\"clock\") when the IClock parameter is null. The clock is required to timestamp elements and decide which trailing elements fall within the skip window. The library fails fast at the public entry point.","triggerScenarios":"Calling source.SkipLast(TimeSpan.FromSeconds(1), clock) where clock is null — e.g. a test clock, virtual-time clock, or injected IClock that was never assigned.","commonSituations":"Forgetting to provide a test/virtual clock in unit tests; DI not binding IClock; a clock property initialized lazily and still null at composition time.","solutions":["Pass a valid IClock instance (e.g. the same LocalClock/ConcreteClock used elsewhere, or a test clock like VirtualClock for tests).","Register and inject IClock properly in your DI container.","Default the clock at the call site: clock ?? Clock.Default (or the library's default clock) if the overload without clock is not suitable."],"exampleFix":"// before\nvar res = source.SkipLast(TimeSpan.FromSeconds(1), testClock); // testClock is null\n// after\nvar res = source.SkipLast(TimeSpan.FromSeconds(1), testClock ?? new LocalClock());","handlingStrategy":"validation","validationCode":"if (clock == null) throw new InvalidOperationException(\"SkipLast(duration, clock) requires a non-null IClock\");\nvar res = source.SkipLast(duration, clock);","typeGuard":"static bool HasClock(IClock c) => c != null;","tryCatchPattern":"try { var res = source.SkipLast(duration, clock); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"clock\") { /* bind a default clock and retry */ }","preventionTips":["Register IClock in DI and verify resolution at startup.","Initialize test clocks in test setup before composing queries.","Use the clock-less overload when a custom clock is not needed."],"tags":["argument-null","clock","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"}