{"record":{"id":"6de3ec646961d555","repo":"dotnet/wpf","slug":"sr-delimiterleading","errorCode":null,"errorMessage":"SR.DelimiterLeading","messagePattern":"SR\\.DelimiterLeading","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStorageReference.cs","lineNumber":118,"sourceCode":"        /// Assign the fullName\n        /// </summary>\n        /// <param name=\"fullName\">name</param>\n        /// <remarks>cache a duplicate copy of the storage name to save having to do this for \n        /// every call to get_Name</remarks>\n        /// <exception cref=\"ArgumentException\">if leading or trailing path delimiter</exception>\n        private void SetFullName(string fullName)\n        {\n            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","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStorageReference.cs#L100-L136","documentation":"CompoundFileStorageReference.SetFullName rejects a fullName that begins with the path separator ('/'). Container-relative names in the compound-file model are always relative, so a leading slash would produce an absolute path the container cannot represent. It throws ArgumentException with SR.DelimiterLeading naming the offending parameter.","triggerScenarios":"Constructing a CompoundFileStorageReference or calling its FullName setter with a string starting with '/', e.g. new CompoundFileStorageReference(\"/storage1\").","commonSituations":"Joining paths with string concatenation that leaves a leading slash, porting code from absolute-path APIs (Uri, filesystem paths) to container-relative names, or reading user-supplied part names without normalization.","solutions":["Trim leading '/' characters from the name before assigning it: fullName.TrimStart('/') using Ordinal semantics on the path separator.","Normalize the path first with a helper (e.g. strip leading separators, then split on '/').","If an absolute path is required, resolve it against the container root externally and pass the relative remainder.","Validate user input to reject or normalize absolute paths before constructing the reference."],"exampleFix":"// before\nvar storageRef = new CompoundFileStorageReference(\"/Data/Storage1\");\n// after\nstring name = \"/Data/Storage1\".TrimStart('/');\nvar storageRef = new CompoundFileStorageReference(name); // \"Data/Storage1\"","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(name) || name.StartsWith(\"/\", StringComparison.Ordinal)) throw new ArgumentException(\"Name must be relative and non-empty.\");","typeGuard":"bool IsValidStorageName(string name) => !string.IsNullOrEmpty(name) && !name.StartsWith(\"/\", StringComparison.Ordinal);","tryCatchPattern":"try { new CompoundFileStorageReference(name); }\ncatch (ArgumentException ex) { /* normalize and retry */ }","preventionTips":["Normalize container paths before use: trim leading '/'","Never feed filesystem absolute paths directly as container names","Validate user/config supplied part names at input boundaries"],"tags":["argument","path","validation","packaging"],"backgroundTag":"invalid-argument-value","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"}