{"record":{"id":"e7d055a866f08084","repo":"dotnet/wpf","slug":"invalidguid","errorCode":null,"errorMessage":"InvalidGuid","messagePattern":"InvalidGuid","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs","lineNumber":773,"sourceCode":"                {\n                    guids[count++] = attribute.Id;\n                }\n            }\n            return guids;\n        }\n\n        #region Key/Value pair validation helpers\n        /// <summary>\n        /// Validates the data to be associated with a ExtendedProperty id\n        /// </summary>\n        /// <param name=\"id\">ExtendedProperty identifier</param>\n        /// <param name=\"value\">data</param>\n        /// <remarks>Ignores Ids that are not known (e.g. ExtendedProperties)</remarks>\n        internal static void Validate(Guid id, object value)\n        {\n            if (id == Guid.Empty)\n            {\n                throw new ArgumentException(SR.InvalidGuid);\n            }\n\n            if (id == KnownIds.Color)\n            {\n                if (!(value is System.Windows.Media.Color))\n                {\n                    throw new ArgumentException(SR.Format(SR.InvalidValueType, typeof(System.Windows.Media.Color)), nameof(value));\n                }\n            }\n                // int attributes\n            else if (id == KnownIds.CurveFittingError)\n            {\n                if (!(value.GetType() == typeof(int)))\n                {\n                    throw new ArgumentException(SR.Format(SR.InvalidValueType, typeof(int)), nameof(value));\n                }\n            }\n            else if (id == KnownIds.DrawingFlags)","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs#L755-L791","documentation":"Thrown by ExtendedPropertySerializer.Validate when an extended property is registered with Guid.Empty as its identifier. Every extended property must carry a real, unique GUID so ISF can key it; an empty GUID is meaningless and cannot be serialized or matched on load.","triggerScenarios":"Calling Add on Stroke.ExtendedProperties / DrawingAttributes.ExtendedProperties with an empty Guid as the id, or InvokeValidateAsISF paths that pass Guid.Empty.","commonSituations":"Building extended property identifiers from parsed config or metadata where the GUID string failed to parse and defaulted to Guid.Empty; copy-paste code that forgot to set the id.","solutions":["Supply a valid, non-empty Guid when adding the extended property (use Guid.NewGuid() or a fixed application GUID).","Check where the GUID originates — fix parsing of the GUID string (Guid.TryParse) so it cannot silently become Guid.Empty.","If the property is optional, skip adding it when no valid id is available."],"exampleFix":"// before\nstroke.ExtendedProperties.Add(Guid.Empty, 42);\n// after\nGuid id = Guid.NewGuid(); // or a fixed application-specific GUID\nstroke.ExtendedProperties.Add(id, 42);","handlingStrategy":"validation","validationCode":"Guid id = parsedViaTryParse ?? Guid.NewGuid();\nif (id == Guid.Empty) throw new ArgumentException(\"Extended property id must be a non-empty Guid\");","typeGuard":"bool IsValidPropertyId(Guid id) => id != Guid.Empty;","tryCatchPattern":"try { props.Add(id, value); }\ncatch (ArgumentException ex) when (ex.ParamName == \"id\") { Log.Error(\"Extended property id was Guid.Empty\", ex); }","preventionTips":["Use Guid.TryParse instead of new Guid(string) so failures don't yield Guid.Empty","Define extended property GUIDs as compile-time constants","Never default missing GUID config to Guid.Empty"],"tags":["ink","extended-properties","guid","argument"],"backgroundTag":"invalid-identifier","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"}