Reputation: 150
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.
Upvotes: 5
Views: 1280
Reputation: 51330
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.
Upvotes: 1
Reputation: 9201
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:
Upvotes: 5