stride3d/stride · error · ArgumentException
Given PropertyKey doesn't have accessor metadata.
Error message
Given PropertyKey doesn't have accessor metadata.
What it means
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.
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.
Example fix
// before
var key = new PropertyKey<float>("Speed", typeof(Entity));
PropertyContainer.AddAccessorProperty(typeof(Entity), key); // no accessor metadata
// after: use a key generated from an accessor-decorated property, or
var key2 = new PropertyKey<float>("Speed", typeof(Entity),
new AccessorMetadata(...)); Defensive patterns
Strategy: validation
Validate before calling
if (propertyKey.AccessorMetadata == null)
throw new InvalidOperationException($"Key {propertyKey.Name} has no accessor metadata; cannot register as accessor property"); Try / catch
try { PropertyContainer.AddAccessorProperty(type, key); }
catch (ArgumentException ex) when (ex.Message.Contains("accessor metadata"))
{
// key is a plain storage key; register it through the normal path instead
} Prevention
- 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.
When it happens
Trigger: Calling PropertyContainer.AddAccessorProperty(type, key) where the key was constructed without an accessor (e.g. PropertyKey<T>.new(..., new PropertyKeyMetadata[...]) with no AccessorMetadata attached).
Common situations: 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.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Unable to retrieve value for
- Class type is expected.
- Cannot add an asset with an empty Id
- Cannot add an asset that is already added to another package
- Asset location [ ] must be relative and not absolute (not…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b22b6b40fbd6fe5f.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core/PropertyContainer.cs:530
}
else
{
if (tryToAdd)
properties.Add(propertyKey, valueToSet);
else
properties[propertyKey] = valueToSet;
}
propertyKey.ObjectInvalidationMetadata?.Invalidate(Owner, propertyKey, oldValue);
}
public static void AddAccessorProperty(Type type, PropertyKey propertyKey)
{
if (!type.GetTypeInfo().IsClass)
throw new ArgumentException("Class type is expected.", nameof(type));
if (propertyKey.AccessorMetadata == null)
throw new ArgumentException("Given PropertyKey doesn't have accessor metadata.", nameof(propertyKey));
if (!AccessorProperties.TryGetValue(type, out var typeAccessorProperties))
AccessorProperties.Add(type, typeAccessorProperties = []);
typeAccessorProperties.Add(propertyKey);
}
internal void RaisePropertyContainerUpdated(PropertyKey propertyKey, object newValue, object oldValue)
{
PropertyUpdated?.Invoke(ref this, propertyKey, newValue, oldValue);
}
private object? GetNonRecursive(PropertyKey propertyKey)
{
// Get bound value, if any.
if (properties != null && properties.TryGetValue(propertyKey, out var value))
{
return propertyKey.IsValueType ? ((ValueHolder)value).ObjectValue : value;View on GitHub (pinned to 96fad776d2)