We recently upgraded InspectCode to version 2022.1.2 on our CI servers. Unfortunately, it caused our builds to fail due to the "InconsistentNaming" warning rule being triggered when services are injected into a CSHTML using @inject. The message we're getting is Name '' does not match rule 'Properties'. Suggested name is ''. It seems that an injected service is treated as a (private) property rather than a field.
The same warning is not triggered when I use the ReSharper VS 2022 Extension - Code Inspection.
We have multiple branches (main and release branches) where we need to have this fixed so we cannot use the ReSharped disabled InconsistenNaming comment as a fix in this case.
I tried to fix the issue by creating a user-defined rule for "Properties":
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=04659595_002Ded5d_002D4afe_002Da946_002D381094bd7781/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Properties (private)"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></Policy></s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=89f0556c_002D7b31_002D45c6_002Dbe4d_002D3f67743afff1/@EntryIndexedValue"><Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Properties (non-private)"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy></s:String>
Unfortunately, it only worked only on CS files, but not on CSHTML files.
Any advise how to fix this issue?