Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CA1701 / Custom Dictionary

In the CustomDictionary.xml, where / how do I put my entry to avoid these two warnings from VS2015 Code Analysis?

Warning CA1701 In resource 'xxx.yyy.Properties.Resources.resx', referenced by name 'LoggerMustSpecifyFilename' the discrete term 'Filename' in string value 'Filename must be specified.' should be expressed as a compound word. If 'Filename' refers to an API identifier, case it as 'FileName', otherwise split it into two words separated by a space.

Warning CA1701 In resource 'xxx.yyy.Properties.Resources.resx', referenced by name 'LoggerInvalidFilename' the discrete term 'filename' in string value 'The specified filename '{0}' is invalid.' should be expressed as a compound word. If 'filename' refers to an API identifier, case it as 'fileName', otherwise split it into two words separated by a space.

I don't want to suppress CA1701, nor do I want to change my string casing. I used the CustomDictionary.xml to block a few other warnings and those all work fine, just can't get rid of these last two.

like image 769
SledgeHammer Avatar asked Jul 18 '26 07:07

SledgeHammer


1 Answers

The problem is that Code Analysis uses it's own CustomDictionary, located at C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop or equivalent.

These can't be overridden with your own dictionary. There is a user voice for this issue.

For Filename in particular, it's this that is causing your problem:

<?xml version="1.0" encoding="utf-8" ?>
<Dictionary>
  <Words>
    <Unrecognized>
      <!-- .. snip .. -->      
    </Unrecognized>
    <Recognized>
      <!-- .. snip .. -->
    </Recognized>
    <Deprecated>
      <!-- .. snip .. -->
    </Deprecated>
    <Compound>
      <!-- .. snip .. -->
      <Term CompoundAlternate="FileName">filename</Term>
      <!-- .. snip .. -->
    </Compound>
    <DiscreteExceptions>
      <!-- .. snip .. -->
    </DiscreteExceptions>
  </Words>
  <Acronyms>
    <CasingExceptions>
      <!-- .. snip .. -->
    </CasingExceptions>
  </Acronyms>
</Dictionary>

(I've snipped the items out of the default dictionary that aren't relevant, there is a lot more)

You can either:

  1. Suppress the message
  2. Change your casing to match this custom dictionary
  3. Edit this default dictionary. This is particularly troublesome, as you would need to keep this in sync on all developer machines and on the build server.
like image 54
NikolaiDante Avatar answered Jul 19 '26 20:07

NikolaiDante



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!