RiriB
RiriB

Reputation: 3

How to configure Re-sharper Cleanup?

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!

Upvotes: 0

Views: 21

Answers (1)

Jonathan Dodds
Jonathan Dodds

Reputation: 5163

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".

Upvotes: 1

Related Questions