{"record":{"id":"4df7b95c3f459421","repo":"dotnet/wpf","slug":"sr-compoundfilepathnullempty","errorCode":null,"errorMessage":"SR.CompoundFilePathNullEmpty","messagePattern":"SR\\.CompoundFilePathNullEmpty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStorageReference.cs","lineNumber":126,"sourceCode":"            if (fullName == null || fullName.Length == 0)\n            {\n                _fullName = String.Empty;\n            }\n            else\n            {\n                // fail on leading path separator to match functionality across the board\n                // Although we need to do ToUpperInvariant before we do string comparison, in this case\n                //  it is not necessary since PathSeparatorAsString is a path symbol\n                if (fullName.StartsWith(ContainerUtilities.PathSeparatorAsString, StringComparison.Ordinal))\n                    throw new ArgumentException(\n                        SR.DelimiterLeading, nameof(fullName));\n\n                _fullName = fullName;\n\n                // ensure that the string is a legal whack-path\n                string[] strings = ContainerUtilities.ConvertBackSlashPathToStringArrayPath(_fullName);\n                if (strings.Length == 0)\n                    throw new ArgumentException (\n                        SR.CompoundFilePathNullEmpty, nameof(fullName));\n            }\n        }\n\n        //------------------------------------------------------\n        //\n        //   Private members\n        //\n        //------------------------------------------------------\n        // this can never be null - use String.Empty\n        private String  _fullName;  // whack-path\n    }\n}\n","sourceCodeStart":108,"sourceCodeEnd":140,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStorageReference.cs#L108-L140","documentation":"After stripping/validating, CompoundFileStorageReference.SetFullName converts the name to a path array; if the result is empty (null, empty string, or a string that reduces to nothing) the name cannot identify any storage. It throws ArgumentException with SR.CompoundFilePathNullEmpty for the fullName parameter.","triggerScenarios":"Constructing a CompoundFileStorageReference with fullName = \"\" (or a string such as separators-only input that ConvertBackSlashPathToStringArrayPath reduces to zero segments).","commonSituations":"Default/uninitialized string variables passed as part names, empty rows from config or data files, string.Empty produced by failed parsing/trimming upstream.","solutions":["Check String.IsNullOrEmpty(fullName) before constructing the reference and throw or substitute a valid name.","Validate that the name has at least one non-separator segment after trimming.","Ensure upstream parsing returns a real name or skip the item rather than creating an empty-named reference.","Guard configuration/user input at the boundary with an explicit non-empty check."],"exampleFix":"// before\nvar storageRef = new CompoundFileStorageReference(nameFromConfig); // may be \"\"\n// after\nif (string.IsNullOrEmpty(nameFromConfig))\n    throw new ArgumentException(\"Storage name must be non-empty.\", nameof(nameFromConfig));\nvar storageRef = new CompoundFileStorageReference(nameFromConfig);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(name) || name.Split('/').All(string.IsNullOrEmpty)) throw new ArgumentException(\"Name must contain at least one path segment.\");","typeGuard":"bool IsNonEmptyPath(string name) => !string.IsNullOrEmpty(name) && ContainerUtilities.ConvertBackSlashPathToStringArrayPath(name).Length > 0;","tryCatchPattern":"try { new CompoundFileStorageReference(name); }\ncatch (ArgumentException) { throw new ArgumentException(\"Storage name required.\", nameof(name)); }","preventionTips":["Check String.IsNullOrEmpty before constructing references","Ensure upstream parsers never emit empty names","Skip empty entries instead of passing them through"],"tags":["argument","path","empty-string","validation","packaging"],"backgroundTag":"empty-required-field","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}