Our codebase has a lot of threading restrictions encoded in comments - such as:
- This class is thread-safe (all public methods may be safely accessed from any thread)
- Must hold a lock on "xyz" to access/invoke any public members
- Must only be accessed from thread "xyz" (usually but not always referring to the GUI thread)
- This lock must be taken after lock "xyz" if both are required
The first three can be seen on both classes and individual members.
I've searched for any solutions that could at least partially verify that these constraints are satisfied. I realise that there are major limitations on the extent to which this can be done automatically, but even a little help from a tool would really help. I couldn't find any though.
Can you suggest a tool to do something along these lines? Perhaps an FxCop ruleset that works by encoding the above restrictions as attributes?