Trying to enforce some rule using the editorconfig file. Following these instructions, but it does not work.
Tried reloading the solution, Format Document, and adding a new line in violation to test.
Have the following contents in the file:
[*.{cs,vb}]
dotnet_naming_rule.private_members_with_underscore.symbols = private_members
dotnet_naming_rule.private_members_with_underscore.style = underscore_prefix
dotnet_naming_rule.private_members_with_underscore.severity = suggestion
dotnet_naming_symbols.private_members.applicable_kinds = field
dotnet_naming_symbols.private_members.applicable_accessibilities = private
dotnet_naming_symbols.private_members.required_modifiers = readonly
dotnet_naming_style.underscore_prefix.capitalization = camel_case
dotnet_naming_style.underscore_prefix.required_prefix = _
dotnet_naming_style.underscore_prefix.required_suffix =
dotnet_naming_style.underscore_prefix.word_separator =
indent_style = tab
indent_size = 4
_This issue has been moved from https://developercommunity.visualstudio.com/content/problem/223832/editorconfig-process-does-not-work-in-visual-studi.html
VSTS ticketId: 590680_
_These are the original issue comments:_
(no comments)
_These are the original issue solutions:_
(no solutions)
Hi Eric,
I'm reviewing this issue to create a work item that someone can look at, but I'm having a bit of trouble understanding the specific scenario. Can you help me with the following questions?
Thank you,
Sam Harwell
So in the below case (assuming the setting are correct) the cartDao and commodityDao should be flagged. The correct naming should be _cartDao and _commodityDao
The setting I used were recommended on a website. I will try and find a link.
The should require all private member variables to be prefixed with an "_"
public class FieldDao : StorageLocationDao, IFieldDao
{
private ICartDao cartDao;
private ICommodityDao commodityDao;
}
I'm having the same issue. However, I have ReSharper installed and in my case, even though I've enabled the ReSharper setting to use EditorConfig rules, it seems not to recognize these naming rules in my .editorconfig file and instead prefer the naming rules set up in ReSharper's options.
@eschneider999 Are you perchance using ReSharper?
In the meantime, I'm going to search for and/or submit a bug with JetBrains.
@eschneider999 the problem lies in the following definition:
dotnet_naming_symbols.private_members.required_modifiers = readonly
By specifying readonly as a required modifier, this rule will only apply to private readonly fields. If you want it to apply to all private fields, you'll need to relax this rule.
If you are interested, I just created https://github.com/dotnet/roslyn/pull/28872 which includes this rule along with some other common default rules.
Just want to say: Good catch sharwell! In case anyone else comes here with a similar issue, in my case, I am not restricting to only readonly fields. But if anyone does have ReSharper and is experiencing issues with their EditorConfig naming rules showing the wrong severity type and/or rule being applied, I believe I found the relevant issue at JetBrains' IssueTracker for ReSharper and provided a comment which details the rule I was attempting to set up and how ReSharper did not attempt to use the EditorConfig rule.
Most helpful comment
So in the below case (assuming the setting are correct) the
cartDaoandcommodityDaoshould be flagged. The correct naming should be_cartDaoand_commodityDaoThe setting I used were recommended on a website. I will try and find a link.
The should require all private member variables to be prefixed with an "_"