stride3d/stride · error · YamlException

Unable to find property

Error message

Unable to find property [{0}] in class [{1}]

What it means

PropertyKeyYamlSerializer.ConvertFrom resolves 'ClassName.PropertyName' scalars by reflecting over the resolved class for a public static field. When GetField with BindingFlags.Public | BindingFlags.Static finds no match, this YamlException is thrown.

Solutions

  1. Update the property name in the YAML scalar to match the current public static field name
  2. Restore the original field name or add a public static field with that name in the class
  3. Verify the field is public and static (GetField only searches those)
  4. Re-save the asset in the Stride editor to rewrite the key reference

Example fix

// before
MyProperty: !MyNS.MyClass.OldKeyName value
// after
MyProperty: !MyNS.MyClass.NewKeyName value
Defensive patterns

Strategy: try-catch

Validate before calling

var field = keyClass.GetField(propertyName, BindingFlags.Public | BindingFlags.Static); if (field == null) { /* name no longer exists */ }

Type guard

bool HasPropertyKey(Type t, string name) => t?.GetField(name, BindingFlags.Public | BindingFlags.Static) != null;

Try / catch

try { value = ConvertFrom(ref context, scalar); } catch (YamlException ex) when (ex.Message.Contains("Unable to find property")) { log.Warn($"PropertyKey renamed/removed: {ex.Message}"); throw; }

Prevention

When it happens

Trigger: Deserializing a YAML asset whose scalar references ClassName.PropertyName where the class was found but no public static field with that exact name exists — e.g. the PropertyKey field was renamed, made non-static/internal, or deleted.

Common situations: Refactoring PropertyKey field names after assets referenced them; a key moved to another class without updating asset YAML; case-sensitivity mismatch between YAML and the C# field name.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/18f043ac5fb4e527. Report an issue: GitHub.

Appendix: source

Thrown at sources/assets/Stride.Core.Assets/Serializers/PropertyKeyYamlSerializer.cs:45

                return true;

        return false;
    }

    public override object? ConvertFrom(ref ObjectContext objectContext, Scalar fromScalar)
    {
        var lastDot = fromScalar.Value.LastIndexOf('.');
        if (lastDot == -1)
            return null;

        var className = fromScalar.Value[..lastDot];

        var containingClass = objectContext.SerializerContext.TypeFromTag("!" + className, out var typeAliased)
            ?? throw new YamlException(fromScalar.Start, fromScalar.End, "Unable to find class from tag [{0}]".ToFormat(className)); // Readd initial '!'

        var propertyName = fromScalar.Value[(lastDot + 1)..];
        var propertyField = containingClass.GetField(propertyName, BindingFlags.Public | BindingFlags.Static)
            ?? throw new YamlException(fromScalar.Start, fromScalar.End, "Unable to find property [{0}] in class [{1}]".ToFormat(propertyName, containingClass.Name));
        return propertyField.GetValue(null);
    }

    protected override void WriteScalar(ref ObjectContext objectContext, ScalarEventInfo scalar)
    {
        // TODO: if ParameterKey is written to an object, It will not serialized a tag
        scalar.Tag = null;
        scalar.IsPlainImplicit = true;
        base.WriteScalar(ref objectContext, scalar);
    }

    public override string ConvertTo(ref ObjectContext objectContext)
    {
        var propertyKey = (PropertyKey)objectContext.Instance;

        return PropertyKeyNameResolver.ComputePropertyKeyName(objectContext.SerializerContext, propertyKey);
    }

View on GitHub (pinned to 96fad776d2)