I want to create a custom policy for Resharper so that it recommends 'var' iff the actual type is specified on the right hand side of '=' immediately after the 'new' keyword, and to disable the recommendation to use 'var' otherwise.
Is this possible? If so, how?
Thanks.
You don't need a custom rule for that, there's already an option in ReSharper 9
. I cannot confirm it's there for the previous versions.
You can find it by going to the ReSharper
tab, select Options...
, and in the pop-up go to Code Editing
, C#
and finally Code Style
.
Change the options for the first section from Use 'var'
to Use 'var' when evident
.
This results in the following:
You actually have two different type of notifications:
The first one is a suggestion, the second one is a hint.
So you can simply click on the (second in this case) notification to show the bulb:
Then select "Do not show". It won't affect the other suggestion.
You can save to the settings layer you want after that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With