Open amanda-mitchell opened 5 years ago
IReadOnlyCollection
or IReadOnlyList
?
All properties should be nullable.
IReadOnlyList
We have a converter for DateTimeOffset, is that being deprecated?
I recommend deprecating the DateTimeOffset
converter.
Using converters makes it more difficult to create intelligible error messages when deserialization fails—particularly in the case of parameters to ASP.NET actions, where a failure to deserialize results in a 500 instead of a 400.
While this is still something of an issue with type mismatches (for example, a number where a string is expected), I don't see a compelling reason to exacerbate the problem, especially when the first thing we usually do with a DTO is to convert it to/from a domain object, which can have a wider variety of types on it.
Additional recommendation: Dto
types should be sealed
.
If a type is used with JSON-serialization methods (for example
JsonUtility.ToJson
), raise a warning if the type does not have aDto
suffix.For types that do have a
Dto
suffix, verify that all properties are auto-implemented and are of "approved" types:Dto
suffixReadOnlyCollection
/IReadOnlyCollection
of any of the aboveReadOnlyDictionary
IReadOnlyDictionary
from string to any of the above.These will definitely need to be warnings, given the number of historical violations that we have.