{"record":{"id":"3b85eeea7ea8d8cf","repo":"dotnet/reactive","slug":"value-cannot-be-null-parameter-end","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'end')","messagePattern":"Value cannot be null\\. \\(Parameter 'end'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/FromAsyncPattern.Generated.cs","lineNumber":498,"sourceCode":"                try\n                {\n                    AsyncObserver.FromAsyncPattern(subject, begin, end, arg1, arg2, arg3, arg4);\n                }\n                catch (Exception ex)\n                {\n                    return Throw<Unit>(ex);\n                }\n\n                return subject.AsAsyncObservable();\n            };\n        }\n\n        public static Func<T1, T2, T3, T4, T5, IAsyncObservable<Unit>> FromAsyncPattern<T1, T2, T3, T4, T5>(Func<T1, T2, T3, T4, T5, AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, Unit> end)\n        {\n            if (begin == null)\n                throw new ArgumentNullException(nameof(begin));\n            if (end == null)\n                throw new ArgumentNullException(nameof(end));\n\n            return (arg1, arg2, arg3, arg4, arg5) =>\n            {\n                var subject = new SequentialAsyncAsyncSubject<Unit>();\n\n                try\n                {\n                    AsyncObserver.FromAsyncPattern(subject, begin, end, arg1, arg2, arg3, arg4, arg5);\n                }\n                catch (Exception ex)\n                {\n                    return Throw<Unit>(ex);\n                }\n\n                return subject.AsAsyncObservable();\n            };\n        }\n","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/FromAsyncPattern.Generated.cs#L480-L516","documentation":"FromAsyncPattern<T1..T5> adapts a Begin/End APM pair into a function returning an IAsyncObservable, and it throws ArgumentNullException with parameter name 'end' when the end callback (Func<IAsyncResult, Unit>) is null. A Begin/End pair is meaningless without the End delegate that extracts the result, so it is validated eagerly when the pattern is constructed. The exception is thrown at FromAsyncPattern call time, not when the returned function is invoked.","triggerScenarios":"Calling FromAsyncPattern(begin, end) with a null end delegate, e.g. the five-generic-argument overload where only begin was supplied or the end lambda was conditionally omitted.","commonSituations":"Migrating legacy APM (BeginXxx/EndXxx) APIs where the End method lookup via reflection returned null; wrapping WebRequest-style APIs with partially defined pairs.","solutions":["Pass the matching End method: FromAsyncPattern(begin, r => (Unit)EndXxx(r)) or via method group EndXxx.","Verify reflection lookups (Type.GetMethod for the End method) are not returning null.","Null-check both delegates before constructing the pattern and surface a domain-specific error."],"exampleFix":"// before\nvar f = AsyncObservable.FromAsyncPattern<string, int, int, int, int>(req.BeginGetResponse, null);\n// after\nvar f = AsyncObservable.FromAsyncPattern<string, int, int, int, int>(req.BeginGetResponse, r => { req.EndGetResponse(r); return Unit.Default; });","handlingStrategy":"validation","validationCode":"if (begin is null || end is null) throw new InvalidOperationException(\"FromAsyncPattern requires a complete begin/end pair\");","typeGuard":"bool IsCompletePair(Delegate begin, Delegate end) => begin is not null && end is not null;","tryCatchPattern":"try { var f = AsyncObservable.FromAsyncPattern<T1,T2,T3,T4,T5>(begin, end); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"end\") { /* log and rebuild with correct End method */ }","preventionTips":["Always pass Begin/End as matched method groups from the same object","Check reflection GetMethod results for null before creating delegates","Migrate legacy APM pairs to Task-returning methods where possible"],"tags":["argument-null","apm","fromasyncpattern","generated-code"],"backgroundTag":"null-argument","analyzedSha":"94b5d5ab912789f5abe9a72138a25bbd716fe59c","analyzedAt":"2026-09-15T02:26:24.759Z","contentChangedAt":"2026-09-15T02:26:24.759Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}