Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default access modifier in Resharper (R#) to internal

Tags:

resharper

By default Resharper creates all methods, properties, and classes as public. Does anybody know how to change it to internal instead?

Thanks a lot.

like image 659
Vlad Bezden Avatar asked Jul 07 '11 15:07

Vlad Bezden


1 Answers

As far as I know there's no way to do that out of the box in ReSharper. In many cases ReSharper goes the safest path when setting visibility to the code it generates but apparently there is some visibility heuristics in place, especially when it comes to generating type members.

ReSharper provides a more general-purpose way of ensuring that you have visibility set to a necessary minimum. If you turn on solution-wide analysis, it will trigger code inspections that will look how members are actually used, and suggest that you make certain members private, protected etc, depending on the results of usage analysis. As soon as you see a code inspection like this, you can press Alt+Enter and select "Find similar issues", set a scope, and get the list of all members in the given scope for which visibility can be reduced. Note that "Find similar issues" is only available starting from ReSharper 6.

Alternatively, you can right-click a node in Solution Explorer, select Find Code Issues, and as soon as you have the list of all found issues, set filters to only show visibility problems (this would be a set of inspections under "Common practices and code improvements"). This can be done in ReSharper 5 or higher.

Irrelevant of which way you choose, you'll need to turn solution-wide analysis on beforehand.

like image 171
Jura Gorohovsky Avatar answered Oct 17 '22 16:10

Jura Gorohovsky