{"record":{"id":"4c10e147b0d2af20","repo":"dotnet/reactive","slug":"argumentnullexception-nameof-resourcefactory","errorCode":null,"errorMessage":"ArgumentNullException(nameof(resourceFactory))","messagePattern":"ArgumentNullException\\(nameof\\(resourceFactory\\)\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs","lineNumber":16,"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","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs#L1-L34","documentation":"Using validates resourceFactory, which must create the disposable resource governing the subscription lifetime; null is rejected because the resource could never be constructed or disposed. Fix: pass a non-null Func<TResource>.","triggerScenarios":"Thrown at AsyncRx.NET/System.Reactive.Async/Linq/Operators/Using.cs:16 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null Func<TResource> that constructs the resource.","Refactor to construct the resource explicitly if factory indirection is unnecessary."],"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"}