I no longer work at Microsoft, so please don't bother leaving a comment here or trying to contact me through my MSDN blog.
You can find my new blog at http://www.technologytoolbox.com/blog/jjameson. My new site also provides copies of all posts from my MSDN blog.
Since I seem to be on a roll this morning with blogging, I figured I might as well get one more post in before moving on to my "day job."
During the process of authoring a different post earlier today, I stumbled across a bug while using the Code Metrics feature in Visual Studio 2008.
After clicking the Analyze menu, and then clicking Calculate Code Metrics for Solution, I encountered errors similar to the following for several projects in the solution:
An error occurred while calculating code metrics for target file 'E:\NotBackedUp\...' in project ... The following error was encountered while reading module 'Microsoft.SharePoint': Could not resolve type: T ObjectModel.
It turns out that this is a known bug in Visual Studio 2008 due to the default setting that allows dependant assemblies to be used in a project without explicitly referencing them.
The workaround is to explicitly add the dependant assemblies to the project.
Consider the following projects from my solution:
PublicationLibrary.Workspaces
References:
PublicationLibrary.Workspaces.DeveloperTests (i.e. the corresponding unit tests project)
With these references, Visual Studio is able to successfully compile both projects. However, it was only able to successfully calculate code metrics on the PublicationLibrary.Workspaces project; attempting to calculate code metrics on the second project yielded the aforementioned error.
After explicitly referencing Microsoft.SharePoint.Security in the PublicationLibrary.Workspaces.DeveloperTests project, the error went away and I could view the code metrics for both projects.