Avro.Net Serializer ignores attributes
I am using .Net library for Avro. I have the following class in C #
namespace Test.Avro.Model
{
[DataContract(Name = "SensorDataValue", Namespace = "Sensors")]
public class TestNm
{
[DataMember(Name = "name")]
public string name { get; set; }
[DataMember(Name = "surname", IsRequired = true)] //test to see if IsRequired works
public string surname { get; set; }
[DataMember(Name = "country", IsRequired = false)] //test to see if IsRequired works
public string country { get; set; }
}
}
When I wrote the class as an avro file using SequentialWriter, how stayed in Serialization using object container files and reflection serialization ( http://azure.microsoft.com/en-us/documentation/articles/hdinsight-dotnet-avro- serialization / ) I am getting the following json in the avro file
Objavro.codecdeflateavro.schemaÆ{
"type": "record",
"name": "Sensors.SensorDataValue",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "surname",
"type": "string"
},
{
"name": "country",
"type": "string"
}
]
} ...
What I would like to have is
Objavro.codecdeflateavro.schemaÆ{
"type": "record",
"name": "Sensors.SensorDataValue",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "surname",
"type": [
"string",
"null"
]
},
{
"name": "country",
"type": [
"string",
"null"
]
}
]
}...
Many thanks for your help. PS: the only relevant information I could find was https://hadoopsdk.codeplex.com/workitem/53
+3
source to share