dotnet/reactive · error · ArgumentNullException

throw new ArgumentNullException(nameof(eighth))

Error message

throw new ArgumentNullException(nameof(eighth))

What it means

System.ArgumentNullException raised by the null-guard for the eighth source in a CombineLatest overload in QbservableEx.Homoicon.cs. The method eagerly checks every source argument so the query provider receives only valid IQbservable nodes when the expression tree is built.

Solutions

  1. Initialize or obtain the eighth observable before composing the query.
  2. Substitute a placeholder source (empty sequence) when the eighth stream is optional.
  3. Check whether sources are assembled from a collection and ensure no element is null before invoking.
  4. Reorder or consolidate sources using Scan/Zip chains to avoid 16-argument overloads where slots are easy to miss.

Example fix

// before
CombineLatest(a, b, c, d, e, f, g, sources[7], sel); // sources[7] == null
// after
if (sources.Any(s => s == null)) throw new InvalidOperationException("all sources must be set");
CombineLatest(a, b, c, d, e, f, g, sources[7], sel);
Defensive patterns

Strategy: validation

Validate before calling

var args = new IQbservable<object>[] { a,b,c,d,e,f,g,h }; if (args.Any(s => s == null)) throw new ArgumentException("null source in CombineLatest arguments");

Type guard

static bool AllSet(IQbservable<object>[] sources) => sources.All(s => s != null);

Try / catch

try { CombineLatest(...); } catch (ArgumentNullException ex) when (ex.ParamName == "eighth") { /* fix source assembly, retry */ }

Prevention

When it happens

Trigger: Invoking the 8+ argument Qbservable.CombineLatest overload with eighth == null at line 910 of the guard chain.

Common situations: Building long source lists programmatically with an array/spread where one element is null; an event-stream wrapper that is only initialized after CombineLatest is called.

Related errors


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

Appendix: source

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

        /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="third" /> or <paramref name="fourth" /> or <paramref name="fifth" /> or <paramref name="sixth" /> or <paramref name="seventh" /> or <paramref name="eighth" /> or <paramref name="ninth" /> or <paramref name="tenth" /> or <paramref name="eleventh" /> or <paramref name="twelfth" /> or <paramref name="thirteenth" /> or <paramref name="fourteenth" /> or <paramref name="fifteenth" /> or <paramref name="sixteenth" /> is null.</exception>
        public static IQbservable<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth, TEleventh Eleventh, TTwelfth Twelfth, TThirteenth Thirteenth, TFourteenth Fourteenth, TFifteenth Fifteenth, TSixteenth Sixteenth)> CombineLatest<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TEighth, TNinth, TTenth, TEleventh, TTwelfth, TThirteenth, TFourteenth, TFifteenth, TSixteenth>(this IQbservable<TFirst> first, IObservable<TSecond> second, IObservable<TThird> third, IObservable<TFourth> fourth, IObservable<TFifth> fifth, IObservable<TSixth> sixth, IObservable<TSeventh> seventh, IObservable<TEighth> eighth, IObservable<TNinth> ninth, IObservable<TTenth> tenth, IObservable<TEleventh> eleventh, IObservable<TTwelfth> twelfth, IObservable<TThirteenth> thirteenth, IObservable<TFourteenth> fourteenth, IObservable<TFifteenth> fifteenth, IObservable<TSixteenth> sixteenth)
        {
            if (first == null)
                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));
            if (eleventh == null)
                throw new ArgumentNullException(nameof(eleventh));
            if (twelfth == null)
                throw new ArgumentNullException(nameof(twelfth));
            if (thirteenth == null)
                throw new ArgumentNullException(nameof(thirteenth));
            if (fourteenth == null)
                throw new ArgumentNullException(nameof(fourteenth));
            if (fifteenth == null)
                throw new ArgumentNullException(nameof(fifteenth));
            if (sixteenth == null)
                throw new ArgumentNullException(nameof(sixteenth));

            return first.Provider.CreateQuery<(TFirst First, TSecond Second, TThird Third, TFourth Fourth, TFifth Fifth, TSixth Sixth, TSeventh Seventh, TEighth Eighth, TNinth Ninth, TTenth Tenth, TEleventh Eleventh, TTwelfth Twelfth, TThirteenth Thirteenth, TFourteenth Fourteenth, TFifteenth Fifteenth, TSixteenth Sixteenth)>(

View on GitHub (pinned to 94b5d5ab91)