Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Code Analysis - how to add custom dictionary?

;) Yeah. I also have C++ in my solution.

How do I add a custom dictionary there? There is no tool for an includes file, as well as no way to tell it the type is CustomDictionary.

THe advice and approach shown in http://msdn.microsoft.com/en-us/library/bb514188(v=VS.100).aspx is not usable for C++ projects.

like image 538
TomTom Avatar asked Dec 12 '22 22:12

TomTom


2 Answers

For VS2010, you can set the dictionary by editing your .vcxproj file and pasting this:

  <ItemGroup>
    <CodeAnalysisDictionary Include="c:\temp\mydictionary.xml" />
  </ItemGroup>

Modify the path to your dictionary.

To make this a permanent setting for all your C++ projects, navigate to c:\program files\msbuild\microsoft.cpp\v4.0 and edit Microsoft.Cpp.props, pasting the above (make a backup please).

To verify that the change is effective, use Tools + Options, Projects and Solutions, Build and Run, MSBuild project build log file verbosity = Diagnostic. Rebuild your project, look in the .log file and verify that fxcopcmd.exe got started with the /dictionary option.

Both approaches worked well on my machine.

like image 128
Hans Passant Avatar answered Dec 15 '22 12:12

Hans Passant


To get a CustomDictionary working with C++ you will have to edit the project file manually as described here.

like image 39
mathmike Avatar answered Dec 15 '22 12:12

mathmike