InspectCode version 2022.1.2 triggers "InconsistentNaming" warnings on injected services in CSHTML files

Hi,

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">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="Properties (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="PROPERTY" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=89f0556c_002D7b31_002D45c6_002Dbe4d_002D3f67743afff1/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Properties (non-private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="PROPERTY" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>

Unfortunately, it only worked only on CS files, but not on CSHTML files.

Any advise how to fix this issue?

2 comments
Comment actions Permalink
Official comment

Mhizole that issue is fixed in 2022.2.x versions. Release will be in a month, currently you can try EAP versions to see if it works for you.

Comment actions Permalink

Great to know that there is already a fix. We'll wait for the new version then. Thanks!

0

Please sign in to leave a comment.