fxcop

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 I try to run it though, it seems to start a rebuild and end in the "Finished Rebuilding" state. I checked the output window and there are ...

Why is it considered bad to expose List<T>?

According to FXCop, List should not be exposed in an API object model. Why is this considered bad practice? ...

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

I'm just curious what Afx stands for. And what about Fx in FxCop? ...

FxCop rule that checks for NotImplementedExceptions

I'd like to have the nightly build check for how many NotImplementedExeptions there are in my .NET code so hopefully we can remove them all before releasing. My first thought is that FxCop might be a good tool to do this. Does anyone have a custom FxCop rule for this? How would I go about creating one myself? ...

Are there any good workarounds for FxCop warning CA1006?

I am having trouble with FxCop warning CA1006, Microsoft.Design "DoNotNestGenericTypesInMemberSignatures". Specifically, I am designing a ReportCollection<T> class that inherits from ReadOnlyCollection<Report<T>>, and its public constructor takes an IList<Report<T>> as a parameter. The suggestion for fixing this warning is not very usef...

How to manage FxCop overwhelming reports

I've recently started using it. However, after running it against one of my company's largest project. It turns up mountains of problems. The list of problems was so overwhelming it would take days to find and fix some, if not all of the stuff. Now, I know that it's not very practical to fix everything FxCop tells you to fix. But as I ...

What internal dictionary does FxCop use?

FxCop must base itself on some internal dictionary. Does it use Word dictionaries if they are installed? When running FxCop on my build server it doesn't find any spelling errors, but on my developer machine it does. I am aware of the custom dictionary, but it is not the issue in this case. On the build server it accepts any word. ...

Should we use FxCop on UnitTest assemblies?

We use FxCop for all of our projects. For our UnitTests I am not sure it is worth it. We end up with many suppresses: [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = SuppressJustifications.CA1822MethodIsUsedExternallyAsNonStatic)] [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResu...

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 only finds and counts the first warning related to a specific rule in each method. So, if I have: public test3(){ int a = 0; //DoNotInit...

FxCop Suppression

I have a control on an Asp.Net page, on that page is a control with the name "PaReq" that violates the rule: CA1704:IdentifiersShouldBeSpelledCorrectly I've used suppression before I'm not sure how to suppress this error since it is defined in the generated file. I could do this in a custom dictionary but that would mean all the ...

Has anyone created any cool rules for FxCop/StyleCop?

I'm just looking for some inspiration. Especially in the area of performance and security, naming conventions are important but not as 'cool' ;) Even if your rule was only applicable to your domain/project but demonstrates how powerful a rule can be, please let me know. I work with C#, but I'm interested in rules for any language. ...

How can I run FxCop on an entire solution in Visual Studio 2008

There must be simple way, I do not want to run Code Analysis separately on each project. ...

FxCop on build (Visual Studio 2008 Professional)

I just learned how to integrate StyleCop into Visual Studio. Now it runs every build and its errors appears as warnings. Excelent! Now I just want to do the same thing with FxCop, but even installing MSBuild Community Tasks and adding to the proj file: <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.T...

How can you get FxCop rule CA1726 to ignore a prefered term?

FxCop has a rule (CA1726) that checks for preferred terms. This looks for words like "Dont" and tells you to replace them with better words like "Do not". Generally this is fine, however one of the terms it objects to is "Flag". At our firm, the business deals with Flags meaning those cloth things at the end of flagpoles. Suppressing thi...

What are your favourite FxCop rules?

Which FxCop rules do you most value? Which rules highlight the best .Net gotchas? ...

FxCop - Use properties where appropriate

I have interface in service layer with several methods starting with Get and FxCop's Use properties where appropriate rule complains that I should consider using properties instead. I tried to use SuppressMessageAttribute but when it's defined on interface it has no effect on member methods. Do I need to put SuppressMessageAttribute to ...

Was FxCop wrong to tell me to use the .Net Uri class?

When getting a URL for something in an Amazon S3 bucket it can append a signature to the end to confirm that the user has permission to view the object and the URL looks like so: https://mybucket.amazonaws.com/mykey?AWSAccessKeyId=myaccesskey&amp; Expires=1235241261&Signature=t5vFBWXaN0DvVaWfck9n2%2fmTzOU%3d These URLs were comin...

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 analyses some of the rules of both FxCop and StyleCop. Is this tool a full replacement for both FxCop and StyleCop or it just implements som...

FxCop doesn't resolve external references

Perhaps not a fully fledged programming quiestion, but to help drive the quality and enforce some standards throughout the application I am working on I want to use FxCop. If I try to integrate into into Visual Studio 2005 as an external tool using the command line /c /f:"$(TargetPath)" /r:"C:\Program Files\Microsoft FxCop 1.36\Rules...

Should GC.SuppressFinalize be called on objects that do not have a finalizer?

For some reason FXCop seems to think I should be calling GC.SuppressFinalize in Dispose, regardless of whether I have a finalizer or not. Am I missing something? Is there a reason to call GC.SuppressFinalize on objects that have no finalizer defined? ...