fxcop

C# analysis fails without .pdb files

你。 提交于 2019-12-07 14:41:45
问题 I'm trying out the new C# plugin v3.0 with SonarQube 4.2. According to plugin documentation, I need .pdb files to run analysis which includes FxCop rules, and indeed I get a failure message when executing sonar-runner if said .pdb files are not present in the output folder; FxCop exits with code 1536. The thing is, the analysis seems to require .pdb files for ALL the binnaries, and the output folder contains several dependencies in addition to my own compiled code. These are NuGet packages

Compare two fxcop results

馋奶兔 提交于 2019-12-07 06:03:58
问题 I'm going to analysis two different versions of the same dll with fxcop. I would like to display only the differences between these two reports. Does anyone know if this is possible ? Thanks for your time. 回答1: Yes, it's possible, but there are no built-in tools available for this. One fairly simple approach would be to use a diff tool to compare the two reports. If the result is too noisy for you, another approach would be to roll your own tool to compare the XML of the two reports. 回答2: Are

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

北城以北 提交于 2019-12-06 14:50:01
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 someone help me with this? This violation usually stems from a couple of code patterns though you should

Is FxCop's CollectionPropertiesShouldBeReadOnly rule incompatible with the spring framework?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 14:07:44
FxCop has the CollectionPropertiesShouldBeReadOnly rule that complains if your class has some kind of collection property that clients can set. Instead, it suggests making the property read-only and supplying a Clear() method and Add() or AddRange() methods for changing the contents of the collection. I agree that makes for a cleaner and more controlled interface, but I'm struggling to make that interface work with the Spring framework. If I want to configure an object with a collection of collaborators, I have to expose some collection property to inject the collaborators into. I've looked

Getting to Microsoft.Office.Interop.Word.dll?

青春壹個敷衍的年華 提交于 2019-12-06 06:47:09
问题 When FxCop examines an assembly it gives the following error: The following reference assembly could not be found. The assembly is required for analysis and was referenced by Test.dll. Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c So, I did a search and found the file in: C:\Windows\assembly\GAC\Microsoft.Office.Interop.Word\12.0.0.0__71e9bce111e9429c However, the dialog in FxCop doesn't let me get past C:\Windows\assembly. It looks like

How to validate DataReader is actually closed using FxCop custom rule?

感情迁移 提交于 2019-12-06 06:30:12
问题 I have written couple of custom rules in for FxCop 1.36. I have written code to find weather an opened DataReader is closed or not. But it does not check which DataReader object is calling the Close() method so I can't be sure if all opened DataReader objects are closed!! 2nd: If I am a DataReader in an 'if/else' like if 1=2 dr = cmd.ExecuteReader(); else dr = cmd2.ExecuteReader(); end if In this case it will search for 2 DataReader objects to be closed. I am putting my code for more clarity.

Detect .NET Framework 3.5 SP1 Dependency (cmp. 3.5 w/o SP1)

走远了吗. 提交于 2019-12-06 03:33:38
问题 I'm using 3.5 SP1 on my machine, while our customers currently use 3.5 without SP1. I don't know any way in VS2008 to target the solution or project to 3.5 without SP1, only the 3.5 with SP1 I have installed. If we use functions or constructors not available in 3.5 w/o SP1 the code will not work properly. That is, I want to detect at compile time what would not work without SP1. So far we have done testing (in a VM or separate machine) to see if the application breaks, and it does break

Analysing FxCop / Code Analysis warning CA1506: AvoidExcessiveClassCoupling

房东的猫 提交于 2019-12-06 03:19:45
问题 I'm getting Visual Studio Code Analysis warning CA1506 for a C# class. It says, "'FormMain' is coupled with 93 different (non-IComponent) types from 25 different namespaces. Rewrite or refactor this class's methods to decrease its class coupling, or consider moving some of the class's methods to some of the other types it is tightly coupled with. A class coupling above 95 indicates poor maintainability, a class coupling between 95 and 80 indicates moderate maintainability, and a class

VS2010 code analysis. Suppress message CA1051:DoNotDeclareVisibleInstanceFields for all class members

久未见 提交于 2019-12-06 03:10:56
问题 I have a class like this one: public class Foo { public readonly int A = 1; public readonly int B = 2; } When I run VS2010 built in Code Analysis tool, I get 2 identical warnings: that ' field '...' is visible outside of its declaring type, change its accessibility to private and add a property, with the same accessibility as the field has currently, to provide access to it '. I want to suppress this warning for all fields in my class Foo , but I don't want to mark every field with

C# analysis fails without .pdb files

别来无恙 提交于 2019-12-06 01:49:34
I'm trying out the new C# plugin v3.0 with SonarQube 4.2. According to plugin documentation, I need .pdb files to run analysis which includes FxCop rules, and indeed I get a failure message when executing sonar-runner if said .pdb files are not present in the output folder; FxCop exits with code 1536. The thing is, the analysis seems to require .pdb files for ALL the binnaries, and the output folder contains several dependencies in addition to my own compiled code. These are NuGet packages and I cannot find symbol files for all of them. So, is there any way I can have the analysis to skip the