Questions tagged [fxcop]

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

fxcop
Filter by
Sorted by
Tagged with
7 votes
1 answer
274 views

Does Code Analysis support defining two languages for mixed language Spell Checking?

Using the tip provided by José Adan at http://social.msdn.microsoft.com/Forums/en-US/vstscode/thread/f6dec8c4-9752-4a9b-82fe-0822808fd386/ I was able to get Code Analysis to do spell checking in ...
3 votes
4 answers
4k views

Naming: Pricelist vs. PriceList [closed]

Which is more correct, "PriceList" or "Pricelist"? FxCop says: CA1702 : Microsoft.Naming : The compound word 'PriceList' in type name 'PriceList' exists as a discrete term. If your usage is intended ...
4 votes
1 answer
9k views

Code analysis in Visual Studio 2012 vs. FxCop

I am new to the code analysis. Here I don’t know the difference and the usages between the code analysis tool in Visual Studio 2012 and the FxCop tool. What are some details?
73 votes
3 answers
43k views

Visual Studio Code Analysis vs StyleCop + FxCop

I used previously StyleCop + FxCop on my Visual Studio's projects. But now I am testing Visual Studio Code Analysis tool, which is easier to integrate into MSBuild, and I have found that this tools ...
0 votes
0 answers
54 views

How to convert FxCopReport format in sarif format?

Running microsoft code analysis using MSBUILD creates xml file which is in FxCopReport format. How canit be converted in sarif format ?
0 votes
0 answers
15 views

Visual Studio 2019 during publish getting fxcop is hung or deadlock error

I am trying to publish my web application in visual studio 2019 and during the publish getting the below fxcop error. "MSbuild error CA 0001 - Fxcop is hung or deadlocked". How to fix this ...
43 votes
5 answers
15k views

c# warning - Mark assemblies with NeutralResourcesLanguageAttribute

I'm getting the following warning: CA1824 Mark assemblies with NeutralResourcesLanguageAttribute According to MSDN, the cause of this is: An assembly contains a ResX-based resource but does not ...
1 vote
1 answer
217 views

Creating Custom Rules for .Net Analyzers

We are switching to .Net Analyzers on our .Net 5 and 6 projects. On previous projects we had dlls we wrote for some custom rules that we use. I've looked around and can't find any information on how ...
13 votes
1 answer
4k views

What is the advantage to use the Microsoft.CodeAnalysis.FxCopAnalyzers nuget over the default Managed Binary Analysis ruleset?

I currently use the Managed Binary Analysis and it looks like the nuget adds the same rules (maybe less). I also use this SonarQube plugin: https://github.com/SonarQubeCommunity/sonar-fxcop. What is ...
2 votes
2 answers
493 views

FxCop 1.36 with CruiseControl.NET 1.5

I need to run FxCop with CruiseControl.NET 1.5 for continuous Integration. I have included the buildscript with the command to execute the FxCop project file. When I Build the project in ...
42 votes
9 answers
13k views

How to get the FxCop custom dictionary to work?

How is it possible to get the FxCop custom dictionary to work correctly? I have tried adding words to be recognised to the file 'CustomDictionary.xml', which is kept in the same folder as the FxCop ...
8 votes
4 answers
2k views

Code analysis/FxCop in VS2008

FxCops is something new to me, but as always I would like to get to know the new things.. From what I've read, FxCops is already included in VS2008. I guess it's the "Code Analysis" function. Whenever ...
47 votes
4 answers
12k views

What's with the "Afx" in StdAfx.h?

I'm just curious what Afx stands for. And what about Fx in FxCop?
5 votes
5 answers
2k views

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

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 ...
10 votes
3 answers
9k views

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

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 ...
0 votes
1 answer
31 views

File names and line numbers missing from FXCOP output in SDK-style project targeting .NET Framework

We used FXCOP code analysis ("legacy") a lot in our solution. We are turning on many Microsoft rules, and also have written a large set of our own FXCOP-style analyzers for aspects of code ...
3 votes
1 answer
2k views

Can we create a GlobalSuppression.cs file for the complete solution

I wanted to know that, In Visual Studio Code Analysis (same as FxCop), can we have a GlobalSuppression.cs file that is applicable for the whole solution and not only for the individual projects inside ...
1 vote
1 answer
256 views

Are FxCopAnalyzers and the .editorconfig file supposed to sync?

When I add an .editorconfig file to my project, it doesn't match the rules shown in the project's Dependencies > Analyzers. For example, my .editorconfig file has this: dotnet_diagnostic.CA2200....
5 votes
3 answers
3k views

Disable Code Analysis output MSBuild

I am building projects using a build definition. When this executes, Code Analysis is also performed. Code Analysis outputs various files including: ConsoleApplication2.exe.CodeAnalysisLog.xml ...
0 votes
2 answers
512 views

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

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 ...
2 votes
2 answers
296 views

Opening the Code Analysis Ruleset editor crashes Visual Studio

Every time I try to do anything with Code Analysis, Visual Studio crashes. The event viewer shows the crash is caused by an invalid window-splitter size. Stacktrace: Application: devenv.exe Framework ...
7 votes
3 answers
5k views

FxCopAnalyzers: An instance of analyzer cannot be created

I'm trying to install fxcop analyzers in my project. However, having added and restored the nuget package, building the project results in hundreds of warnings of the form 1>CSC : warning CS8032: ...
16 votes
5 answers
11k views

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

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. ...
19 votes
3 answers
24k views

Why can't Microsoft analyzers find Microsoft.CodeAnalysis?

I'm trying to add Microsoft.CodeAnalysis.FXCopAnalyzers (latest stable version) to my ASP.NET project. When I install it via NuGet, I get a ton of errors like: An instance of analyzer Microsoft....
9 votes
3 answers
6k views

Suppressing Static Code Analysis Warning CA1806 for TryParse calls

I was wondering what people's thoughts were on the CA1806 (DoNotIgnoreMethodResults) Static Code Analysis warning when using FxCop. I have several cases where I use Int32.TryParse to pull in ...
24 votes
5 answers
10k views

Why is Microsoft.CodeAnalysis published with ASP.NET Core website?

I'm publishing an ASP.NET Core MVC 3.0 website and the output folder contains lots of reference in many language to Microsoft.CodeAnalysis librairies, someone knows why? Of course the FxCopAnalyzers ...
23 votes
3 answers
11k views

Error in FxCop Phoenix analysis engine

So I'm trying to run a bunch of rules which are defined in a RuleSet. The RuleSet file is actually generated using Sonarqube - I've selected absolutely all rules in there, including the FxCop, ...
3 votes
1 answer
798 views

What do I missed to apply for sonarqube custom rules using fxcop?

I want to apply for my own sonarqube custom rule using fxcop. SonarScan succeeded with MSBuild, but sonarqube did not reflect the rule! I referenced this url - https://github.com/DanielHWe/sonar-...
4 votes
4 answers
1k views

Too many false positives when using FxCop

We are using FxCop and it generates too many false positives to our liking. For instance, if a private method is invoked using reflection, then this method is reported as potentially unused - ...
8 votes
1 answer
2k views

How to silence fx cop warning CS0067?

On a build server, I see some weird message. It doesn't say so, but I think it's from some software called 'fx cop' Warning CS0067: The event 'SunGard.Adaptiv.AnalyticsEngine.UI.CommonControls....
10 votes
3 answers
5k views

How to prevent FxCop from analyzing auto-generated code?

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 ...
0 votes
1 answer
219 views

Strange warning counting behavior from FxCop?

My team is using FxCop to help clean up an existing ASP.NET application. We have noticed some strange behavior in the way FxCop counts warnings. It seems that on one pass through the code, FxCop ...
0 votes
2 answers
2k views

Visual Studio SonarLint extension connected to SonarQube is generating warnings CA0507 and CA0064 and no sonar Sxxx warnings

I installed the SonarLint extension for Visual Studio and connected successfully to our SonarQube server and successfully ran Code Analysis to display sonar issues in VS. So it was working OK but for ...
14 votes
2 answers
14k views

What Replaces Code Analysis in Visual Studio 2019?

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 ...
6 votes
6 answers
3k views

C# Code Analysis dislikes protected static s_Foo (CA1709, CA1707)

I usually add an m_ in front of private fields and an s_ before static members. With a code like protected static readonly Random s_Random = new Random (); I get the following warnings by VS2008's ...
106 votes
14 answers
54k views

Why/when should you use nested classes in .net? Or shouldn't you?

In Kathleen Dollard's 2008 blog post, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes. I'm assuming that the people ...
11 votes
2 answers
8k views

CA1303, DoNotPassLiteralsAsLocalizedParameters, but I'm actually not

My code gets the CA1303 warning from Microsoft.Globalization, "Do not pass literals as localized parameters", but my code is not actually passing a literal: private void MyForm_Load(object ...
2 votes
2 answers
473 views

Suppress CA1303 fxcop warning when constructing a new Exception

When I throw an exception in my ASP.NET Core 3.1 code, fxcop warns me when it sees a string literal as an argument to a new Exception(). For example: throw new InvalidOperationException("Ouch"); ...
7 votes
1 answer
2k views

Any reason not to enable CODE_ANALYSIS in production builds?

Are there any performance costs when static code analysis is enabled in a production (release) build? Our CI server runs code analysis on a debug build of our C# projects, whereas the release build ...
1 vote
1 answer
240 views

How to get CA2100 SQL injection warning in calling methods

I have a helper method to prevent a lot of copy and paste. I want to make sure calling methods of my helper method "MyExecuteSQLQuery" will be checked against rule "CA2100: Review SQL ...
4 votes
2 answers
3k views

What is the static analysis rule to warn about unused using statements?

Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file?
101 votes
12 answers
39k views

CA2202, how to solve this case

Can anybody tell me how to remove all CA2202 warnings from the following code? public static byte[] Encrypt(string data, byte[] key, byte[] iv) { using(MemoryStream memoryStream = new ...
1 vote
0 answers
121 views

CA1063 Remove finalizer from class and add it in the code where disposing is false

I have been trying to avoid this warning, what I have tried and understand according to CA1063: Implement IDisposable correctly is that the finalizer should just include the Dispose method in false. ...
20 votes
1 answer
4k views

Is CA2007 relevant to a .NET Core application?

When I run FxCop on my project, I get a large number of warnings with the ID of CA2007. This ID is missing from the docs (it just skips from CA2006 to CA2100), but the message I get is: Do not ...
0 votes
1 answer
2k views

CA1707 warning on constants names

why microsoft keeps documenting code with constant like WM_SOMECONSTANT but the code analysis in Visual Studio reports the CA1707 warning? Should we suppress all these warning for the solution? should ...
0 votes
2 answers
159 views

Remove all, except the first two parameters from the EventHandler

I am having trouble with the warning CA1009 from FxCop to remove all the poarameters except the first two from the event (object and EventArgs). I have not found the way to solve this issue, bécause ...
0 votes
1 answer
453 views

Warning: SQL injection attacks

I have been trying to adapt my code to FxCop rules and I found this warning: CA2100 Review the query string passed to 'OleDbDataAdapter.OleDbDataAdapter(string, OleDbConnection)' in 'WavesShaperNew....
85 votes
9 answers
17k views

Parameter naming: filename or fileName?

I try to be grammatically correct in my naming*. I've always used filename instead of fileName. The java convention also seems to use this, but FxCop prefers fileName. There's a discussion on ...
1 vote
0 answers
444 views

How to exclude auto generated files from getting analyzed from your custom code analysis rule?

I have written a custom code analysis rule using FxCop sdk api and integrated it into my test project. It is correctly analyzing the project code, however it also analyses auto generated files. i.e in ...
24 votes
6 answers
2k views

Why does FxCop think initializing fields to the default value is bad?

When assigning a default default-value to a field (here false to a bool), FxCop says: Resolution : "'Bar.Bar()' initializes field 'Bar.foo' of type 'bool' to false. Remove this ...

1
2 3 4 5
15