Data assign before ContentType throws NullReferenceException
Closed this issue · 2 comments
justinyoo commented
When an event object is directly created, instead of using CloudEventFactory
, if Data
is assigned first than ContentType
, it throws the NullReferenceException
error.
// This throws an exception
var ev = new ObjectEvent()
{
Data = new { Hello = "World" },
ContentType = "application/json"
};
However, if ContentType
is defined first, followed by Data
, it's OK.
// This is fine
var ev = new ObjectEvent()
{
ContentType = "application/json",
Data = new { Hello = "World" }
};
justinyoo commented
The interim solution will be:
- Define
ContentType
first, then defineData
, or - Use
CloudEventFactory
to create anObjectEvent
,StringEvent
orBinaryEvent
.
justinyoo commented
Fixed and NuGet package v0.1.1 has been released