Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect VS naming styles when introducing substitute #196

Open
cieciurm opened this issue Dec 5, 2022 · 3 comments
Open

Respect VS naming styles when introducing substitute #196

cieciurm opened this issue Dec 5, 2022 · 3 comments
Labels

Comments

@cieciurm
Copy link

cieciurm commented Dec 5, 2022

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

@cieciurm
Copy link
Author

cieciurm commented Dec 11, 2022

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:

image

But still the introduced substitutes names are not starting with an underscore.

@tpodolak
Copy link
Member

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

dotnet/roslyn#31655
dotnet/roslynator#473 (comment)
dotnet/roslyn#22884 (comment)

@cieciurm
Copy link
Author

Thanks a lot for the explanation and the links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants