{"record":{"id":"7d26036b98434597","repo":"HangfireIO/Hangfire","slug":"source","errorCode":null,"errorMessage":"source","messagePattern":"source","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/MoreLinq/MoreEnumerable.Pairwise.cs","lineNumber":53,"sourceCode":"        /// <param name=\"resultSelector\">A transform function to apply to \n        /// each pair of sequence.</param>\n        /// <returns>\n        /// Returns the resulting sequence.\n        /// </returns>\n        /// <remarks>\n        /// This operator uses deferred execution and streams its results.\n        /// </remarks>\n        /// <example>\n        /// <code>\n        /// int[] numbers = { 123, 456, 789 };\n        /// IEnumerable&lt;int&gt; result = numbers.Pairwise(5, (a, b) => a + b);\n        /// </code>\n        /// The <c>result</c> variable, when iterated over, will yield \n        /// 579 and 1245, in turn.\n        /// </example>\n        public static IEnumerable<TResult> Pairwise<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TSource, TResult> resultSelector)\n        {\n            if (source == null) throw new ArgumentNullException(nameof(source));\n            if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector));\n            return PairwiseImpl(source, resultSelector);\n        }\n\n        private static IEnumerable<TResult> PairwiseImpl<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TSource, TResult> resultSelector)\n        {\n            Debug.Assert(source != null);\n            Debug.Assert(resultSelector != null);\n\n            using (var e = source.GetEnumerator())\n            {\n                if (!e.MoveNext())\n                    yield break;\n\n                var previous = e.Current;\n                while (e.MoveNext())\n                {\n                    yield return resultSelector(previous, e.Current);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/MoreLinq/MoreEnumerable.Pairwise.cs#L35-L71","documentation":"Thrown by the MoreEnumerable.Pairwise extension method (part of Hangfire's vendored MoreLinq) when the source sequence is null. Pairwise projects consecutive pairs of elements using a selector function; a null source sequence cannot be enumerated.","triggerScenarios":"Calling null.Pairwise(selector) or someCollection.Pairwise(selector) where someCollection is null. The check happens eagerly at call time, before deferred execution begins.","commonSituations":"An internal Hangfire code path passes a null collection to Pairwise (e.g., a method returning null instead of an empty enumerable), or application code using Hangfire's vendored MoreLinq Pairwise on a null reference.","solutions":["Ensure the source sequence is non-null; use Enumerable.Empty<T>() instead of null for empty sequences","Add a null check before calling Pairwise","If the source comes from a method that may return null, coalesce with ?? Enumerable.Empty<T>()"],"exampleFix":"// before\nIEnumerable<int> items = GetItems(); // returns null\nvar pairs = items.Pairwise((a, b) => a + b);\n\n// after\nvar items = GetItems() ?? Enumerable.Empty<int>();\nvar pairs = items.Pairwise((a, b) => a + b);","handlingStrategy":"validation","validationCode":"var safeSource = source ?? Enumerable.Empty<TSource>();\nvar pairs = safeSource.Pairwise(resultSelector);","typeGuard":"source != null","tryCatchPattern":null,"preventionTips":["Return Enumerable.Empty<T>() instead of null from methods that feed Pairwise","Use the null-coalescing operator (??) to provide an empty fallback","Validate collection-returning methods for null before passing to LINQ operators"],"tags":["null-argument","linq","morelinq","internal-api","hangfire"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}