IrishBruse / LDtkMonogame

Monogame importer, renderer and code generator for LDtk Level editor

Home Page:http://ldtk.ethanconneely.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when calling GetEntity or GetEntities for an Entity with an EntityReference property

PixelDough opened this issue · comments

I'm using source generation for my LDtk entities to have classes generated from their json objects, but when I try to get an object with an Entity reference as one of it's parameters, the game crashes with this error. If I remove the Entity Reference parameter, it works just fine.

System.NotSupportedException: JsonTypeInfo metadata for type 'LDtk.EntityReference' was not provided by TypeInfoResolver of type 'LDtk.LDtkJsonSourceGenerator'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.
   at System.Text.Json.ThrowHelper.ThrowNotSupportedException_NoMetadataForType(Type type, IJsonTypeInfoResolver resolver)
   at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type type, Boolean ensureConfigured, Nullable`1 ensureNotNull, Boolean resolveIfMutable, Boolean fallBackToNearestAncestorType)
   at System.Text.Json.JsonSerializerOptions.GetTypeInfoForRootType(Type type, Boolean fallBackToNearestAncestorType)
   at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
   at LDtk.LDtkFieldParser.ParseCustomFields[T](T classFields, FieldInstance[] fields, LDtkLevel level)
   at LDtk.LDtkFieldParser.ParseCustomEntityFields[T](T entity, FieldInstance[] fields, LDtkLevel level)
   at LDtk.LDtkLevel.GetEntityFromInstance[T](EntityInstance entityInstance)
   at LDtk.LDtkLevel.GetEntities[T]()

Fixed in pull request #30