fxcop
Why is it considered bad to expose List? [duplicate]
I agree with moose-in-the-jungle here: List<T> is an unconstrained, bloated object that has a lot of “baggage” in it. Fortunately the solution is simple: expose IList<T> instead. It exposes a barebones interface that has most all of List<T>‘s methods (with the exception of things like AddRange()) and it doesn’t constrain you to the specific List<T> … Read more
Why/when should you use nested classes in .net? Or shouldn’t you?
Use a nested class when the class you are nesting is only useful to the enclosing class. For instance, nested classes allow you to write something like (simplified): public class SortedMap { private class TreeNode { TreeNode left; TreeNode right; } } You can make a complete definition of your class in one place, you … Read more
CA2202, how to solve this case
You should suppress the warnings in this case. Code that deals with disposables should be consistent, and you shouldn’t have to care that other classes take ownership of the disposables you created and also call Dispose on them. [SuppressMessage(“Microsoft.Usage”, “CA2202:Do not dispose objects multiple times”)] public static byte[] Encrypt(string data, byte[] key, byte[] iv) { … Read more