fxcop

FxCop Custom Rule - Inspecting winform control properties

寵の児 提交于 2019-12-10 19:38:15
问题 I am looking for an example of a FxCop Rule that inspects the properties of controls created. Has anyone seen one? Or know how to respond to a property set in the FxCop SDK? Rich. 回答1: This is definitely not difficult. Just filter for types that inherit from Control and then get a list of fields (if I remember correctly). You may be better off asking this at the http://str8.to/fxcop-forum - they are very much active and I've had pretty great support there. Good luck! 回答2: My solutionwas to

What Replaces Code Analysis in Visual Studio 2019?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 12:50:29
问题 I'm toying with getting our team and projects ready for VS 2019. Right away, trying to set up Code Analysis for a new project, I find this: So, if this is deprecated (and apparently can't even be used, so I'm thinking "deprecated" really means "gone"), where are we supposed to set up our Rule Sets? Is there some other location, or perhaps an altogether new solution to the problem of style and code quality? 回答1: Going forward, static analysis will be provided by Roslyn analyzers: https:/

CA1704 - Microsoft seems to be blocking the word 'Multi'?

风格不统一 提交于 2019-12-10 01:47:57
问题 public class MultiSomething { } //CA1704:IdentifiersShouldBeSpelledCorrectly When I run Code Analysis, I get an error because the Microsoft does not recognize the word 'Multi' (go figure they use it in IMultiValueConverter ). So, what I did to correct this was to add a CodeAnalysisDictionary.xml file and followed the steps supplied here. However, it doesn't seem to solve the situation, I still get a Code Analysis warning message. To ensure that this isn't a bug with the recognized words

Do not declare read only mutable reference types - why not?

柔情痞子 提交于 2019-12-10 01:16:39
问题 I have been reading this question and a few other answers and whilst I get the difference between changing the reference and changing the state of the current instance I'm not certain why this means that I shouldn't mark it readonly. Is this because marking something as readonly tells the compiler something special about the instance and so it is able to then treat it as thread safe when it actually might not be? Presumably there are situations where I don't want the instance to be able to be

How can the cyclomatic complexity be 27 in a method with 13 event handler subscriptions?

落爺英雄遲暮 提交于 2019-12-09 16:52:12
问题 We have this code, sortof: private void InitializeEvents() { this.Event1 += (s,e) => { }; this.Event2 += (s,e) => { }; this.Event3 += (s,e) => { }; this.Event4 += (s,e) => { }; this.Event5 += (s,e) => { }; this.Event6 += (s,e) => { }; this.Event7 += (s,e) => { }; this.Event8 += (s,e) => { }; this.Event9 += (s,e) => { }; this.Event10 += (s,e) => { }; this.Event11 += (s,e) => { }; this.Event12 += (s,e) => { }; this.Event13 += (s,e) => { }; } Code analysis in VS10 Ultimate says "cyclomatic

How to prevent FxCop from analyzing auto-generated code?

隐身守侯 提交于 2019-12-09 15:27:21
问题 FxCop (tool for static code analysis) gives me an error while checking code behind of .edmx model. How to prevent FxCop from analyzing auto-generated code (or at least Entity Framework generated classes)? 回答1: I have moved to Visual Studio Code Analysis, as it gives me the same functionality as FxCop. From FxCop blog: "That's correct, they are different products (FxCop and VS Code Analysys), however they do have a common engine. Visual Studio 2008 SP1 already comes with the same fixes and

How to implement dispose pattern with close method correctly (CA1063)

亡梦爱人 提交于 2019-12-08 16:14:56
问题 The Framework Design Guidelines (2nd Ed., page 327) say: CONSIDER providing method Close() , in addition to the Dispose() , if close is standard terminology in the area. When doing so, it is important that you make the Close implementation identical to Dispose and consider implementing IDisposable.Dispose method explicitly. So, following the provided example, I've got this class: public class SomeClass : IDisposable { private SomeDisposable someInnerDisposable; public void Open() { this

CA1819: Properties shouldn't return arrays - What is the right alternative?

和自甴很熟 提交于 2019-12-08 14:58:41
问题 I encountered this FxCop rule before and wasn't really content with how to solve violations (thread1, thread2). I now have another case where I need to correct violations of the CA1819 kind. Specifically, I have an algorithm-library that performs some analytic calculations on a curve (x,y), with a public "input object" like this: public class InputObject { public double[] X { get; set; } public double[] Y { get; set; } // + lots of other things well } This object's X and Y properties are used

“CA2000: Dispose object before losing scope” building Unity container

两盒软妹~` 提交于 2019-12-08 04:36:20
问题 I am using following code where I am getting fxCop voilation CA2000: Dispose object before losing scope: private static IUnityContainer BuildContainer() { var container = new UnityContainer().LoadConfiguration(); return container; } to remove this violation I have used following code: private static IUntyContainer BuildContainer() { using(var container = new UnityContainer()) { return container.LoadConfiguration(); } } But this code start throwing exception while resolving dependencies. Can

FxCop analysis not finding indirectly-referenced assemblies - GAC issue?

落花浮王杯 提交于 2019-12-08 04:18:41
问题 I am running my DLL against FxCop and it is returning problems as seen in the image here (It also complains about System.Windows.Browser and System.Core, same versions): I have told FxCop to search the GAC and it isn't helping. I do have System.Runtime.Serialization referenced in my project but it is showing as version 4.0.0.0. I do not see this particular version of the file anywhere. Although I can skip it means it fails when I use FxCop Integrator in Visual Studio and I don't know what