{"record":{"id":"b22b6b40fbd6fe5f","repo":"stride3d/stride","slug":"given-propertykey-doesn-t-have-accessor-metadata","errorCode":null,"errorMessage":"Given PropertyKey doesn't have accessor metadata.","messagePattern":"Given PropertyKey doesn't have accessor metadata\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/PropertyContainer.cs","lineNumber":530,"sourceCode":"        }\n        else\n        {\n            if (tryToAdd)\n                properties.Add(propertyKey, valueToSet);\n            else\n                properties[propertyKey] = valueToSet;\n        }\n\n        propertyKey.ObjectInvalidationMetadata?.Invalidate(Owner, propertyKey, oldValue);\n    }\n\n    public static void AddAccessorProperty(Type type, PropertyKey propertyKey)\n    {\n        if (!type.GetTypeInfo().IsClass)\n            throw new ArgumentException(\"Class type is expected.\", nameof(type));\n\n        if (propertyKey.AccessorMetadata == null)\n            throw new ArgumentException(\"Given PropertyKey doesn't have accessor metadata.\", nameof(propertyKey));\n\n        if (!AccessorProperties.TryGetValue(type, out var typeAccessorProperties))\n            AccessorProperties.Add(type, typeAccessorProperties = []);\n\n        typeAccessorProperties.Add(propertyKey);\n    }\n\n    internal void RaisePropertyContainerUpdated(PropertyKey propertyKey, object newValue, object oldValue)\n    {\n        PropertyUpdated?.Invoke(ref this, propertyKey, newValue, oldValue);\n    }\n\n    private object? GetNonRecursive(PropertyKey propertyKey)\n    {\n        // Get bound value, if any.\n        if (properties != null && properties.TryGetValue(propertyKey, out var value))\n        {\n            return propertyKey.IsValueType ? ((ValueHolder)value).ObjectValue : value;","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/PropertyContainer.cs#L512-L548","documentation":"AddAccessorProperty only makes sense for PropertyKey instances that were created with accessor metadata (PropertyKey.AccessorMetadata), which links the key to a CLR property. When the supplied key carries no such metadata there is nothing to register, so ArgumentException is thrown.","triggerScenarios":"Calling PropertyContainer.AddAccessorProperty(type, key) where the key was constructed without an accessor (e.g. PropertyKey<T>.new(..., new PropertyKeyMetadata[...]) with no AccessorMetadata attached).","commonSituations":"Passing a plain data key (or a key built by hand) to the accessor registration API; keys generated by source generators omitted the accessor attribute; using the wrong key overload without [Property] style metadata.","solutions":["Use a PropertyKey created with accessor metadata (e.g. keys generated for [DataMember]/[Property]-attributed CLR properties).","Attach AccessorMetadata to the key at construction instead of registering it bare.","If the key is a plain storage key, register it via the normal property mechanism, not AddAccessorProperty."],"exampleFix":"// before\nvar key = new PropertyKey<float>(\"Speed\", typeof(Entity));\nPropertyContainer.AddAccessorProperty(typeof(Entity), key); // no accessor metadata\n// after: use a key generated from an accessor-decorated property, or\nvar key2 = new PropertyKey<float>(\"Speed\", typeof(Entity),\n    new AccessorMetadata(...));","handlingStrategy":"validation","validationCode":"if (propertyKey.AccessorMetadata == null)\n    throw new InvalidOperationException($\"Key {propertyKey.Name} has no accessor metadata; cannot register as accessor property\");","typeGuard":null,"tryCatchPattern":"try { PropertyContainer.AddAccessorProperty(type, key); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"accessor metadata\"))\n{\n    // key is a plain storage key; register it through the normal path instead\n}","preventionTips":["Use keys generated from accessor-attributed properties so AccessorMetadata is attached.","Do not pass hand-built plain PropertyKeys to AddAccessorProperty.","Document which keys are accessor keys versus storage keys in your property registry."],"tags":["argument-exception","property-key","metadata","property-system"],"backgroundTag":"missing-dependency","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}