dotnet/reactive · error · ArgumentNullException

Value cannot be null. (Parameter 'tenth')

Error message

Value cannot be null. (Parameter 'tenth')

What it means

ArgumentNullException with message "Value cannot be null. (Parameter 'tenth')" is thrown by the 10-source CombineLatest overload when the tenth source sequence is null. This is the last guard in the validation chain at QbservableEx.Homoicon.cs:425-426; once it passes, the method builds the Expression.Call and delegates to first.Provider.CreateQuery. A null tenth source would make the expression tree invalid, so it is rejected upfront.

Solutions

  1. Pass a non-null IObservable<TTenth>; coalesce with Observable.Empty<TTenth>() when the stream may be absent.
  2. Verify argument order matches the signature so a non-null stream is not accidentally passed as tenth.
  3. Fix the producer that returns null, or drop the tenth source and use a 9-argument overload.

Example fix

// before
var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
// after
var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth ?? Observable.Empty<TTenth>());
Defensive patterns

Strategy: validation

Validate before calling

if (tenth is null) throw new InvalidOperationException("tenth source must be a non-null IObservable<TTenth>");
// or: tenth ??= Observable.Empty<TTenth>();

Type guard

static bool IsValidSource<T>(IObservable<T>? source) => source is not null;

Try / catch

try
{
    var combined = first.CombineLatest(second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
}
catch (ArgumentNullException ex) when (ex.ParamName == "tenth")
{
    // handle missing tenth source
}

Prevention

When it happens

Trigger: Calling QbservableEx.CombineLatest with tenth == null; the guard runs after the first nine sources validate, just before CreateQuery is invoked.

Common situations: Multi-stream merges where the final stream depends on optional data that resolved to null; null returned by a conditional stream builder; mis-ordered arguments causing an unintended null slot.

Related errors


AI-assisted analysis of dotnet/reactive@94b5d5ab91 (2026-09-15). Data as JSON: /api/errors/70d1319f4298eeb5. Report an issue: GitHub.

Appendix: source

Thrown at Rx.NET/Source/src/System.Reactive/Linq/QbservableEx.Homoicon.cs:425

                throw new ArgumentNullException(nameof(first));
            if (second == null)
                throw new ArgumentNullException(nameof(second));
            if (third == null)
                throw new ArgumentNullException(nameof(third));
            if (fourth == null)
                throw new ArgumentNullException(nameof(fourth));
            if (fifth == null)
                throw new ArgumentNullException(nameof(fifth));
            if (sixth == null)
                throw new ArgumentNullException(nameof(sixth));
            if (seventh == null)
                throw new ArgumentNullException(nameof(seventh));
            if (eighth == null)
                throw new ArgumentNullException(nameof(eighth));
            if (ninth == null)
                throw new ArgumentNullException(nameof(ninth));
            if (tenth == null)
                throw new ArgumentNullException(nameof(tenth));

            return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)>(
                Expression.Call(
                    null,
                    new Func<IQbservable<TFirst>, IObservable<TSecond>, IObservable<TThird>, IObservable<TFourth>, IObservable<TFifth>, IObservable<TSixth>, IObservable<TSeventh>, IObservable<TEighth>, IObservable<TNinth>, IObservable<TTenth>, IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth)>>(CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth>).Method,
                    first.Expression,
                    GetSourceExpression(second),
                    GetSourceExpression(third),
                    GetSourceExpression(fourth),
                    GetSourceExpression(fifth),
                    GetSourceExpression(sixth),
                    GetSourceExpression(seventh),
                    GetSourceExpression(eighth),
                    GetSourceExpression(ninth),
                    GetSourceExpression(tenth)
                )
            );
        }

View on GitHub (pinned to 94b5d5ab91)