当我注意到奇怪的时候,我正在浏览
PluralizationService
的来源.在课堂上有一些反映不同的多元化规则的私人词典.例如:
private string[] _uninflectiveWordList = new string[] { "bison","flounder","pliers","bream","gallows","proceedings","breeches","graffiti","rabies","britches","headquarters","salmon","carp","----","scissors","ch----is","high-jinks","sea-bass","clippers","homework","series","cod","innings","shears","contretemps","jackanapes","species","corps","mackerel","swine","debris","measles","trout","diabetes","mews","tuna","djinn","mumps","whiting","eland","news","wildebeest","elk","pincers","police","hair","ice","chaos","milk","cotton","pneumonoultramicroscopicsilicovolcanoconiosis","information","aircraft","scabies","traffic","corn","millet","rice","hay","tobacco","cabbage","okra","broccoli","asparagus","lettuce","beef","pork","venison","mutton","cattle","offspring","molasses","shambles","shingles"};
字符串中的四个破折号是什么?我没有看到他们在代码中处理,所以他们不是某种模板.我唯一可以想到的是那些被审查的咒语(“ch —-是”将是“底盘”),在这种情况下,实际上是伤害了可读性.有其他人遇到这个吗?如果我对实际的完整列表感兴趣,我该怎么看?
解决方法
从使用
Reflector看看反编译代码,我可以验证编译的版本在那里没有“—-”,但确实似乎是某种方式的某种审查.反编译代码在构造函数中有:
this._uninflectiveWordList = new string[] { "bison","herpes","chassis","hemp","shingles" };
正如你可以看到被审查的单词是“疱疹”,“底盘”和“大麻”(如果我遵循正确的话).没有一个我个人认为需要审查,这表明它是某种自动化系统.我会假设原始来源有它们,而不是被添加到某种预编译合并中(如果没有其他的,因为“—-”真的不足以说明应该替换什么).我可以想象,由于某些原因参考网站得到他们的审查.
汉斯·帕斯特也在与一个非常相似的问题的答案相关的评论:What does —-s mean in the context of StringBuilder.ToString()?.这解释说:“发布的引用源的源代码被推送通过过滤器,从源代码中删除令人反感的内容”.