Dear Visual Studio Code Analysis / FxCopCmd.exe:





Visual Studio Code Analysis (aka prettified output from fxcopcmd.exe in a Visual Studio pane) hasn’t been worked on in like forever. And it shows. Why is it that when you configure Code Analysis just the way you want it in your projects and then do a build, Code Analysis decides it only wants to run for the projects with changes? Configurable? Not that I can tell. No problem, I’ll use the Build menu to run Code Analysis for the solution. HUGE FAIL! It looks like it runs it for all projects whether they’re properly configured or not. WTF?? If I do a clean/rebuild solution, now CA starts pumping out messages for the whole solution. There are 10 ways to kick off CA for the solution and I think this is the only one that works consistently.

FxCopCmd.exe has so many damned problems it’s not even funny. Want to run it on a build server? Good effing luck. Give up and install Visual Studio. Want it to honor suppressions for release builds? Don’t forget to pass /p:DefineConstants=”CODE_ANALYSIS” to msbuild when in release mode or you’re screwed. Isn’t that documented? Only if google’s index counts somehow as documentation. Why don’t you have to pass that *all* the time? Why isn’t it required for debug? WHO KNOWS!? It seems like some parts of code analysis instrumentation are integrated with the compiler or at least some magic step in the build process because this thing is a weird black box and you just have to fart around with it until it works.

Don’t even get me started about the stupid Code Analysis spelling dictionary. THERE ARE MAGICAL WORDS WHICH YOU CANNOT CORRECT NO MATTER HOW HARD YOU TRY. Just disable CA1704 or you will go insane. A developer in my group recently needed “checkbox” recognized as a valid compound. It’s the god damned EXAMPLE in the article on how to customize the CA dictionary and it doesn’t work. He just shut off CA1704 instead–most of the garbage that rule produces isn’t even worth suppressing.

What about when people configure fxcopcmd.exe to run in release mode as part of their build? Well, when codeanalysis msbuild tasks are run by Visual Studio, they magically always work great and never have any problems or errors. When you run them with msbuild like you would on a build server, they can sometimes create a command line with so many reference arguments that it’s too long for Windows to execute. WTF?? Now you have to pass /p:RunCodeAnalysis=false to msbuild and manually run fxcopcmd.exe as a separate, post-build step with the DLLs you want to analyze. F#$k you, fxcopcmd.exe. You could be so awesome and so helpful, but no, you force me to experience Stockholm syndrome rather that just being cool.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s