Domanda

All projects that I know - including Entity Framework (which is Microsoft itself!) - use "Db" instead of "DB". So they treat "Db" as an abbreviation. But FxCop treats the term as an acronym so you have to call it "DB". I have similar other terms that I like to be written like abbeviations. How do I force FxCop to do so? I want the same behavior as with "Id". Adding a custom dictionary is the first step I think, but to add "Db" to Dictionary/Acronyms/CasingExceptions is not enough. You are still able to call it "DB". "Db" is accepted but not forced. Somehow "Id" is really forced you are not allowed to call it "ID".

I've already taken a look at

"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\CustomDictionary.xml"

to figure out how they did it. But "Id" is not part of this default dictionary maybe there is another one?

Any ideas?


Additionally I don´t understand why "DB" is not handled as an abbreviation by default it´s an abbreviation for "database" like "Id" is an abbreviation of "identifier":

http://msdn.microsoft.com/en-us/library/ms182256(v=VS.80).aspx

Maybe because of some other exceptions where it is no abbreviation but an acronym? Lets say "Doggy Bag" ("DB")?

È stato utile?

Soluzione

The treatment of Id is hard-coded in Microsoft.FxCop.Rules.Naming.CasingWordParser.CheckAbbreviation() (at least in VS 10), and there's essentially nothing you can do to get wired into that logic.

As for why DB is considered to be an acronym rather than an abbreviation, it's probably because "database" was originally "data base". (The separate word form still seems to be in use, although it's pretty darn rare compared to the compound form.) According to the design guidelines, we shouldn't be using "db" at all if it's an abbreviation, so I guess we should consider ourselves lucky that it's considered an acronym in the first place. ;)

All that said, I've personally been finding the capitalization of two-letter acronyms increasingly unpleasant as time goes on. I find that it looks ugly and "exceptional", and it seems to be counter-intuitive for pretty much everyone who is introduced to the design guidelines for the first time. I've never seen an explanation for why the design guidelines team originally thought this might be a good idea, but I do have to wonder whether most of them might not wish they could reverse the decision if they had a chance to today.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top