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

不羁的心 提交于 2020-01-13 08:21:09

问题


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

Thanks a lot.


回答1:


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.



来源:https://stackoverflow.com/questions/6613316/how-to-change-default-access-modifier-in-resharper-r-to-internal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!