{"record":{"id":"392725565330c6c4","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-optimizationinterfaces","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'optimizationInterfaces')","messagePattern":"Value cannot be null\\. \\(Parameter 'optimizationInterfaces'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Wrappers.cs","lineNumber":41,"sourceCode":"        }\n\n        /// <summary>\n        /// Returns a scheduler that represents the original scheduler, without the specified set of interface-based optimizations (e.g. long running scheduling).\n        /// </summary>\n        /// <param name=\"scheduler\">Scheduler to disable the specified optimizations for.</param>\n        /// <param name=\"optimizationInterfaces\">Types of the optimization interfaces that have to be disabled.</param>\n        /// <returns>Proxy to the original scheduler but without the specified optimizations enabled.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"scheduler\"/> or <paramref name=\"optimizationInterfaces\"/> is <c>null</c>.</exception>\n        public static IScheduler DisableOptimizations(this IScheduler scheduler, params Type[] optimizationInterfaces)\n        {\n            if (scheduler == null)\n            {\n                throw new ArgumentNullException(nameof(scheduler));\n            }\n\n            if (optimizationInterfaces == null)\n            {\n                throw new ArgumentNullException(nameof(optimizationInterfaces));\n            }\n\n            return new DisableOptimizationsScheduler(scheduler, optimizationInterfaces);\n        }\n\n        /// <summary>\n        /// Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.\n        /// </summary>\n        /// <typeparam name=\"TException\">Type of the exception to check for.</typeparam>\n        /// <param name=\"scheduler\">Scheduler to apply an exception filter for.</param>\n        /// <param name=\"handler\">Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.</param>\n        /// <returns>Wrapper around the original scheduler, enforcing exception handling.</returns>\n        /// <exception cref=\"ArgumentNullException\"><paramref name=\"scheduler\"/> or <paramref name=\"handler\"/> is <c>null</c>.</exception>\n        public static IScheduler Catch<TException>(this IScheduler scheduler, Func<TException, bool> handler)\n            where TException : Exception\n        {\n            if (scheduler == null)\n            {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Concurrency/Scheduler.Wrappers.cs#L23-L59","documentation":"The same DisableOptimizations overload also validates the optimizationInterfaces parameter; passing a null Type[] throws ArgumentNullException naming 'optimizationInterfaces'. The wrapper needs the array (possibly empty) to know which optimizations to suppress.","triggerScenarios":"Calling scheduler.DisableOptimizations((Type[])null) or passing a variable typed Type[] that is null, typically built by a method that returned null instead of an empty array.","commonSituations":"Building the list of optimization interfaces dynamically; configuration-driven type lists that were never populated; API returning null for 'no restrictions'.","solutions":["Pass an empty array instead of null when no optimizations should be disabled","Ensure the code building the Type[] returns Array.Empty<Type>() rather than null","Check the variable for null before the call"],"exampleFix":"// before\nType[] ifs = GetDisabledOptimizations(); // returns null\nvar s = scheduler.DisableOptimizations(ifs);\n// after\nvar ifs = GetDisabledOptimizations() ?? Array.Empty<Type>();\nvar s = scheduler.DisableOptimizations(ifs);","handlingStrategy":"validation","validationCode":"optimizationInterfaces ??= Array.Empty<Type>();","typeGuard":"static bool HasInterfaceList(Type[] t) => t != null;","tryCatchPattern":"try { wrapped = scheduler.DisableOptimizations(list); }\ncatch (ArgumentNullException) { wrapped = scheduler.DisableOptimizations(Array.Empty<Type>()); }","preventionTips":["Return Array.Empty<Type>() instead of null from list builders","Normalize params arrays with ?? Array.Empty<Type>() before calls","Prefer overloads accepting IEnumerable with empty defaults"],"tags":["null-argument","scheduler","params"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}