I'm writing a unit test to verify that the serializable attributes are set on my class. I thought I was on the right way, but for some reason I can't find the attribute types.
Here is my class:
[DataContract]
public class User
{
[DataMember]
public int Id { get; set; }
}
And a unit test for checking the attributes:
[Test]
public void DataMembersSetAsExpected()
{
var type = typeof(User);
Assert.That(type.IsDefined(typeof(System.Runtime.Serialization.DataContractAttribute), true));
var idProperty = type.GetProperty("Id");
Assert.That(idProperty.IsDefined(typeof(System.Runtime.Serialization.DataMemberAttribute), true));
}
The problem here is that the types of the attributes are unknown. Where can I find the right attribute definitions?
System.Runtime.Serialization.DataContractAttribute
System.Runtime.Serialization.DataMemberAttribute