How do I report a compile error if someone uses some classes from an external class library
We bought a collection of Windows Forms controls. In order to extend their functionality have created their own equivalents by inheriting from the base. Is there any way to prohibit the use of basic controls (bought), and force our programmers to use ours.
I would like if someone uses the base control (I do not have access to its source), then the compiler should report an error or warni开发者_如何学Pythonng and suggest to use my class (which inherits from the base).
Any ideas?
You can write a custom FXCop rule that would check this, then integrate this into your build process. With VS2010, fxcop can be a part of every build if you so choose - or you can run it as part of your CI build or nightly build, what have you.
You could accomplish this via a Post-build event. Create a little exe, that opens up each project in your solution. Reads each type in the assembly and makes sure no instances of the wrong types are created.
精彩评论