6

I'm getting Visual Studio Code Analysis warning CA1506 for a C# class. It says, "'FormMain' is coupled with 93 different (non-IComponent) types from 25 different namespaces. Rewrite or refactor this class's methods to decrease its class coupling, or consider moving some of the class's methods to some of the other types it is tightly coupled with. A class coupling above 95 indicates poor maintainability, a class coupling between 95 and 80 indicates moderate maintainability, and a class coupling below 80 indicates good maintainability."

My question is simply, where can I see a list of all of the types that FormMain is coupled to, so I can understand the situation better?

Thanks.

RenniePet
  • 11,420
  • 7
  • 80
  • 106
  • How many controls do you have on this form? How many lines of code in the form.cs file? – Hans Passant Jan 17 '11 at 15:42
  • I'm using Developer Express ribbon bar and docking panels. There are about 30 controls on the ribbon bar. Including blank lines and comments there are about 1600 lines (not counting FormMain.Designer.cs), of which about 800 lines are not blank lines or comments. – RenniePet Jan 17 '11 at 15:51

1 Answers1

4

You can use Reflector to analyze everything a class uses (right-click on the class, click 'Analyze', expand 'Depends On')

thecoop
  • 45,220
  • 19
  • 132
  • 189
  • Thank you very much. That looks very interesting, and I think the answer to my question is buried in that list. The only thing I'd like to know now is if there is some way to get a list containing only the types, and not all the methods within the types, just to make it easier for me to put numbers on the DevExpress types vs. .Net Framework types vs. my own types. – RenniePet Jan 17 '11 at 16:09
  • Funny, when I remove all of the methods from that list I get about 145 types in 20 namespaces, which isn't exactly what Code Analysis said in its warning message. Still, I'm now feeling confident enough in ignoring that warning, putting the blame for the "problem" on DevExpress. (DevExpress accounts for 70 types, .Net Framework for 40, and my own types for the remaining 30.) – RenniePet Jan 17 '11 at 16:48
  • @RenniePet - Do you have any business logic or database access code in the form? If so, moving that functionality to separate classes will also help reduce the form's dependencies. – Pedro Jan 18 '11 at 22:48