Ignore ReSharper Naming Rules for DTO

I have ReSharper naming rules set, so all property names must be PascalCase. However, there are times when I have to use a different naming style to work with serialization. For example, backbone.js expects objects to have an identifier named 'id'.

I would prefer that my objects meet the expectations of serializers, rather than using fancy serialization attributes to change the way things are named. Is there a way to mark my DTO classes as such, so resharper doesn't complain about them? As for the convention-based approach, for example, “Free any class whose name ends with“ Dto ”or is in the namespace“ Dto ”? Also, I would prefer not to use special comment blocks //disable rule XX .

  public class PersonDto { public int id {get;set;} //i want resharper to accept this as a valid name, // but only in this context. public string Name {get;set;} public string _CID {get;set;} //some external api is sending me data named like this } 
+8
c # resharper
source share
1 answer

You can disable validation for any files. In the Resharper options, go to Code verification: settings and click "Edit items for skips." Add *.DTO.cs to the "File masks for skips" list.

+10
source share

All Articles