visual studio - How to configure Re-sharper Cleanup? - Stack Overflow

admin2025-04-18  2

Whenever i run the re-sharper code cleanup on my file in VisualStudio the following happens: var somevariable = 5 is modified to IVariableType someVariable = 5 or var variable = new TypeClass() is modified to TypeClass variable = new() but i would like to retain it as it was with the usage of var. How do i change the cleanup configuration? Cheers!

Whenever i run the re-sharper code cleanup on my file in VisualStudio the following happens: var somevariable = 5 is modified to IVariableType someVariable = 5 or var variable = new TypeClass() is modified to TypeClass variable = new() but i would like to retain it as it was with the usage of var. How do i change the cleanup configuration? Cheers!

Share edited Jan 30 at 14:09 RiriB asked Jan 30 at 14:08 RiriBRiriB 32 bronze badges 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Jan 30 at 20:12
Add a comment  | 

1 Answer 1

Reset to default 1

I'll presume C# code and Visual Studio 2022.

Resharper "Clean Up" uses the syntax style settings. For C# var usage, choose "Extensions -> Resharper -> Options..." from the Visual Studio menu. In the left pane of the Options window, navigate to "Code Editing -> C# -> Syntax Style". Check the preferences for the settings for "'var' usage in declarations". See "Code Syntax Style: Implicit/Explicit Typing ('var' Keyword)" for an explanation of the settings.

If there is an .editorconfig file, it will override the Resharper settings. See "Code-style rule options" and "'var' preferences".

转载请注明原文地址:http://anycun.com/QandA/1744914317a89411.html