{"record":{"id":"5602567b955cc601","repo":"dotnet/wpf","slug":"guid-cannot-be-empty","errorCode":null,"errorMessage":"GUID cannot be empty.","messagePattern":"GUID cannot be empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs","lineNumber":23,"sourceCode":"\nnamespace System.Windows.Ink\n{\n    /// <summary>\n    /// Drawing Attribute Key/Value pair for specifying each attribute\n    /// </summary>\n    internal sealed class ExtendedProperty\n    {\n        /// <summary>\n        /// Create a new drawing attribute with the specified key and value\n        /// </summary>\n        /// <param name=\"id\">Identifier of attribute</param>\n        /// <param name=\"value\">Attribute value - not that the Type for value is tied to the id</param>\n        /// <exception cref=\"System.ArgumentException\">Value type must be compatible with attribute Id</exception>\n        internal ExtendedProperty(Guid id, object value)\n        {\n            if (id == Guid.Empty)\n            {\n                throw new ArgumentException(SR.InvalidGuid);\n            }\n            _id = id;\n            Value = value;\n        }\n\n        /// <summary>Returns a value that can be used to store and lookup\n        /// ExtendedProperty objects in a hash table</summary>\n        public override int GetHashCode()\n        {\n            return Id.GetHashCode() ^ Value.GetHashCode();\n        }\n\n        /// <summary>Determine if two ExtendedProperty objects are equal</summary>\n        public override bool Equals(object obj)\n        {\n            if (obj == null || obj.GetType() != GetType())\n            {\n                return false;","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs#L5-L41","documentation":"The internal ExtendedProperty constructor requires a non-empty Guid identifying the ink attribute; Guid.Empty is rejected with ArgumentException(SR.InvalidGuid, 'GUID cannot be empty.'). Extended properties are keyed by GUID, so an empty id would create an unaddressable entry.","triggerScenarios":"Constructing ExtendedProperty(Guid.Empty, value), or calling ExtendedPropertyCollection.Add(Guid.Empty, value), which forwards to this constructor.","commonSituations":"Loading ISF/ink data where a property GUID was lost or zeroed; deserializing hand-built ink XML with placeholder GUIDs; using default(Guid) as a placeholder before assigning a real attribute id.","solutions":["Supply a valid, non-empty Guid (e.g. a known ApplicationGuid or a newly generated Guid.NewGuid()) when adding the property.","Check `id == Guid.Empty` before calling Add and skip or substitute a real id.","Fix upstream data so the GUID is preserved through serialization/deserialization.","If the guid was meant to be generated, replace default(Guid)/new Guid() placeholders with Guid.NewGuid()."],"exampleFix":"// before\nproperties.Add(Guid.Empty, value); // ArgumentException: GUID cannot be empty.\n// after\nGuid id = knownAttributeId != Guid.Empty ? knownAttributeId : Guid.NewGuid();\nproperties.Add(id, value);","handlingStrategy":"validation","validationCode":"if (id == Guid.Empty)\n    throw new ArgumentException(\"A valid non-empty GUID is required.\", nameof(id));\nproperties.Add(id, value);","typeGuard":"static bool IsValidPropertyId(Guid id) => id != Guid.Empty;","tryCatchPattern":"try { properties.Add(id, value); }\ncatch (ArgumentException) { /* Guid.Empty id: fix the source of the guid */ }","preventionTips":["Never use default(Guid) as a placeholder","Validate guids at data-deserialization boundaries","Generate ids with Guid.NewGuid() when none exists"],"tags":["wpf","ink","extendedproperty","guid","argumentexception"],"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"}