{"record":{"id":"6ef27dec6f9035af","repo":"dotnet/reactive","slug":"argumentnullexception-nameof-observablefactory","errorCode":null,"errorMessage":"ArgumentNullException(nameof(observableFactory))","messagePattern":"ArgumentNullException\\(nameof\\(observableFactory\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs","lineNumber":18,"sourceCode":"﻿// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT License.\n// See the LICENSE file in the project root for more information. \n\nusing System.Reactive.Disposables;\nusing System.Threading.Tasks;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        public static IAsyncObservable<TResult> Using<TResult, TResource>(Func<TResource> resourceFactory, Func<TResource, IAsyncObservable<TResult>> observableFactory)\n            where TResource : IDisposable\n        {\n            if (resourceFactory == null)\n                throw new ArgumentNullException(nameof(resourceFactory));\n            if (observableFactory == null)\n                throw new ArgumentNullException(nameof(observableFactory));\n\n            return Create<TResult>(async observer =>\n            {\n                TResource resource;\n                try\n                {\n                    resource = resourceFactory();\n                }\n                catch (Exception ex)\n                {\n                    await observer.OnErrorAsync(ex).ConfigureAwait(false);\n                    return AsyncDisposable.Nop;\n                }\n\n                IAsyncObservable<TResult> observable;\n                try\n                {\n                    observable = observableFactory(resource);","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs#L1-L36","documentation":"Using validates observableFactory, which builds the observable from the acquired resource; null is rejected because the sequence to subscribe would be undefined. Fix: pass a non-null Func<TResource, IAsyncObservable<TResult>>.","triggerScenarios":"Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs:18 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null Func<TResource, IAsyncObservable<TResult>>.","Ensure the lambda is defined for the generic TResource in use."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}