You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TeamCity代码检查步骤为何无法一致应用命名规则?

问题:TeamCity代码检查命名规则生效异常

环境

  • 本地部署的TeamCity Professional 2024.03(版本156166)
  • 代码检查依赖CleanCode.sln.dotsettings中定义的自定义命名规则

自定义命名规则配置

<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="m_" Suffix="Id" Style="AaBb_AaBb"><ExtraRule Prefix="m_" Suffix="" Style="AaBb_AaBb" /></Policy></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="s_" Suffix="Id" Style="AaBb_AaBb"><ExtraRule Prefix="s_" Suffix="" Style="AaBb_AaBb" /></Policy></s:String>

测试代码

[TestFixture]
public class InspectionTest
{
   private int m_Id = 15;
   private static int s_Id = 30;
   
   [Test]
   public void Then_it_should()
   {
       Assert.AreEqual(15, m_Id);
       Assert.AreEqual(30, s_Id);
   }
}

代码检查报错

Name 'm_Id' does not match rule 'Instance fields (private)'. Suggested name is 'm_'.
Name 's_Id' does not match rule 'Static fields (private)'. Suggested name is 's_'.

异常现象

  • 按配置预期,m_Id(带m_前缀+Id后缀)、s_Id(带s_前缀+Id后缀)应该符合命名规则,但检查却判定不合法
  • 将字段名改为m_Idx和s_Idx后,报错立即消失
  • 改回原名称m_Id和s_Id后,报错不再出现

如何解释这一矛盾的现象?

内容的提问来源于stack exchange,提问作者JohnnyKuna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 15:25:06