fxcop

Do I need to worry about link-demands in a full-trust only .EXE?

好久不见. 提交于 2019-12-13 18:08:50
问题 I'm trying to understand FxCop CA2122 messages (probably before disabling the wretched things), and I have clearly overstepped my understanding of .NET CAS. The application is a .EXE, not marked with AllowPartiallyTrustedCallers. We get CA2122 warnings from Code Analysis, complaining about our failure to propagate LinkDemands upwards from the lowest level of calls to methods which themselves have LinkDemands. Obviously we can run around putting LinkDemands on callers, and then callers of

How to use FxCop analysis with the new MsBuild Sonar runner?

拟墨画扇 提交于 2019-12-13 13:52:55
问题 I am trying to migrate from the old Sonar runner to the new MsBuild Sonar runner in a .NET project. The last problem I have is doing the FxCop analysis. If the quality profile in Sonar contains any FxCop rules, I get the following build error: ERROR: Caused by: The property "sonar.cs.fxcop.assembly" must be set and the project must have been built to execute FxCop rules. This property can be automatically set by the Analysis Bootstrapper for Visual Studio Projects plugin, see: http://docs

Jenkins FxCop errors should fail the build

我的梦境 提交于 2019-12-13 04:08:31
问题 I have a FxCop.project file which i call using a Jenkins job "C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe" /project:"D:\Testing\Source\FxCop\BrokerApplication.FxCop" /out:"D:\Testing\Source\FxCop\BrokerApplication.xml" What i want is to fail the job if there are any FxCop errors. Is there anyway to do this ? 回答1: After googling for hours I found a partial answer here and decided to update it to an executable. You can find my solution here. How to run it: Checkout FxCopParser.exe

Why do I get Code Analysis CA1062 on an out parameter in this code?

萝らか妹 提交于 2019-12-12 07:54:46
问题 I have a very simple code (simplified from the original code - so I know it's not a very clever code) that when I compile in Visual Studio 2010 with Code Analysis gives me warning CA1062: Validate arguments of public methods. public class Foo { protected static void Bar(out int[] x) { x = new int[1]; for (int i = 0; i != 1; ++i) x[i] = 1; } } The warning I get: CA1062 : Microsoft.Design : In externally visible method 'Foo.Bar(out int[])', validate local variable '(*x)', which was reassigned

FxCop: Returning Matrix as Property (C#)

家住魔仙堡 提交于 2019-12-12 04:13:00
问题 I have a static class 'Defaults' which shall hold default matrices that are forwarded to an interface that asks for double[][] in the end. So far I simply put static properties in this class that return double[][] s. Now to make this conform to our company's coding standards, the code must comply to FxCop's rule CA1819, which won't allow me to return a jagged array from a property like I did. And instead of arrays, I shall return IList or IEnumerable (as discussed here). "Fair enough" I

Overridable Methods In Constructors -Help to Fix

半城伤御伤魂 提交于 2019-12-11 09:03:37
问题 Im attempting to use fxCop on a C# Project as kind of basis for C# coding standards. The project Im using is called S#arp Architecture and is freely available here: S#Arp Arch Now if I run fxCop (most things have been fixed already) I need to fix the CA2214 fxcop error for overridable methods in contructors. At the moment a piece of violating code looks like this: public class Region : Entity, IHasAssignedId<int> { public Region(string description) { Check.Require(!string.IsNullOrEmpty

How to configure FxCop in SonarQube 6.2

可紊 提交于 2019-12-11 07:28:50
问题 I am having hard time while trying to configure FxCop with SonarQube 6.2 along with TFS Continuous Integration Build 2015. I could able to successfully configure TFS build definition with SonarQube 6.2 and it is running perfectly fine but couldn't able to integrate FxCop into it. I couldn't able to find any plugin for FxCop in the SonarQube website and also, most of the viable solutions available in the internet for FxCop integration with SonarQube along with TFS Build definition are

using object initializer generates CA 2000 warning

不羁的心 提交于 2019-12-11 06:59:08
问题 Following code generates a CA2000 warning: Myclass myclass = null; try { myclass = new Myclass { Name = "a name" }; } finally { if (myclass != null) { myclass.Dispose(); } } i found some topics with the same problem and as I understand the problem is, that the compiler generates for the constructor a temporary variable and for this variable I'm not calling Dispose(). var tmp = new MyClass(); tmp.Name = "a name"; myclass = tmp: so my question is, if there is a solution with using object

How do you disable Roslyn Analyzers when using msbuild through the command line?

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:05:11
问题 The Roslyn Analyzers are installed as nuget packages, which are dependencies of the FxCop Analyzers (also installed as nuget packages). I have enabled full solution analysis as instructed here: How to Enable and disable full solution analysis for managed code. I have a fairly large solution with most of the projects using the FxCop/Roslyn Analyzers and Visual Studio builds fine, usually in under a minute. However, when running msbuild through the command line using: "C:/Program Files (x86)

FXCop casting Warning

痞子三分冷 提交于 2019-12-11 01:29:11
问题 I get the following error when running FXCop: CA1800 : Microsoft.Performance : 'obj', a variable, is cast to type 'Job' multiple times in method 'ProductsController.Details(int, int)'. Cache the result of the 'as' operator or direct cast in order to eliminate the redundant castclass instruction Code: object obj = repository.GetJobOrPlace(jobId);//Returns (object) place or (object) product if (obj != null) { if (obj is Job) { Job j = (Job) obj; Debug.WriteLine(j.Title); } else if (obj is Place