I have a class with a property of type List<SomeEnum>. Something like this:
public enum MyEnum
{
A,
B
}
public class MyClass
{
public string Id { get; set; }
public List<MyEnum> Values { get; set; }
}
I'm already using the EnumRepresentationConvention in this way:
ConventionRegistry.Register("EnumStringConvention", new ConventionPack { new EnumRepresentationConvention(BsonType.String) }, t => true);
Still, the Values property gets serialized as an array of ints (simple enum properties are correctly handled as ints). It seem the convention is not used in the context of the list serialization.
How can I enforce the serializer to write strings instead of ints?