InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

FxCop Rule for Multi-Targeting

Posted by Jonathan Allen on Oct 09, 2007

Sections
Process & Practices,
Architecture & Design,
Development
Topics
.NET Framework ,
Code Analysis ,
Profilers ,
.NET ,
Debugging ,
Orcas ,
FXCop ,
Programming

Multi-targeting in Visual Studio 2008 leads to a new set of problems. With .NET 3.5 bringing new features to the core assemblies, care must be taken when targeting .NET 2.0. Otherwise, an application can be compiled successfully but fail to run due to missing methods. One way to handle this is to use Krzysztof Cwalina's Multitargeting rule for FxCop.

FxCop, which provides code analysis for Visual Studio, allows developers to create the own custom rules. FxCop rules work against IL, not source code, so they are automatically available for any compiled .NET language.

Krzysztof has provided a sample rule that issues warnings whenever a new class or method is used. The list of new classes and methods is provided along with the source code. This rule could also be adapted to discourage the use of other classes deemed inappropriate for the project. One possibility is to get a list of Mono classes not yet implemented and filter against them.

No comments

Watch Thread Reply