{"record":{"id":"b592c72ce731b034","repo":"MaterialDesignInXAML/MaterialDesignInXamlToolkit","slug":"session","errorCode":null,"errorMessage":"session","messagePattern":"session","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/MaterialDesignThemes.Wpf/DialogClosedEventArgs.cs","lineNumber":7,"sourceCode":"﻿namespace MaterialDesignThemes.Wpf;\n\npublic class DialogClosedEventArgs : RoutedEventArgs\n{\n    public DialogClosedEventArgs(DialogSession session, RoutedEvent routedEvent)\n        : base(routedEvent)\n        => Session = session ?? throw new ArgumentNullException(nameof(session));\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.\n    /// </summary>\n    public DialogSession Session { get; }\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/98edec3a0b96ef272c587b14bcd67ef5f928a7ed/src/MaterialDesignThemes.Wpf/DialogClosedEventArgs.cs#L1-L19","documentation":"ArgumentNullException(nameof(session)) in DialogClosedEventArgs constructor (DialogClosedEventArgs.cs:7). The args object requires a live DialogSession because Parameter and consumers depend on it. Thrown only if internal/library code constructs DialogClosedEventArgs with a null session; not normally reachable by user code.","triggerScenarios":"Constructing 'new DialogClosedEventArgs(null, routedEvent)' directly, or a fork/custom build invoking the constructor without a session. In the shipped library, the host always passes CurrentSession.","commonSituations":"Custom subclasses/mocks of the event args; unit-test fakes that pass null; reflection-based instantiation.","solutions":["Always pass a valid DialogSession instance when constructing DialogClosedEventArgs; reuse DialogHost.CurrentSession if synthesizing one.","If writing tests/mocks, instantiate DialogSession through an actual DialogHost rather than null.","Prefer subscribing to the DialogClosed event instead of constructing the args yourself."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"DialogSession? session = dialogHost.CurrentSession;\nif (session is null)\n    throw new InvalidOperationException(\"Cannot build DialogClosedEventArgs without a session.\");\n\nvar args = new DialogClosedEventArgs(session, DialogHost.DialogClosedEvent);","typeGuard":"static bool TryBuildClosedArgs(DialogHost host, out DialogClosedEventArgs args)\n{\n    args = null!;\n    if (host.CurrentSession is null) return false;\n    args = new DialogClosedEventArgs(host.CurrentSession, DialogHost.DialogClosedEvent);\n    return true;\n}","tryCatchPattern":null,"preventionTips":["Never construct DialogClosedEventArgs with null; reuse DialogHost.CurrentSession.","Subscribe to DialogClosed rather than synthesizing the args.","In tests, drive a real DialogHost so the library builds the args."],"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"}