NSubstitute.Analyzers
NSubstitute.Analyzers copied to clipboard
Respect VS naming styles when introducing substitute
Hello,
Thanks for your work on the Analyzer, it's a great package!
I wanted to start using it at work, but I found one issue with the introduce substitute code refactoring. Is it possible to respect the VS naming preferences, f.e. to create the substitutes with underscore prefix? I'm using this approach.
If no, perhaps the .editorconfig could be used?
I would be very happy to work on this improvement, just wanted to confirm first if it's technically feasible :)
Thanks
Just to follow up, I have checked the behavior using .editorconfig
.
So, I've added .editorconfig
to a project with the following rules:
[*.{cs,vb}]
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.severity = suggestion
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_fields.required_modifiers = readonly
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _
It's been detected by VS:
But still the introduced substitutes names are not starting with an underscore.
Hi @cieciurm
Thanks for your work on the Analyzer, it's a great package!
Glad you like it
Is it possible to respect the VS naming preferences, f.e. to create the substitutes with underscore prefix?
Not possible at the moment, related Roslyn API was not made public yet
https://github.com/dotnet/roslyn/issues/31655 https://github.com/JosefPihrt/Roslynator/issues/473#issuecomment-445164565 https://github.com/dotnet/roslyn/issues/22884#issuecomment-445173009
Thanks a lot for the explanation and the links