{"record":{"id":"f16b71c9896e9438","repo":"MaterialDesignInXAML/MaterialDesignInXamlToolkit","slug":"all-action-arguments-must-be-provided-if-any-are-p","errorCode":null,"errorMessage":"All action arguments must be provided if any are provided.","messagePattern":"All action arguments must be provided if any are provided\\.","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/MaterialDesignThemes.Wpf/SnackbarMessageQueue.cs","lineNumber":186,"sourceCode":"    public void Enqueue(object content, object? actionContent, Action? actionHandler, bool promote)\n        => Enqueue(content, actionContent, _ => actionHandler?.Invoke(), false, promote, false);\n\n    public void Enqueue<TArgument>(object content, object? actionContent, Action<TArgument?>? actionHandler,\n        TArgument? actionArgument)\n        => Enqueue(content, actionContent, actionHandler, actionArgument, false, false);\n\n    public void Enqueue<TArgument>(object content, object? actionContent, Action<TArgument?>? actionHandler,\n        TArgument? actionArgument, bool promote) =>\n        Enqueue(content, actionContent, actionHandler, actionArgument, promote, false);\n\n    public void Enqueue<TArgument>(object content, object? actionContent, Action<TArgument?>? actionHandler,\n        TArgument? actionArgument, bool promote, bool neverConsiderToBeDuplicate, TimeSpan? durationOverride = null)\n    {\n        if (content is null) throw new ArgumentNullException(nameof(content));\n\n        if (actionContent is null ^ actionHandler is null)\n        {\n            throw new ArgumentNullException(actionContent != null ? nameof(actionContent) : nameof(actionHandler),\n                \"All action arguments must be provided if any are provided.\");\n        }\n\n        Action<object?>? handler = actionHandler != null\n            ? new Action<object?>(argument => actionHandler((TArgument?)argument))\n            : null;\n        Enqueue(content, actionContent, handler, actionArgument, promote, neverConsiderToBeDuplicate, durationOverride);\n    }\n\n    public void Enqueue(object content, object? actionContent, Action<object?>? actionHandler,\n        object? actionArgument, bool promote, bool neverConsiderToBeDuplicate, TimeSpan? durationOverride = null)\n    {\n        if (content is null) throw new ArgumentNullException(nameof(content));\n\n        if (actionContent is null ^ actionHandler is null)\n        {\n            throw new ArgumentNullException(actionContent != null ? nameof(actionContent) : nameof(actionHandler),\n                \"All action arguments must be provided if any are provided.\");","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/98edec3a0b96ef272c587b14bcd67ef5f928a7ed/src/MaterialDesignThemes.Wpf/SnackbarMessageQueue.cs#L168-L204","documentation":"The generic Enqueue<TArgument> overload requires actionContent and actionHandler to be both present or both absent (an XOR check). Supplying only one half would show a button with no handler or wire a handler with no button, so it throws ArgumentNullException naming the missing half.","triggerScenarios":"Calling Enqueue<TArgument> with actionContent set but actionHandler null, or actionHandler set but actionContent null.","commonSituations":"Wiring an action button but forgetting the callback delegate; a refactor that removed the handler; conditionally providing only the button text.","solutions":["Provide both actionContent and actionHandler, or pass null for both.","If no action is needed, use the simpler Enqueue(content) overload.","Centralize snackbar action creation in a helper that always pairs content and handler."],"exampleFix":"// before\nqueue.Enqueue(\"Saved\", \"Undo\", null);\n// after\nqueue.Enqueue(\"Saved\", \"Undo\", () => Revert());","handlingStrategy":"validation","validationCode":"bool hasAction = actionContent is not null;\nbool hasHandler = actionHandler is not null;\nif (hasAction != hasHandler)\n    throw new ArgumentException(\"Provide both actionContent and actionHandler, or neither.\");\nqueue.Enqueue(content, actionContent, actionHandler, arg, promote);","typeGuard":"(actionContent is null) == (actionHandler is null)","tryCatchPattern":null,"preventionTips":["Always pair action button text with its handler.","Use the no-action Enqueue(content) overload when no button is needed.","Wrap Enqueue in a helper that enforces the pairing."],"tags":["wpf","snackbar","argument-null"],"backgroundTag":null,"analyzedSha":"98edec3a0b96ef272c587b14bcd67ef5f928a7ed","analyzedAt":"2026-08-13T14:31:19.111Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}