tags:

views:

364

answers:

3

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 var declaration with explicit type declarations. But I have set the appropriate settings under "Inspection Severity" "Use var keyword when initializer explictly 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?

+2  A: 

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.

bdukes
When I go to the Section "Code Cleanup" the right side remains blank. There are no profiles saved. I would always like to use "Full cleanup" but I can not change any settings for the profile Full cleanup because the list is empty.
bitbonk
You have to add a new profile of your own before you can edit the settings.
peteski22
+1  A: 

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.

RhysC
oh and ignore Mitch.. hes old skool.. go var! :p
RhysC
A: 

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

Allan Bush

related questions