How to detect a buggy DataContract class?

33 Views Asked by At

Is it possible to detect the following situation (with a compiler warning or with an external tool):

public class SomeItem
 {
     public string ValueOne { get; set; }
     public string ValueTwo { get; set; }
 }

[DataContract]
 public class Response
 {        
     [DataMember]
     public List<SomeItem> Items { get; set; } //A desirable warning: SomeItem is NOT a DataContract, SomeItem has no member with the DataMember attribute.
 }

The problem is that this code can be compiled without an error or a warning, but it doesn’t work properly: Items will always be empty.

0

There are 0 best solutions below