{"record":{"id":"8d657745d855df72","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-source-8d6577","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source')","messagePattern":"Value cannot be null\\. \\(Parameter 'source'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs","lineNumber":46,"sourceCode":"        /// <typeparam name=\"TResult\">Result sequence element type.</typeparam>\n        /// <param name=\"element\">The value to be repeated.</param>\n        /// <param name=\"count\">The number of times to repeat the value in the generated sequence.</param>\n        /// <returns>Sequence that contains a repeated value.</returns>\n        public static IEnumerable<TResult> Repeat<TResult>(TResult element, int count)\n        {\n            return Enumerable.Repeat(element, count);\n        }\n\n        /// <summary>\n        /// Repeats and concatenates the source sequence infinitely.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"source\">Source sequence.</param>\n        /// <returns>Sequence obtained by concatenating the source sequence to itself infinitely.</returns>\n        public static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n\n            return RepeatCore(source);\n        }\n\n        /// <summary>\n        /// Repeats and concatenates the source sequence the given number of times.\n        /// </summary>\n        /// <typeparam name=\"TSource\">Source sequence element type.</typeparam>\n        /// <param name=\"source\">Source sequence.</param>\n        /// <param name=\"count\">Number of times to repeat the source sequence.</param>\n        /// <returns>Sequence obtained by concatenating the source sequence to itself the specified number of times.</returns>\n        public static IEnumerable<TSource> Repeat<TSource>(this IEnumerable<TSource> source, int count)\n        {\n            if (source == null)\n                throw new ArgumentNullException(nameof(source));\n\n            if (count < 0)\n            {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Ix.NET/Source/System.Interactive/System/Linq/Operators/Repeat.cs#L28-L64","documentation":"Repeat(source) throws ArgumentNullException when the source sequence is null. Repeat concatenates the source to itself (infinitely or N times), which requires a valid source; the argument is validated eagerly at call time.","triggerScenarios":"Calling Repeat() on a null IEnumerable<TSource>, e.g. source.Repeat() where source came from a nullable producer.","commonSituations":"Passing a nullable collection from configuration, deserialization, or a lookup straight into Repeat without a null check.","solutions":["Pass a non-null source; substitute Enumerable.Empty<TSource>() when there is nothing to repeat (note: an empty source repeats infinitely to nothing).","Coalesce: (source ?? Enumerable.Empty<T>()).Repeat().","Fix the upstream producer that returned a null sequence."],"exampleFix":"// before\nvar repeated = source.Repeat(); // source may be null\n// after\nvar repeated = (source ?? Enumerable.Empty<int>()).Repeat();","handlingStrategy":"validation","validationCode":"if (source == null) source = Enumerable.Empty<int>();\nvar repeated = source.Repeat();","typeGuard":"static bool CanRepeat(IEnumerable<int>? source) => source is not null;","tryCatchPattern":"try\n{\n    var repeated = source.Repeat();\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source\")\n{\n    // handle missing source\n}","preventionTips":["Coalesce nullable sequences to Enumerable.Empty<T>() before repeating.","Use nullable reference types to catch null sources at compile time.","Avoid passing results of nullable-returning lookups directly into Repeat."],"tags":["null-reference","argument-validation","linq"],"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"}