Is it DTO or Dto? FxCop can't decide.

Okay, I give up. Sure this might be minor to some but it's bugging the heck our of me this fine morning. 

FxCop is a great tool. Sure, there are sometimes a few too many warning messages that it yells at you with and sometimes it suggests stupid things but for the most part it's yet another good tool to use to give your assemblies a sanity check. I ran one of our systems through FxCop to see what would come up, if there was anything we majorly missed and if there was something we should go back and refactor.

FxCop is just plain retarted when it comes to the Data Transfer Object pattern. We have a folder in our domain called DTO that appropriately holds any Data Tranfer Objects we create. Of course a folder in a .NET project creates a new namespace but that's fine. So we have our namespace called AppName.DTO (it's not AppName but you get the idea) and there are several DTO classes in there for a Project, a Task, etc. Naturally we named these ProjectDto, TaskDto, etc.

So first FxCop didn't like the namespace AppName.DTO and complained with the LongAcryonymsShouldBePascalCased error. Fair enough. So that means we should renamed the namespace to AppName.Dto to make it stop complaining. However right afterwards it complained with the IdentifiersShouldBeSpelledCorrectly when it hit our ProjectDto class, moaning that it didn't recognize the token 'Dto' in the class name.

So which is right?

  1. AppName.Dto.ProjectDto
  2. AppName.Dto.ProjectDTO
  3. AppName.DTO.ProjectDto
  4. AppName.DTO.ProjectDTO

I can't seem to find a combination that FxCop won't complain one way or another between the namespace and class names.

Update: Thanks to Joe for the clarification. It's not really FxCop that's braindead about Data Transfer Objects, it's the guy creating them (yeah, that would be me).


  • AppName.Dto.ProjectDto is correct.

    But you will need to create a custom dictionary (CustomDictionary.xml) to tell FxCop that "dto" is a legal word.

    I usually put the custom dictionary in the same directory as the FxCop project file.

  • The basic rule (broken by assorted .NET Framework objects) is: Acronyms should always be Pascal cased. Unless they are only two letter acronyms (like IO). Irritated the graphics guys (Gif, Jpeg, etc.) I imagine.

    Personally, I would have set your namespace to DataTransferObject, but then I live for Intellisense.

    TTFN - Kent

Comments have been disabled for this content.