Reputation: 5622
Can anyone recommend a way to block access to particular system classes in a particular assembly? For example I may want to block FileStream or other I/O classes in a class library that implements a certain layer that shouldn't involve I/O. It doesn't have to be insurmountable, the point isn't to combat hostile developers, only to reduce layering errors by team members (including myself) and easily identify such code by breaking the compile.
Upvotes: 1
Views: 257
Reputation: 15579
Seeing as though it sounds like your trying to "block" coding practices as opposed to executed code then I think you should look at FxCop and writing some custom rules.
You can then integrate FxCop into your build process and cause it to "break the build".
Upvotes: 6
Reputation: 14777
I don't think you could 'block access'. But you can analyze your codebase as part of the build. The only existing out-of-the-box solution I'm aware of is NDepend - it allows you to write explicit rules alike SQL. It is not free though.
Upvotes: 1
Reputation: 283614
If you want to block I/O, don't worry about blocking individual classes, use FileIOPermission
and block I/O.
Upvotes: 1
Reputation: 70369
If you have the source of that class library you could just define aliases for everything you want to block... these aliases would point to something "neutral" which throws an exception when accessed...
Upvotes: 0