{"record":{"id":"bcc797ccd97560a8","repo":"dotnet/wpf","slug":"sr-invalidguid","errorCode":null,"errorMessage":"SR.InvalidGuid","messagePattern":"SR\\.InvalidGuid","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/StrokeCollection.cs","lineNumber":187,"sourceCode":"        /// </summary>\n        /// <param name=\"propertyDataId\"></param>\n        public void RemovePropertyData(Guid propertyDataId)\n        {\n            object propertyData = GetPropertyData(propertyDataId);\n            this.ExtendedProperties.Remove(propertyDataId);\n            // fire notification\n            OnPropertyDataChanged(new PropertyDataChangedEventArgs(propertyDataId, null, propertyData));\n        }\n\n        /// <summary>\n        /// Allows retrieval of objects from the EPC\n        /// </summary>\n        /// <param name=\"propertyDataId\"></param>\n        public object GetPropertyData(Guid propertyDataId)\n        {\n            if ( propertyDataId == Guid.Empty )\n            {\n                throw new ArgumentException(SR.InvalidGuid, nameof(propertyDataId));\n            }\n\n            return this.ExtendedProperties[propertyDataId];\n        }\n\n        /// <summary>\n        /// Allows retrieval of a Array of guids that are contained in the EPC\n        /// </summary>\n        public Guid[] GetPropertyDataIds()\n        {\n            return this.ExtendedProperties.GetGuidArray();\n        }\n\n        /// <summary>\n        /// Allows the checking of objects in the EPC\n        /// </summary>\n        /// <param name=\"propertyDataId\"></param>\n        public bool ContainsPropertyData(Guid propertyDataId)","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/StrokeCollection.cs#L169-L205","documentation":"StrokeCollection.GetPropertyData throws ArgumentException when propertyDataId equals Guid.Empty. Custom stroke properties are keyed by a non-empty Guid identifier; Guid.Empty is never a valid property key in the ink ExtendedProperties store. The library rejects it immediately to prevent an unresolvable property lookup.","triggerScenarios":"Calling StrokeCollection.GetPropertyData(Guid.Empty). Typically happens when the Guid came from an uninitialized field, a default(Guid) struct, or a failed Guid.TryParse whose result was used anyway.","commonSituations":"Developers storing/retrieving custom metadata (e.g. author name, drawing attributes) on ink strokes pass a Guid field that was never assigned; serializing/deserializing property IDs from config where the empty string parsed to Guid.Empty.","solutions":["Ensure the property Guid is a real generated identifier; assign it via new Guid(\"...\") or a const Guid and verify it is not Guid.Empty before calling GetPropertyData.","Add a guard in the caller: if (propertyDataId == Guid.Empty) throw/log before calling GetPropertyData.","If the Guid originates from parsed input, use Guid.TryParse/Exactlyn and reject empty results."],"exampleFix":"// before\nvar value = strokes.GetPropertyData(someGuid); // someGuid is Guid.Empty\n// after\nif (someGuid == Guid.Empty)\n    throw new InvalidOperationException(\"Property GUID was not initialized\");\nvar value = strokes.GetPropertyData(someGuid);","handlingStrategy":"validation","validationCode":"if (propertyDataId == Guid.Empty)\n    throw new ArgumentException(\"Property data GUID must be a non-empty Guid\", nameof(propertyDataId));\n// safe to call:\nvar value = strokes.GetPropertyData(propertyDataId);","typeGuard":"static bool IsValidPropertyId(Guid id) => id != Guid.Empty;","tryCatchPattern":"try { return strokes.GetPropertyData(id); }\ncatch (ArgumentException ex) when (ex.ParamName == \"propertyDataId\") { return null; }","preventionTips":["Store property GUIDs as readonly static readonly Guid constants so they cannot default to Guid.Empty.","Never consume the result of an unvalidated Guid.Parse/TryParse.","Initialize Guid fields at declaration or in the constructor."],"tags":["wpf","ink","argument-validation","guid"],"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-22T01:17:13.364Z"}