{"record":{"id":"dfeda7f9e59dd903","repo":"AvaloniaUI/Avalonia","slug":"unsupported-avaloniaproperty-type","errorCode":null,"errorMessage":"Unsupported AvaloniaProperty type.","messagePattern":"Unsupported AvaloniaProperty type\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/AvaloniaObject.cs","lineNumber":157,"sourceCode":"        /// <summary>\n        /// Clears a <see cref=\"AvaloniaProperty\"/>'s local value.\n        /// </summary>\n        /// <param name=\"property\">The property.</param>\n        public void ClearValue<T>(AvaloniaProperty<T> property)\n        {\n            ThrowHelper.ThrowIfNull(property, nameof(property));\n            VerifyAccess();\n\n            switch (property)\n            {\n                case StyledProperty<T> styled:\n                    ClearValue(styled);\n                    break;\n                case DirectPropertyBase<T> direct:\n                    ClearValue(direct);\n                    break;\n                default:\n                    throw new NotSupportedException(\"Unsupported AvaloniaProperty type.\");\n            }\n        }\n\n        /// <summary>\n        /// Clears a <see cref=\"AvaloniaProperty\"/>'s local value.\n        /// </summary>\n        /// <param name=\"property\">The property.</param>\n        public void ClearValue<T>(StyledProperty<T> property)\n        {\n            ThrowHelper.ThrowIfNull(property, nameof(property));\n            VerifyAccess();\n\n            _values.ClearValue(property);\n        }\n\n        /// <summary>\n        /// Clears a <see cref=\"AvaloniaProperty\"/>'s local value.\n        /// </summary>","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/AvaloniaObject.cs#L139-L175","documentation":"Thrown by AvaloniaObject.ClearValue<T> when the supplied property is neither a StyledProperty<T> nor a DirectPropertyBase<T>. The generic ClearValue dispatches on the runtime property kind; any other AvaloniaProperty subclass (or an untyped/registered-as-other property) hits the default branch.","triggerScenarios":"Calling ClearValue<T> with a property instance whose runtime type is a custom AvaloniaProperty subclass; passing an AttachedProperty that does not derive from StyledProperty<T>; calling the wrong generic arity.","commonSituations":"Reflection-based code that resolves an AvaloniaProperty by name and calls ClearValue generically; mixing styled and direct property APIs.","solutions":["Use the property-type-specific overload: ClearValue(StyledProperty<T>) or ClearValue(DirectPropertyBase<T>).","Cast the property to its concrete type before clearing.","For attached properties, use the static ClearValue(provider, AttachedProperty) helper on the owning type."],"exampleFix":"// before\nobj.ClearValue((AvaloniaProperty<double>)someUnknownProp);\n\n// after\nif (someUnknownProp is StyledProperty<double> styled)\n    obj.ClearValue(styled);\nelse if (someUnknownProp is DirectPropertyBase<double> direct)\n    obj.ClearValue(direct);","handlingStrategy":"type-guard","validationCode":"switch (property)\n{\n    case StyledProperty<T> s: obj.ClearValue(s); break;\n    case DirectPropertyBase<T> d: obj.ClearValue(d); break;\n    default: throw new NotSupportedException();\n}","typeGuard":"static bool IsClearable(AvaloniaProperty<T> p) =>\n    p is StyledProperty<T> or DirectPropertyBase<T>;","tryCatchPattern":null,"preventionTips":["Prefer the concrete-typed ClearValue overloads.","In generic code, switch on the property runtime type."],"tags":["property-system","avaloniaobject","not-supported"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}