{"record":{"id":"b678923865d56389","repo":"AvaloniaUI/Avalonia","slug":"value-cannot-be-null-parameter-directoryinfo","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'directoryInfo')","messagePattern":"Value cannot be null\\. \\(Parameter 'directoryInfo'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Platform/Storage/ILauncher.cs","lineNumber":61,"sourceCode":"    public static Task<bool> LaunchFileInfoAsync(this ILauncher launcher, FileInfo fileInfo)\n    {\n        _ = fileInfo ?? throw new ArgumentNullException(nameof(fileInfo));\n        if (!fileInfo.Exists)\n        {\n            return Task.FromResult(false);\n        }\n\n        return launcher.LaunchFileAsync(new BclStorageFile(fileInfo));\n    }\n\n    /// <summary>\n    /// Starts the default app associated with the specified storage directory (folder).\n    /// </summary>\n    /// <param name=\"launcher\">ILauncher instance.</param>\n    /// <param name=\"directoryInfo\">The directory.</param>\n    public static Task<bool> LaunchDirectoryInfoAsync(this ILauncher launcher, DirectoryInfo directoryInfo)\n    {\n        _ = directoryInfo ?? throw new ArgumentNullException(nameof(directoryInfo));\n        if (!directoryInfo.Exists)\n        {\n            return Task.FromResult(false);\n        }\n\n        return launcher.LaunchFileAsync(new BclStorageFolder(directoryInfo));\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":70,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Platform/Storage/ILauncher.cs#L43-L70","documentation":"LauncherExtensions.LaunchDirectoryInfoAsync(directoryInfo) wraps a System.IO.DirectoryInfo into a BclStorageFolder and forwards to ILauncher.LaunchFileAsync. It throws ArgumentNullException(nameof(directoryInfo)) on a null DirectoryInfo as a fail-fast precondition. Mirrors LaunchFileInfoAsync for the folder case.","triggerScenarios":"Calling Launcher.LaunchDirectoryInfoAsync(null), or passing a DirectoryInfo that is null because the directory lookup/config returned null.","commonSituations":"A DirectoryInfo built from a user-supplied or config-supplied path that was empty/null, or a cancel from a folder picker yielding null, forwarded without a guard.","solutions":["Null-check and existence-check the DirectoryInfo before calling.","Build DirectoryInfo only from a validated non-empty path.","Handle the null/cancel branch explicitly instead of forwarding."],"exampleFix":"// before\nawait Launcher.LaunchDirectoryInfoAsync(dir); // dir may be null\n\n// after\nif (dir is null || !dir.Exists) return false;\nreturn await Launcher.LaunchDirectoryInfoAsync(dir);","handlingStrategy":"validation","validationCode":"if (directoryInfo is null || !directoryInfo.Exists) return false;\nreturn await Launcher.LaunchDirectoryInfoAsync(directoryInfo);","typeGuard":"bool IsValid(DirectoryInfo? d) => d is not null && d.Exists;","tryCatchPattern":null,"preventionTips":["Validate DirectoryInfo is non-null and Exists before launching.","Construct DirectoryInfo only from validated non-empty paths.","Handle folder-picker cancel (null) explicitly."],"tags":["avalonia","launcher","argumentnull","directory-info","validation"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}