Question

I have ReSharper naming rules set up such that 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 Id named 'id'.

I'd prefer to have my objects match the expectations of serializers rather than use 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? What about a conventions-based approach, like "Exempt any class whose name ends with 'Dto' or is in a namespace called 'Dto'? Additionally, I'd rather not use the special //disable rule XX comment blocks. I find them really distracting

 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
 }
Was it helpful?

Solution

You can disable inspection for any files. In the Resharper options, go to Code Inspection: Settings and click on "Edit Items to Skip". Add *.DTO.cs to the "File masks to skip" list.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top