Analyzing "Whidbey" binaries in fxcop [Jeffrey van Gogh]
As the “Visual Studio 2005 Community Technology Preview March 2004” of the next release of the .NET framework (codename “Whidbey”) has been made available to customers recently. We expect people to want to analyze their projects made with this preview version in FxCop.
The last few months the FxCop team has spent quite some time making FxCop ready for all these new features as other Microsoft Teams already run FxCop on this new version. The major workitem turned out to be supporting generics. Generics are a great tool to developers, but to static code analysis tools it adds a lot of extra complexity. some samples of these complexities:
- Naming rules, for instance the rule that checks to see if your collection type implements System.Collections.ICollection, with generics it is supposed to implement System.Collections.Generic.ICollection<T> instead.
- The rule consider passing base types as parameters, it would find you're passing List<string> but only calling List<T> methods and suggest you use that one instead.
With FxCop's new metadata reader, we are able to analyze “Whidbey” assemblies running FxCop on v1.1 of the framework. There are two sets of rules that might show issues though: Rules that do security checks & rules that read in resources. The reason for this is that we use framework API's to instantiate both of these and the format has changed in “Whidbey” so v1.1. of the framework can't instantiate “Whidbey” versions of these.
If you want to enable analysis on these two items, you'll need to run fxcop on “Whidbey”. To do this you'll have to change fxcop's configuration:
- Open fxcop.exe.config and fxcopcmd.exe.config in your favorite editor from the installation directory of FxCop
- Find the line containing <supportedRuntime version="v1.1.4322" />
- Replace this with <supportedRuntime version="v2.0.40301" /> <!-- see c:\windows\microsoft.net\framework to see which exact version of v2.0 you have installed) -->
- Launch fxcop, check if the “running on runtime version“ value is equivalent to the value you just entered
- Analyze your assemblies. You should now be able to analyze “Whidbey“ binaries as well as all assemblies compiled on v1.0 or v1.1 of the framework.
Don't forget to change this setting back to the old state if you remove this preview version of “Whidbey“
Regards,
Jeffrey
Comments
- Anonymous
May 13, 2004
Crashed on both PDC Longhorn and the recent .NET version. It also failed to import my project file. I needed to redo all my settings and finally it created this really large project file. :( - Anonymous
May 13, 2004
When running FxCop on itself it errors 4000 (four thousand) violations. Obviously the FxCop team is not one of those "Microsoft Teams [that] already run FxCop on this new version". - Anonymous
May 14, 2004
Anonymous,
Your supposition is not correct, there is something wrong with your runtime configuration. When our metadata reader fails, it cannot provide any IL instructions for analysis. Because of this, FxCop cannot detect any call sites and will fire tons of erroneous 'dead code' false positives (among others).
We will have a Whidbey-specific version of FxCop posted to www.gotdotnet.com next time. I hope this clears up your issues.
Re: your large project file, be sure you don't have compression turned off in the UI.
Michael