Ignore ReSharper naming rules for DTOs
Asked Answered
T

1

9

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
 }
Tema answered 12/7, 2012 at 23:31 Comment(0)
S
12

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.

Sporran answered 13/7, 2012 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.