One tool you might think of that integrates seamlessly into your build is NDepend . This allows you to run various code metrics that you can then use to warn / fail builds.
In CQL (the built-in query language in NDepend) you should write something like:
WARN IF Count > 0 IN SELECT TYPES FROM NAMESPACES "namespace" WHERE !IsSerializable
Obviously, this will only find namespaces for the types that are included in the assemblies in your solution, but I assume that you mean it.
NDepend can start automatically as part of your build in VS or on a separate build server. It can also be run as a standalone application.
Rob Levine Jul 15 2018-10-15T00: 00Z
source share