Questions tagged [fxcop]

Microsoft's free static analysis tool for analyzing .NET managed code assemblies.

FxCop can be used to find coding design issues quickly and early, comes with switchable rulesets, and supports the creation of custom rules.

Available with certain versions of Visual Studio and as part of the Windows 7 SDK, available here.

749 questions
0
votes
3 answers

Does identifier casing really matter?

FxCop thought me (basically, from memory) that functions, classes and properties should be written in MajorCamelCase, while private variables should be in minorCamelCase. I was talking about a reasonably popular project on IRC and quoted some code.…
Kawa
  • 1,478
  • 1
  • 15
  • 20
0
votes
2 answers

How to Add Custom Rule to FXCop for avoiding == operator inside the method

I want to add a Custom rule for avoiding the '==' operator inside a method in a class. For example in the below method i need to avoid 'str1==str2' with string.Compare(str1, str2,StringComparison.Ordinal);.So I need to check this types of code are…
Jameel
  • 81
  • 5
0
votes
2 answers

How should I expose a generic List as a property in a .NET API when the property can legitimately be null?

I am trying to create a .NET API which wraps and interfaces with a third-party C API. As such the semantics of the API are as follows: There is a property which represents a list of strings in a binary file. There is a distinction to be drawn…
JimEvans
  • 27,201
  • 7
  • 83
  • 108
0
votes
1 answer

Is calling process.start a security risk from an azure worker role?

We have a worker role in Azure which uses Process.Start to kick off a background process (which hosts a native application we need to run) FxCop gives me a whole load of CA2122 errors due to a link demand. When I tried to add this…
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
0
votes
2 answers

Do I need to provide an IFormatProvider when converting a date to a string with a specific format?

If I'm using this: DateTime.Now.Date.ToString("yyyy-MM-dd") FXCop complains that I'm violating CA1305 and says that I should provider an IFormatProvider. Do I need to? I'm asking for the date in a specific format anyway (which is the format I'm…
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
0
votes
1 answer

Exclude Class/Methods while using FxcopIntegrator

While integrating FxCop with visual studio, i found [FxCop Integrator]( http://fxcopintegrator.codeplex.com) Though this seems to be a very good tool (which almost eliminates the need to run FxCop independently), i could not find way to exclude…
Ujjwal
  • 386
  • 3
  • 18
0
votes
1 answer

FxCop fails to analyse the indirectly referenced assembly

Metrics.exe: error: The referenced assembly 'Exception.dll, version=1.0.5289.9, Culture=neutral, publickeytoken=67er8..' could not be found. This assembly is required for analysis and was referenced by \bin\cancel.dll. But the assembly it is trying…
ashish g
  • 281
  • 3
  • 7
  • 14
0
votes
1 answer

Pass dictionary to FxCop GUI

I would like to open FxCop.exe (not the command line version) from VS 2010 with custom dictionary (Stored in a given path, not necessarily in FxCop folder) as a parameter. Can someone tell me how to do this?
Arun
  • 2,217
  • 3
  • 17
  • 18
0
votes
1 answer

Source implementation available for FxCop rule CA2241 (Provide correct arguments to formatting methods)?

I'm attempting to implement my own version of CA2241 using the VisitMethodCall override. It works if the number of arguments to String.Format are 5 or fewer, but always shows only 2 arguments if there are 6 or more arguments (including the format…
Glenn
  • 1,687
  • 15
  • 21
0
votes
1 answer

Built-in FxCop rule for avoiding unnecessary Boxing and Unboxing

Is there a built-in FxCop rule that analyses for unnecessary Boxing/UnBoxing? The following example shows a method, WeaklyTyped, which violates the rule and a method, StronglyTyped, which satisfies the rule. using System; namespace…
Vivin joy
  • 97
  • 7
0
votes
1 answer

FxCop rule to ensure that each class has a unique identifier

In our API library, we have a number of classes that implement a method ComputeCurrentDefinitionHashCode, which combines the hash codes of each member field with a pseudo-random number that should be unique to that class. This is based on Paul…
0
votes
2 answers

Is it possible from within the csproj file to know whether devenv or msbuild is used to run it?

Motivation: I have fxcop integrated in the build process, which makes fxcopcmd.exe run each time the target has changed or as long as there are warnings from the previous run of fxcop. But when one works in the studio, devenv.exe often decides to…
mark
  • 59,016
  • 79
  • 296
  • 580
0
votes
3 answers

FxCop and memory leak hunting

According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and…
Andriy Zakharko
  • 1,623
  • 2
  • 16
  • 37
0
votes
1 answer

Create FxCop .ruleset file using free tools

How can I create a .ruleset file for FxCop, using only MSVS 10 Professional edition and free tools such as FxCopIntegrator? The only graphical tool I found is FxCop GUI which allows to choose rules. That rule selection results in creating a ".fxcop"…
Yury Rumega
  • 220
  • 1
  • 12
0
votes
1 answer

ASP.NET Code Analisys on Visual Studio 2010 SP1

I'm trying to install the Fxcop ASP.NET Security rules from CodePlex as described on a MSDN Magazine article: Improving ASP.NET Security with Visual Studio 2010 Code Analysis I'm using VS 2010 SP1 Ultimate and I can't make it load the rules to be…
Pedro Laguna
  • 465
  • 2
  • 5
  • 20
1 2 3
49
50