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“