Domanda

In our API library, we have a number of classes that implement a method ComputeCurrentDefinitionHashCode, which combines the hash codes of each member field with a pseudo-random number that should be unique to that class.

This is based on Paul Hsieh's "SuperFastHash" at http://www.azillionmonkeys.com/qed/hash.html

I'm trying to determine if it's possible to use FxCop to ensure that the randomly generated number we put in each class is not duplicated in any other class.

In other words, can we save information from one class to the next?

È stato utile?

Soluzione

Yes, you can construct an FxCop rule that caches information across classes. However, depending on how you include the target number in your classes, this may or may not be a particularly good candidate for an FxCop rule. For example, if it is a literal passed as an argument to a base class constructor, then an FxCop rule might be an OK choice. However, if the source of the number is less "predictable", a unit test approach might be preferable.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top