{"record":{"id":"878b85ec0c4c9b28","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-value","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'value')","messagePattern":"Value cannot be null\\. \\(Parameter 'value'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Rx.NET/Source/src/System.Reactive/Internal/PlatformEnlightenmentProvider.cs","lineNumber":58,"sourceCode":"        // NOTE TO MAINTAINERS\n        //\n        //  Do *NOT* remove this mechanism which has been used beyond its original goal of supporting dependency injection when we were unifying\n        //  the different Rx implementations as one Portable Library with platform-specific PlatformServices assemblies on top. Besides this, it\n        //  has been used (and is still being used) for hosting scenarios where the host wants control over thread creation (cf. CAL), or other\n        //  services (e.g. interception of query operators for logging, debugging, quota management, policy injection, etc.). Compat matters and\n        //  lack thereof results in users getting stuck on older versions or having to resort to forking.\n        //\n\n        /// <summary>\n        /// (Infrastructure) Gets the current enlightenment provider. If none is loaded yet, accessing this property triggers provider resolution.\n        /// </summary>\n        /// <remarks>\n        /// This member is used by the Rx infrastructure and not meant for public consumption or implementation.\n        /// </remarks>\n        public static IPlatformEnlightenmentProvider Current\n        {\n            get => _current;\n            set => _current = value ?? throw new ArgumentNullException(nameof(value));\n        }\n\n        private static IPlatformEnlightenmentProvider CreatePlatformProvider() => new CurrentPlatformEnlightenmentProvider();\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":64,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/Rx.NET/Source/src/System.Reactive/Internal/PlatformEnlightenmentProvider.cs#L40-L64","documentation":"PlatformEnlightenmentProvider.Current is the static injection point for Rx's platform enlightenment provider. Its setter rejects null with ArgumentNullException('value') because a null provider would break every internal enlightenment lookup (concurrency, timers, etc.).","triggerScenarios":"Assigning PlatformEnlightenmentProvider.Current = null, typically in test teardown or DI setup code that resets a stored provider reference which was never initialized.","commonSituations":"Unit-test fixtures clearing static state between tests; host applications that read the provider from a service locator returning null before assignment.","solutions":["Assign a valid IPlatformEnlightenmentProvider instance (e.g. new CurrentPlatformEnlightenmentProvider() or the test provider).","Skip the assignment when the resolved value is null instead of writing it back.","Cache the original provider and restore that reference, never null."],"exampleFix":"// before\nPlatformEnlightenmentProvider.Current = ResolveProvider();\n// after\nvar provider = ResolveProvider();\nif (provider != null) { PlatformEnlightenmentProvider.Current = provider; }","handlingStrategy":"validation","validationCode":"if (provider != null) { PlatformEnlightenmentProvider.Current = provider; }","typeGuard":"bool IsValidProvider(IPlatformEnlightenmentProvider? p) => p is not null;","tryCatchPattern":"try { PlatformEnlightenmentProvider.Current = resolved; } catch (ArgumentNullException ex) when (ex.ParamName == \"value\") { /* fall back to default provider */ }","preventionTips":["Restore the original provider captured at test setup, never null, in teardown.","Centralize provider assignment in one guarded helper."],"tags":["argument-null","static-configuration","platform-enlightenment"],"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"}