{"record":{"id":"858b614dde20b74a","repo":"dotnet/wpf","slug":"0-1-is-a-property-without-a-getter-and-is-not-a-valid-xaml","errorCode":null,"errorMessage":"'{0}'.'{1}' is a property without a getter and is not a valid XAML property.","messagePattern":"'(.+?)'\\.'(.+?)' is a property without a getter and is not a valid XAML property\\.","errorType":"exception","errorClass":"XamlSchemaException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/ClrAttachableProperty.cs","lineNumber":37,"sourceCode":"namespace MS.Internal.Xaml.Schema\n#else\nnamespace System.Xaml.Schema\n#endif\n{\n    [DebuggerDisplay(\"{Name}\")]\n    class ClrAttachedProperty : ClrProperty\n    {\n        public readonly MethodInfo ClrBindingGetterMethodInfo;\n        public readonly MethodInfo ClrBindingSetterMethodInfo;\n        private Type _systemTypeOfProperty = null;\n        internal ClrAttachedProperty(string name, MethodInfo getter, MethodInfo setter, XamlType declaringType)\n            : base(name, declaringType)\n        {\n            Debug.Assert(getter != null || setter != null);\n\n            if (getter == null && setter == null)\n            {\n                throw new XamlSchemaException(SR.Format(SR.SetOnlyProperty, declaringType.Name, name));\n            }\n\n            _isPublic = (getter != null) ? getter.IsPublic : setter.IsPublic;\n            _isReadOnly = (setter == null);\n            _isStatic = false;\n            _isAttachable = true;\n            _isEvent = false;\n\n            ClrBindingGetterMethodInfo = getter;\n            ClrBindingSetterMethodInfo = setter;\n        }\n\n        protected override Type LookupSystemTypeOfProperty()\n        {\n            if (_systemTypeOfProperty == null)\n            {\n                _systemTypeOfProperty = PrivateLookupSystemTypeOfProperty;\n            }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/ClrAttachableProperty.cs#L19-L55","documentation":"System.Xaml throws this XamlSchemaException when an attachable member is registered that has neither a getter nor a setter method. XAML properties must be readable to be valid; a member with no accessors cannot participate in XAML loading or type reflection, so the schema layer rejects it at construction time.","triggerScenarios":"Calling the internal/public ClrAttachedProperty constructor (via reflection-based schema provider) with getter == null and setter == null for an attachable property of declaringType.","commonSituations":"Custom XAML schema/context implementations registering attachable properties discovered by convention, where naming-based reflection failed to bind either an Get<Name> or Set<Name> static method; refactoring renamed one accessor so neither resolved.","solutions":["Define a public static Get<Name>(target) method on the declaring type (or pass a valid MethodInfo as getter).","Ensure the Set<Name>(target, value) method exists and is resolvable so the constructor receives a non-null setter.","Fix the type resolution/naming convention in the code that locates the accessor methods before constructing ClrAttachedProperty."],"exampleFix":"// before: no accessors found\nclass MyExt { /* no GetGlow / SetGlow */ }\n// after\nclass MyExt {\n  public static double GetGlow(DependencyObject o) => ...;\n  public static void SetGlow(DependencyObject o, double v) { ... }\n}","handlingStrategy":"validation","validationCode":"// before registering an attachable property\nvar getter = type.GetMethod(\"Get\" + name, BindingFlags.Public|BindingFlags.Static, null, new[]{ targetType }, null);\nvar setter = type.GetMethod(\"Set\" + name, BindingFlags.Public|BindingFlags.Static);\nif (getter == null && setter == null)\n    throw new InvalidOperationException($\"{type.Name}.{name} needs a Get{Name} or Set{Name} static method\");","typeGuard":"bool HasAccessor(EventInfo e) => e.GetAddMethod(true) != null;\n// for attachable props: getter != null || setter != null","tryCatchPattern":"try { schema.RegisterAttachableProperty(name, type); }\ncatch (XamlSchemaException ex) { log($\"Invalid attachable property: {ex.Message}\"); }","preventionTips":["Always pair attachable properties with Get/Set static methods following the WPF naming convention.","Unit-test XAML schema registration for every attachable member.","Run reflection checks over the assembly before loading XAML."],"tags":["xaml","schema","reflection"],"backgroundTag":"missing-dependency","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"}