What is the correct way of adding a List property to a component?
In my application I have the following situation
[Serializable]
public class ChunkViewModel
{
public int Id { get; set; } = 123;
}
[Serializable]
public class ChunksHolder
{
public List<ChunkViewModel> Chunks { get; set; } = new List<ChunkViewModel>{new ChunkViewModel()};
}
[DataContract("WorldComponent")]
public class WorldComponent : EntityComponent
{
// Works just fine
public ChunkViewModel Chunk { get; set; } = new ChunkViewModel();
// Fails
// [NonIdentifiableCollectionItems] doesn't help
// [MemberCollection] doesnt help
public List<ChunkViewModel> Chunks { get; set; } = new List<ChunkViewModel>();
// Weirdly enough, this does work though
public ChunksHolder ChunksHolder { get; set; } = new ChunksHolder();
}
Adding a List directly to my component gave me a System.InvalidOperationException in CecilSerializerContext.AddSerializableType
System.InvalidOperationException: Could not find serializer for generic dependent type Torens.Presentation.ViewModels.ChunkViewModel when processing System.Collections.Generic.List`1<Torens.Presentation.ViewModels.ChunkViewModel>
Adding a regular object that contains a list, does work though.
Adding any of the xenko member attributes like NonIdentifiableCollectionItems doesn’t make a difference.
Using a different sort of collection like Dictionary or array doesn’t help either.
Any suggestions?