And*_*zub 12 .net c# spell-checking stylecop
对最近版本的StyleCop添加了对注释的拼写检查.我似乎可以使用StyleCop重用我现有的CustomDictionary文件(我为FxCop创建).SA1650规则文档没有说它是可能的.但在版本4.7.39的发行说明中,我看到了
添加对settings.StyleCop文件中指定字典文件夹的支持.
如何配置StyleCop以在我的解决方案的根文件夹中搜索此文件?
在我的情况下,当我在.csproj文件旁边的Settings.StyleCop文件中指定自定义词典条目时,它工作.
<GlobalSettings>
<StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
<CollectionProperty Name="RecognizedWords">
<Value>word1</Value>
<Value>word2</Value>
...
</CollectionProperty>
</GlobalSettings>
Run Code Online (Sandbox Code Playgroud)
实际上,StyleCopSettingsEditor.exe实用程序为我创建了这些设置.我使用"StyleCop设置"菜单项在Visual Studio中使用项目的上下文菜单打开它.
Settings.StyleCop使用以下内容添加解决方案根目录中指定的文件:
<StyleCopSettings Version="105">
<GlobalSettings>
<CollectionProperty Name="DictionaryFolders">
<Value>**my-dictionary-folder**</Value>
</CollectionProperty>
</GlobalSettings>
</StyleCopSettings>
Run Code Online (Sandbox Code Playgroud)
my-dictionary-folder使用包含CustomDictionary.xml文件的文件夹的相对路径替换的位置.
CustomDictionary.xml 文件应放置在与 StyleCop.dll 和规则相同的文件夹中。检查该文件夹(和所有子文件夹)中的字典文件。StyleCop 加载 CustomDictionary.xml、CustomDictionary.en-GB.xml,然后加载 CustomDictionary.en.xml(其中 en-GB 是在 Settings.StyleCop 文件中指定的区域性)。StyleCop 还会加载 custom.dic、custom.en-GB.dic,然后加载 custom.en.dic(其中 en-GB 是在 Settings.StyleCop 文件中指定的区域性)。还可以使用拼写选项卡上的设置编辑器将识别的单词添加到 Settings.StyleCop 文件中。
因此,您似乎必须将 CustomDictionary.xml 的副本放在该特定位置,而不是放在解决方案文件夹的根目录中。