Describe the bug
I have an issue where I have an event that contains a TimeOnly
type which was added in .NET 6. Sadly .NET 6 does not come with build in JsonConverter
for TimeOnly
and DateOnly
.
These are easily to implement as a custom JsonConverter
however there are no way to add these converter to the Event Store.
A "workaround" is to add the converters to the TimeOnly/DateOnly properties in the event object through JsonConverterAttribute
, like so:
[StreamEvent("event-name:v1")]
public record TimeEvent(
[property: JsonConverter(typeof(JsonTimeOnlyConverter))]
TimeOnly Time,
This works for simple cases but not if the I have more complex objects that contains TimeOnly
further down. Then I would have to make custom converters for these types, only to be able to handle deserialization of a single properties within it.
My code could also end up with a lot of these attributes if a have a lot of different events requiring custom converters.
To Reproduce
Steps to reproduce the behavior:
- Create an event with a
TimeOnly
or DateOnly
type
- Write the event to the event store
- An exception is thrown with the error
System.NotSupportedException : Serialization and deserialization of 'System.DateOnly/TimeOnly' instances are not supported
Expected behavior
I am able to add custom JsonConverters
to the Event Store client that are used when writing to, or reading from, the Event Store.