{"record":{"id":"bdff2bdac393c38d","repo":"dotnet/wpf","slug":"this-setter-is-not-intended-to-be-used-directly-from-your","errorCode":null,"errorMessage":"This setter is not intended to be used directly from your code. Do not call this setter.","messagePattern":"This setter is not intended to be used directly from your code\\. Do not call this setter\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/ClrProperty.cs","lineNumber":122,"sourceCode":"        // ----- Protected Overrides -----\n\n        public override string BoundName\n        {\n            get { return Name; }\n        }\n\n        public override bool IsImplicit { get { return false; } }\n        public override bool IsUnknown { get { return false; } }\n\n        public override IList<string> GetXamlNamespaces()\n        {\n            return DeclaringType.GetXamlNamespaces();\n        }\n\n        protected override string NameCore\n        {\n            get { return _name; }\n            set { throw new InvalidOperationException(SR.MustNotCallSetter); }\n        }\n\n        protected override bool IsPublicCore\n        {\n            get { return _isPublic; }\n            set { throw new InvalidOperationException(SR.MustNotCallSetter); }\n        }\n\n        protected override bool IsBrowsableCore\n        {\n            get\n            {\n                bool ret = CheckPropertyBit(BoolPropertyBits.IsBrowsable);\n                return ret;\n            }\n            set { throw new InvalidOperationException(SR.MustNotCallSetter); }\n        }\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/ClrProperty.cs#L104-L140","documentation":"ClrProperty overrides XamlMember.NameCore with a get-only cached value and throws InvalidOperationException (SR.MustNotCallSetter) if anyone attempts to set NameCore. These setters exist only to satisfy the abstract base-class signature; mutation of schema metadata after construction is not supported.","triggerScenarios":"Calling NameCore = value (or invoking the setter via reflection) on a ClrProperty instance, typically from custom XAML schema code that tries to rename a member after construction.","commonSituations":"Framework authors subclassing XamlMember/XamlProperty and trying to fix up member names post-construction; debugging tools setting properties blindly through reflection.","solutions":["Pass the correct name to the ClrProperty constructor instead of setting NameCore afterwards.","Construct a new ClrProperty/XamlMember with the desired name rather than mutating the existing one.","Use a mutable XamlMember subclass if post-construction mutation is genuinely needed."],"exampleFix":"// before\nprop.NameCore = \"NewName\"; // throws\n// after\nvar prop = new ClrProperty(\"NewName\", propertyInfo, declaringType, schemaContext);","handlingStrategy":"validation","validationCode":"// guard before assigning XamlMember metadata\nif (member is ClrProperty) throw new InvalidOperationException(\"ClrProperty metadata is immutable; recreate the member instead\");","typeGuard":"bool IsImmutableMember(XamlMember m) => m.GetType().Name == \"ClrProperty\";","tryCatchPattern":"try { member.NameCore = newName; }\ncatch (InvalidOperationException ex) { log(\"XamlMember metadata setters must not be called: \" + ex.Message); }","preventionTips":["Treat all XamlMember Core properties as read-only; supply values via constructors.","Never invoke Core-property setters directly or via reflection.","Check base-class docs: setter throws mean use subclass overrides, not runtime mutation."],"tags":["xaml","schema","invalid-operation"],"backgroundTag":"unsupported-operation","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"}