简体   繁体   中英

Visual Studio How To Check if all public members of Class are defined in Interface

Is there a tool or a Analysis possiblity in Visual Studio that could find the public memebrs (methods, fields, properties) of a Class who are not defined in the Interface of that Class. This would be a good help I would like to have for my code reviews.

If you want to make sure that all of you public members are defined in your Interface, you can use Visual Studio's capability of extracting an interface and compare it to your interface.

You can do this by:

  1. Right-Clicking on the class name
  2. Refactor
  3. Select "Extract Interface"

I also recommend using FxCop (can be downloaded here ) for your code analysis. It also has a plugin for integrating in Visual studio.

在此处输入图片说明

if you want to find unused cod than use ReSharper.

Right click on your solution and selection "Find Code Issues". One of the results is "Unused Symbols". This will show you classes, methods, etc., that aren't used.

or

FxCop, which is built into higher editions of Visual Studio, will warn of unused private or internal members. Right-click your project and choose Run Code Analysis. In conjunction with "unreachable code segments" being identified by the compiler as others have noted, this should catch the remaining unused code.

Find Dead Code

What you need is NDepend . It is a static code analysis tool with a Code Query Language to check every possible aspect of the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM