bitbonk
bitbonk

Reputation: 49659

resharper "cleanup code" vs. 'var' keyword

I have an odd behavior with code clean up for c# in visual studio 2008 Team Developer Edition.

Whenever I clean up my code using "Full Cleanup", it replaces all variables declaration with explicit type declarations. But I have set the appropriate settings under "Inspection Severity", "Use var keyword when initializer explicitly declares type" and "use var keyword when possible" to "Show as Error"

Is there any other setting I need to set or is this a known bug?

Upvotes: 8

Views: 4533

Answers (3)

Allan Bush
Allan Bush

Reputation: 21

In Build 5.0.1659.36 there is a bug - "Use 'var' in declaration settings" are not respected.

Upvotes: 2

RhysC
RhysC

Reputation: 1644

This certainly looks like a bug to me. the var=> type usage works but the type usage => var does not on all of the devs machine here at work (R# 4.5). Posting feedback to R# now.

Upvotes: 2

bdukes
bdukes

Reputation: 156065

There's a setting under the Code Cleanup section that specifies what Code Cleanup should do with var declarations.

In the ReSharper Menu, select Options. At the bottom of the tree view, select Code Cleanup (in the Tools section). Select a Code Cleanup preset on the right, and then look at the Use 'var' in declaration setting. You probably want the Replace direction setting set to Do not change.

Upvotes: 13

Related Questions