Friday, February 3, 2012

Pro Tip: Code Analysis, IoC and Excessive Class Coupling

This is a quick tip:

If you’re using Visual Studio's Code Analysis to make your code better (and who isn’t?), you’ll obviously have a bit of a problem with any IoC bootstrapping because you’re most likely wiring up a LOT of interfaces and classes together in your bootstrapping logic.

This will result in the CA1506 "Avoid Excessive Class Coupling" warning

SuppressMessage to the rescue!

Just decorate your IoC bootstrapper class or method with this:
[SuppressMessage("Microsoft.Maintainability",
   "CA1506:AvoidExcessiveClassCoupling")]
public static class IoC
...
Problem Solved!

No comments:

Post a Comment