{"record":{"id":"72671e5f5dc5eb3a","repo":"jstedfast/MailKit","slug":"message-authenticatedeventargs","errorCode":null,"errorMessage":"message","messagePattern":"message","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/AuthenticatedEventArgs.cs","lineNumber":52,"sourceCode":"\t/// Some servers, such as GMail IMAP, will send some free-form text in\n\t/// the response to a successful login.\n\t/// </remarks>\n\tpublic class AuthenticatedEventArgs : EventArgs\n\t{\n\t\t/// <summary>\n\t\t/// Initializes a new instance of the <see cref=\"MailKit.AuthenticatedEventArgs\"/> class.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Creates a new <see cref=\"AuthenticatedEventArgs\"/>.\n\t\t/// </remarks>\n\t\t/// <param name=\"message\">The free-form text.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <paramref name=\"message\"/> is <see langword=\"null\" />.\n\t\t/// </exception>\n\t\tpublic AuthenticatedEventArgs (string message)\n\t\t{\n\t\t\tif (message == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (message));\n\n\t\t\tMessage = message;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Get the free-form text sent by the server.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Gets the free-form text sent by the server.\n\t\t/// </remarks>\n\t\t/// <value>The free-form text sent by the server.</value>\n\t\tpublic string Message {\n\t\t\tget; private set;\n\t\t}\n\t}\n}\n","sourceCodeStart":34,"sourceCodeEnd":69,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/AuthenticatedEventArgs.cs#L34-L69","documentation":"MailKit's AuthenticatedEventArgs constructor throws ArgumentNullException when the message parameter is null. This event-args class carries the free-form server text received upon successful authentication, so a non-null string is required. It is typically thrown by library or subclass code, not by application developers.","triggerScenarios":"Invoking new AuthenticatedEventArgs(null) — usually from custom protocol handlers, subclasses of the authentication flow, or unit tests simulating the Authenticated event with a null message.","commonSituations":"Writing a custom IMAP/SMTP protocol extension that raises the Authenticated event; test harnesses faking server responses where the response text variable is null; mocking frameworks passing uninitialized strings.","solutions":["Pass a non-null string (use string.Empty if there is no server text).","Check the server-response parsing code so an empty response becomes an empty string, not null.","In tests, provide a representative message string such as \"Authenticated\" when simulating the event."],"exampleFix":"// before\nvar args = new AuthenticatedEventArgs(serverText); // serverText is null\n\n// after\nvar args = new AuthenticatedEventArgs(serverText ?? string.Empty);","handlingStrategy":"validation","validationCode":"if (message == null)\n    throw new InvalidOperationException(\"AuthenticatedEventArgs requires a non-null message string\");\nvar args = new AuthenticatedEventArgs(message);","typeGuard":"bool HasServerMessage(string message) => !string.IsNullOrEmpty(message);","tryCatchPattern":"try\n{\n    var args = new AuthenticatedEventArgs(message);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"message\")\n{\n    logger.LogError(ex, \"Null server message for AuthenticatedEventArgs\");\n}","preventionTips":["Use string.Empty for absent server text instead of null.","In protocol parsers, trim/normalize responses and default missing text to empty strings.","In test doubles for the Authenticated event, always supply a literal message string."],"tags":["argument-null","event-args","authentication","mailkit"],"backgroundTag":"null-argument","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}