fxcop

FXCop Custom Rule does not show up in RuleSet

别来无恙 提交于 2019-12-05 19:03:10
I followed the steps here to create a new custom rule and add it to the ruleset in VSStudio 2013: http://blog.tatham.oddie.com.au/2010/01/06/custom-code-analysis-rules-in-vs2010-and-how-to-make-them-run-in-fxcop-and-vs2008-too/ However, despite all my efforts, the custom rule does not show up in the ruleset file. If I add the rule in the FXCop Editor, it shows up and analyzes the target project correctly. This is the Rule File, which is an embedded resource in the project: <?xml version="1.0" encoding="utf-8" ?> <Rules FriendlyName="PSI Custom FxCop Rules"> <Rule TypeName=

Compare two fxcop results

徘徊边缘 提交于 2019-12-05 11:46:27
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. 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. Are you using UI or the command line? With the command line tool, you have a number of options. One of them is to

Custom Rule in FxCop to only apply to methods called by particular type's method

元气小坏坏 提交于 2019-12-05 10:18:05
I want to create an FxRule that applies a method, only if the method gets called from a specific class. NOTE: I don't want to just apply a rule to a method of a particular class, i want to be able to handle methods calling other methods calling other methods which do the boxing. I'd like to get FxCop to report problems associated with the method that does the boxing. Below is the code i have so far: using System; using System.Linq; using Microsoft.FxCop.Sdk; using System.Collections.Generic; class CheckUpdatableComponents : BaseIntrospectionRule { private string[] MethodsToCheck = new string[]

How to specify CodeAnalysisRules in MSBuild via commandline

落爺英雄遲暮 提交于 2019-12-05 10:15:45
I want to be able to specify the Code AnalysisRules in commandline MSBuild (for Code Analysis / FXCOP). The project file would have something like this in it: <CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302</CodeAnalysisRules> So I would assume that I use something like this: MSBuild.exe /property:RunCodeAnalysis=true /property:CodeAnalysisRules=-Microsoft.Globalization#CA1301 Which works fine, but when I want to add another rule, it does not like the semi colon: MSBuild.exe /property:RunCodeAnalysis=true /property:CodeAnalysisRules=-Microsoft.Globalization

Code Analysis CA1060 Fix

流过昼夜 提交于 2019-12-05 08:13:25
I have the following code in my application: [DllImport("user32.dll")] private static extern int GetWindowLong(IntPtr hwnd, int index); [DllImport("user32.dll")] private static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle); [DllImport("user32.dll")] private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter, int x, int y, int width, int height, uint flags); [DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam); I am getting the following warning from Code Analysis (FxCop): CA1060 : Microsoft

Why “Properties that return arrays are prone to code inefficiencies”?

断了今生、忘了曾经 提交于 2019-12-05 02:27:10
I have a piece of code which deals with customers stored in database. There is an object Customer , and it has, among other, two properties of type byte[] : one property for password salt, the second one for password hash. Checking the code with FxCop, I see that it complains ( CA1819 , Performance Rules ) that: "Properties that return arrays are prone to code inefficiencies. Consider using a collection or making this a method. See the design guidelines for more information." and suggests: "Change 'Customer.PasswordHash' to return a collection or make it a method." I don't really understand,

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

依然范特西╮ 提交于 2019-12-05 01:12:36
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 section, I added another class and another exception. public class MultiSomething { } //CA1704

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

偶尔善良 提交于 2019-12-05 00:15:06
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 changed, but don't mind if the state of the instance is changed (singleton maybe. /me prepares for

FxCop and Code Analysis Rules

你。 提交于 2019-12-04 23:19:56
问题 I recently started using Code Analysis on my projects in Visual Studio. I have created a custom ruleset to use with all of my projects that include two of the Microsoft defined rulesets. I've been working to integrate FxCop into the CI build process to fail builds that don't pass all rules. What's really odd to me is that I can't use my ruleset to define what rules FxCop scans the code against. How do I make it so Visual Studio's Code Analysis rules match up to FxCop's rules? 回答1: You already

ASP.NET MVC4 solution fails to build after installing KB2993928

笑着哭i 提交于 2019-12-04 18:08:54
问题 We have an ASP.NET MVC 4 solution with a couple of references that has been building without problems for about 2 years now. However, after installing KB2993928 and KB2993937 this morning, we cannot run FxCop on this solution on our Windows 7 machines anymore. I have a feeling this is because this update changed the DLL version of the System.Web.Mvc assembly in the GAC. This is because in the GAC I can currently find 3 different System.Web.Mvc DLLs, which are all updated today. The error we