{"record":{"id":"4d6cff195ca4ec67","repo":"dotnet/reactive","slug":"rightdurationselector","errorCode":null,"errorMessage":"rightDurationSelector","messagePattern":"rightDurationSelector","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"AsyncRx.NET/System.Reactive.Async/Linq/Operators/GroupJoin.cs","lineNumber":24,"sourceCode":"using System.Reactive.Disposables;\nusing System.Reactive.Subjects;\nusing System.Threading;\nusing System.Threading.Tasks;\n\nnamespace System.Reactive.Linq\n{\n    public partial class AsyncObservable\n    {\n        public static IAsyncObservable<TResult> GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IAsyncObservable<TLeft> left, IAsyncObservable<TRight> right, Func<TLeft, IAsyncObservable<TLeftDuration>> leftDurationSelector, Func<TRight, IAsyncObservable<TRightDuration>> rightDurationSelector, Func<TLeft, IAsyncObservable<TRight>, TResult> resultSelector)\n        {\n            if (left == null)\n                throw new ArgumentNullException(nameof(left));\n            if (right == null)\n                throw new ArgumentNullException(nameof(right));\n            if (leftDurationSelector == null)\n                throw new ArgumentNullException(nameof(leftDurationSelector));\n            if (rightDurationSelector == null)\n                throw new ArgumentNullException(nameof(rightDurationSelector));\n            if (resultSelector == null)\n                throw new ArgumentNullException(nameof(resultSelector));\n\n            return Create<TResult>(async observer =>\n            {\n                var subscriptions = new CompositeAsyncDisposable();\n\n                var (leftObserver, rightObserver, disposable) = AsyncObserver.GroupJoin(observer, subscriptions, leftDurationSelector, rightDurationSelector, resultSelector);\n\n                var leftSubscription = await left.SubscribeSafeAsync(leftObserver).ConfigureAwait(false);\n                await subscriptions.AddAsync(leftSubscription).ConfigureAwait(false);\n\n                var rightSubscription = await right.SubscribeSafeAsync(rightObserver).ConfigureAwait(false);\n                await subscriptions.AddAsync(rightSubscription).ConfigureAwait(false);\n\n                return disposable;\n            });\n        }","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/dotnet/reactive/blob/94b5d5ab912789f5abe9a72138a25bbd716fe59c/AsyncRx.NET/System.Reactive.Async/Linq/Operators/GroupJoin.cs#L6-L42","documentation":"GroupJoin needs rightDurationSelector to compute, for each right item, the observable whose completion removes that item from open join windows. A null selector is rejected with ArgumentNullException as the fourth guard in the method, before any subscription.","triggerScenarios":"Calling GroupJoin with null as the `rightDurationSelector` (Func<TRight, IAsyncObservable<TRightDuration>>), e.g. `left.GroupJoin(right, lds, null, rs)`.","commonSituations":"Asymmetric refactors where the left duration was added but the right one left null; porting synchronous Rx GroupJoin code where selector slots were reordered; generic helpers passing through nullable delegates.","solutions":["Provide a right duration observable, e.g. `r => rightTimer` or an immediate-complete async observable.","Re-check overload/parameter order: left is (left, right, leftDurationSelector, rightDurationSelector, resultSelector).","Guard delegates in wrapper APIs before forwarding to GroupJoin."],"exampleFix":"// before\nvar result = left.GroupJoin(right, l => leftTimer, null, (l, rs) => rs);\n// after\nvar result = left.GroupJoin(right, l => leftTimer, r => rightTimer, (l, rs) => rs);","handlingStrategy":"validation","validationCode":"if (rightDurationSelector is null) throw new ArgumentNullException(nameof(rightDurationSelector));","typeGuard":"bool IsValidSelector<TRight,TDur>(Func<TRight, IAsyncObservable<TDur>>? f) => f is not null;","tryCatchPattern":"try\n{\n    var result = left.GroupJoin(right, lds, rds, rs);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"rightDurationSelector\")\n{\n    // supply a default duration or switch to a non-windowed operator\n}","preventionTips":["Provide both duration selectors symmetrically; ported Rx code often omits the right one.","Use an immediately-completing observable when a right item should expire instantly.","Guard delegate parameters in wrappers before forwarding to GroupJoin."],"tags":["argparse","null-check","async-rx"],"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"}