fxcop

Exclude complete namespace from FxCop code analysis?

被刻印的时光 ゝ 提交于 2019-11-26 20:55:25
问题 Is it possible to exclude a complete namespace from all FxCop analysis while still analyzing the rest of the assembly using the SuppressMessageAttribute ? In my current case, I have a bunch of classes generated by LINQ to SQL which cause a lot of FxCop issues, and obviously, I will not modify all of those to match FxCop standards, as a lot of those modifications would be gone if I re-generated the classes. I know that FxCop has a project option to suppress analysis on generated code, but it

Why is it considered bad to expose List<T>? [duplicate]

試著忘記壹切 提交于 2019-11-26 18:40:20
This question already has an answer here: List<T> or IList<T> 18 answers According to FXCop, List should not be exposed in an API object model. Why is this considered bad practice? 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> type, which allows your API consumers to use their own custom

Why is it considered bad to expose List<T>? [duplicate]

耗尽温柔 提交于 2019-11-26 06:32:47
问题 This question already has an answer here: List<T> or IList<T> [closed] 18 answers According to FXCop, List should not be exposed in an API object model. Why is this considered bad practice? 回答1: 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() )

Why/when should you use nested classes in .net? Or shouldn&#39;t you?

只愿长相守 提交于 2019-11-26 02:08:38
问题 In Kathleen Dollard\'s 2008 blog post, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn\'t like nested classes. I\'m assuming that the people writing FxCop rules aren\'t stupid, so there must be reasoning behind that position, but I haven\'t been able to find it. 回答1: 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):

CA2202, how to solve this case

戏子无情 提交于 2019-11-26 01:24:38
问题 Can anybody tell me how to remove all CA2202 warnings from the following code? public static byte[] Encrypt(string data, byte[] key, byte[] iv) { using(MemoryStream memoryStream = new MemoryStream()) { using (DESCryptoServiceProvider cryptograph = new DESCryptoServiceProvider()) { using (CryptoStream cryptoStream = new CryptoStream(memoryStream, cryptograph.CreateEncryptor(key, iv), CryptoStreamMode.Write)) { using(StreamWriter streamWriter = new StreamWriter(cryptoStream)) { streamWriter