{"record":{"id":"7a8ea61989d37026","repo":"MaterialDesignInXAML/MaterialDesignInXamlToolkit","slug":"session-7a8ea6","errorCode":null,"errorMessage":"session","messagePattern":"session","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/MaterialDesignThemes.Wpf/DialogClosingEventArgs.cs","lineNumber":7,"sourceCode":"﻿namespace MaterialDesignThemes.Wpf;\n\npublic class DialogClosingEventArgs : RoutedEventArgs\n{\n    public DialogClosingEventArgs(DialogSession session, RoutedEvent routedEvent)\n        : base(routedEvent)\n        => Session = session ?? throw new ArgumentNullException(nameof(session));\n\n    /// <summary>\n    /// Cancel the close.\n    /// </summary>\n    public void Cancel() => IsCancelled = true;\n\n    /// <summary>\n    /// Indicates if the close has already been cancelled.\n    /// </summary>\n    public bool IsCancelled { get; private set; }\n\n    /// <summary>\n    /// Gets the parameter originally provided to <see cref=\"DialogHost.CloseDialogCommand\"/>/\n    /// </summary>\n    public object? Parameter => Session.CloseParameter;\n\n    /// <summary>\n    /// Allows interaction with the current dialog session.","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/98edec3a0b96ef272c587b14bcd67ef5f928a7ed/src/MaterialDesignThemes.Wpf/DialogClosingEventArgs.cs#L1-L25","documentation":"ArgumentNullException(nameof(session)) in DialogClosingEventArgs constructor (DialogClosingEventArgs.cs:7). The args expose session-derived state (Cancel/Parameter) so a null session is illegal. Reachable only if user/library code constructs the args with a null session.","triggerScenarios":"Calling 'new DialogClosingEventArgs(null, routedEvent)' directly, or a fork raising DialogClosingEvent with a null session.","commonSituations":"Custom routed-event raising; test doubles; reflection instantiation; modified library builds.","solutions":["Pass a valid DialogSession when constructing DialogClosingEventArgs; reuse the host's CurrentSession.","Raise the DialogClosing event through DialogHost's own API rather than constructing args manually.","In tests, drive a real DialogHost lifecycle so the library constructs the args."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"DialogSession? session = dialogHost.CurrentSession;\nif (session is null)\n    throw new InvalidOperationException(\"Cannot build DialogClosingEventArgs without a session.\");\n\nvar args = new DialogClosingEventArgs(session, DialogHost.DialogClosingEvent);","typeGuard":"static bool TryBuildClosingArgs(DialogHost host, out DialogClosingEventArgs args)\n{\n    args = null!;\n    if (host.CurrentSession is null) return false;\n    args = new DialogClosingEventArgs(host.CurrentSession, DialogHost.DialogClosingEvent);\n    return true;\n}","tryCatchPattern":null,"preventionTips":["Never construct DialogClosingEventArgs with null; reuse DialogHost.CurrentSession.","Raise DialogClosing through the host's API, not by hand-built args.","In tests, exercise a real DialogHost lifecycle."],"tags":["wpf","materialdesigninxaml","argument-null","internal","dialog"],"backgroundTag":null,"analyzedSha":"98edec3a0b96ef272c587b14bcd67ef5f928a7ed","analyzedAt":"2026-08-13T14:31:19.111Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}