AvaloniaUI/Avalonia · error · ArgumentException
Skip count must be bigger than zero
Error message
Skip count must be bigger than zero
What it means
Thrown by Observable.Skip<T> when skipCount is less than or equal to zero. Skip is meant to drop the first N notifications of a stream; skipping zero or a negative count is a programming error (use the source directly). Note the message says 'must be bigger than zero' and the guard is skipCount <= 0, so skipCount of exactly 0 also throws.
Source
Thrown at src/Avalonia.Base/Reactive/Observable.cs:105
public static IObservable<TResult> CombineLatest<TFirst, TSecond, TResult>(
this IObservable<TFirst> first, IObservable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector)
{
return new CombineLatest<TFirst, TSecond, TResult>(first, second, resultSelector);
}
public static IObservable<TInput[]> CombineLatest<TInput>(
this IEnumerable<IObservable<TInput>> inputs)
{
return new CombineLatest<TInput, TInput[]>(inputs, items => items);
}
public static IObservable<T> Skip<T>(this IObservable<T> source, int skipCount)
{
if (skipCount <= 0)
{
throw new ArgumentException("Skip count must be bigger than zero", nameof(skipCount));
}
return Create<T>(obs =>
{
var remaining = skipCount;
return source.Subscribe(new AnonymousObserver<T>(
input =>
{
if (remaining <= 0)
{
obs.OnNext(input);
}
else
{
remaining--;
}
}, obs.OnError, obs.OnCompleted));
});View on GitHub (pinned to 11c5427268)
Solutions
- If you want all items, skip the Skip call entirely when count <= 0.
- Clamp the count: source.Skip(Math.Max(1, count)) only when you genuinely want to skip at least one.
- Validate count > 0 before calling and surface a clearer error to your caller.
Example fix
// before var filtered = source.Skip(skipCount); // throws when skipCount == 0 // after var filtered = skipCount > 0 ? source.Skip(skipCount) : source;
Defensive patterns
Strategy: validation
Validate before calling
if (skipCount <= 0) throw new ArgumentOutOfRangeException(nameof(skipCount)); var s = skipCount > 0 ? source.Skip(skipCount) : source;
Prevention
- Branch around Skip when the count is data-driven and can be 0.
- Clamp user-supplied counts to >= 1 when 'skip at least one' is the intent.
- Remember Skip(0) throws — it is not a no-op in this implementation.
When it happens
Trigger: Calling source.Skip(0), source.Skip(-1), or source.Skip(count) where count is computed from user input or a config value that can be zero/negative.
Common situations: A 'skip first N items' feature where N is user-configurable and defaults to or can be set to 0; an off-by-one producing a negative; reusing the same variable for both skip and take and letting it hit 0.
Related errors
- Reset called on collection without reset handler.
- Reset called on collection without reset handler.
- Collection reset not supported.
- collection
- Stream is not readable
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/ee4949d28230d038.
Report an issue: GitHub.