This has to qualify as an obscure FxCop feature:

DoNotDeclareReadOnlyMutableReferenceTypes is a rule that checks for visible read-only fields that are mutable reference types (classes). A mutable type is a type whose instance data can be changed once it has been constructed.

A useful rule, but the rule can give false positives if FxCop isn’t aware that one of your classes is immutable. Fortunately, you can tell FxCop about this, but the approach is more than a little obscure.

To make DoNotDeclareReadOnlyMutableReferenceTypes aware of your immutable types, simply do the following:

Using a text editor, create a new text file called ImmutableTypes.txt and place this file alongside your FxCop project file, or within the FxCop installation folder.

Using a new line for each type, enter the fully-qualified name of each class you want to mark as immutable,

From the FxCop FAQ.

Comments

blog comments powered by Disqus
Next Post
Validation shouldn't be a Blunt Instrument  18 Feb 2010
Prior Post
A Great Upgrade Experience  13 Feb 2010
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
February 2010
2010