{"record":{"id":"6936da9605357d23","repo":"dotnet/wpf","slug":"feature-id-string-cannot-have-zero-length","errorCode":null,"errorMessage":"Feature ID string cannot have zero length.","messagePattern":"Feature ID string cannot have zero length\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs","lineNumber":77,"sourceCode":"        /// <param name=\"readerVersion\">Reader Version</param>\n        /// <param name=\"updaterVersion\">Updater Version</param>\n        public FormatVersion(String featureId,\n                                VersionPair writerVersion,\n                                VersionPair readerVersion,\n                                VersionPair updaterVersion)\n        {\n            if (featureId == null)\n                throw new ArgumentNullException(nameof(featureId));\n            if (writerVersion == null)\n                throw new ArgumentNullException(nameof(writerVersion));\n            if (readerVersion == null)\n                throw new ArgumentNullException(nameof(readerVersion));\n            if (updaterVersion == null)\n                throw new ArgumentNullException(nameof(updaterVersion));\n\n            if (featureId.Length == 0)\n            {\n                throw new ArgumentException(SR.ZeroLengthFeatureID);\n            }\n\n            _featureIdentifier = featureId;\n            _reader = readerVersion;\n            _updater = updaterVersion;\n            _writer = writerVersion;\n        }\n\n        #endregion Constructors\n\n        //------------------------------------------------------\n        //\n        //  Public Properties\n        //\n        //------------------------------------------------------\n\n        #region Public Properties\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs#L59-L95","documentation":"ArgumentException from the FormatVersion constructor when the featureId string is non-null but zero-length. A feature identifier is the key used to match version blocks to features in the DataSpace; an empty string is not a valid identifier, so construction fails after the null checks pass.","triggerScenarios":"new FormatVersion(\"\", writerVersion, readerVersion, updaterVersion) — e.g. a parsed file yielded an empty feature-id field or a string was trimmed to empty.","commonSituations":"Reading malformed compound files whose version stream contains blank feature IDs; building version blocks from user-supplied or config-driven feature names.","solutions":["Pass a meaningful non-empty feature ID (e.g. \"DataSpace\" or the transform's registered name)","Trim/validate the feature-id string and reject empty values before construction","Skip or repair malformed version records when reading files"],"exampleFix":"// before\nvar fv = new FormatVersion(featureId, w, r, u); // featureId == \"\"\n// after\nif (string.IsNullOrEmpty(featureId)) throw new InvalidOperationException(\"Feature id required\");\nvar fv = new FormatVersion(featureId, w, r, u);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(featureId)) throw new ArgumentException(\"featureId must be non-empty\");\nvar fv = new FormatVersion(featureId, writerVersion, readerVersion, updaterVersion);","typeGuard":"static bool IsNonEmptyFeatureId(string s) => !string.IsNullOrEmpty(s);","tryCatchPattern":null,"preventionTips":["Trim and check feature IDs after parsing or user input","Reject empty feature IDs at the file-reading boundary","Use named constants for known feature IDs (e.g. \"DataSpace\")"],"tags":["empty-string","wpf","packaging","argument"],"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"}