Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore ReSharper naming rules for DTOs

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
 }
like image 280
dan Avatar asked Jul 12 '12 23:07

dan


1 Answers

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.

like image 78
Cihan Yakar Avatar answered Sep 30 '22 07:09

Cihan Yakar