{"record":{"id":"dbce5965fa91f954","repo":"jstedfast/MailKit","slug":"argumentnullexception-folderrenamedeventargs","errorCode":null,"errorMessage":"ArgumentNullException","messagePattern":"ArgumentNullException","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"MailKit/FolderRenamedEventArgs.cs","lineNumber":54,"sourceCode":"\tpublic class FolderRenamedEventArgs : EventArgs\n\t{\n\t\t/// <summary>\n\t\t/// Initializes a new instance of the <see cref=\"T:MailKit.FolderRenamedEventArgs\"/> class.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// Creates a new <see cref=\"FolderRenamedEventArgs\"/>.\n\t\t/// </remarks>\n\t\t/// <param name=\"oldName\">The old name of the folder.</param>\n\t\t/// <param name=\"newName\">The new name of the folder.</param>\n\t\t/// <exception cref=\"System.ArgumentNullException\">\n\t\t/// <para><paramref name=\"oldName\"/> is <see langword=\"null\" />.</para>\n\t\t/// <para>-or-</para>\n\t\t/// <para><paramref name=\"newName\"/> is <see langword=\"null\" />.</para>\n\t\t/// </exception>\n\t\tpublic FolderRenamedEventArgs (string oldName, string newName)\n\t\t{\n\t\t\tif (oldName == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (oldName));\n\n\t\t\tif (newName == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (newName));\n\n\t\t\tOldName = oldName;\n\t\t\tNewName = newName;\n\t\t}\n\n\t\t/// <summary>\n\t\t/// The old name of the folder.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// The old name of the folder.\n\t\t/// </remarks>\n\t\t/// <value>The old name.</value>\n\t\tpublic string OldName {\n\t\t\tget; private set;\n\t\t}","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/FolderRenamedEventArgs.cs#L36-L72","documentation":"The FolderRenamedEventArgs(string oldName, string newName) constructor throws ArgumentNullException when either oldName or newName is null. The event args must carry both the previous and new folder names for the FolderRenamed event, so both are documented required non-null values.","triggerScenarios":"Constructing FolderRenamedEventArgs with a null oldName or newName — e.g. raising the renamed event manually where one of the names was not tracked.","commonSituations":"Custom IMAP session implementations raising MailKit events; unit tests building event args; code paths where the old name was never captured before renaming.","solutions":["Capture the folder's name before renaming so oldName is available","Pass non-empty strings for both oldName and newName","When raising events yourself, validate both names before constructing the args"],"exampleFix":"// before\nvar args = new FolderRenamedEventArgs (oldName, null);\n// after\nvar args = new FolderRenamedEventArgs (oldName, folder.FullName);","handlingStrategy":"validation","validationCode":"if (oldName == null || newName == null)\n    throw new InvalidOperationException (\"both names required\");\nvar args = new FolderRenamedEventArgs (oldName, newName);","typeGuard":"bool ValidNames (string o, string n) => o != null && n != null;","tryCatchPattern":"try {\n    args = new FolderRenamedEventArgs (oldName, newName);\n} catch (ArgumentNullException) {\n    // skip raising the event or fix the names\n}","preventionTips":["Snapshot the folder's name before renaming to preserve oldName","Validate both name strings before constructing event args","When implementing custom IMAP sessions, always populate both names for rename notifications"],"tags":["csharp","mailkit","argument-null","event-args"],"backgroundTag":"null-argument","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}