我们在本地使用 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_Idx和s_Idx后,检查错误消失。如果您再次恢复,将不再出现检查错误。 请与我们联系以获取更多信息。如何解释这种行为?
您在 TeamCity 上使用哪个 ReSharper CLT 版本?对于最新的 2024.1.3 版本,请尝试将以下字符串添加到 .dotSettings 文件
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue"><Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="m_" Suffix="" Style="AaBb" /></Policy></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue"><Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="s_" Suffix="" Style="AaBb" /></Policy></s:String>