-
Notifications
You must be signed in to change notification settings - Fork 4
Gendarme.Rules.Concurrency.DoNotLockOnWeakIdentityObjectsRule(git)
Assembly: Gendarme.Rules.Concurrency
Version: git
This rule ensures there are no locks on objects with weak identity. An object with weak identity is one that can be directly accessed across different application domains. Because these objects can be accessed by different application domains it is very difficult to ensure that the locking is done correctly so problems such as deadlocks are much more likely. The following types have a weak identities:
- System.MarshalByRefObject
- System.OutOfMemoryException
- System.Reflection.MemberInfo
- System.Reflection.ParameterInfo
- System.ExecutionEngineException
- System.StackOverflowException
- System.String
- System.Threading.Thread
Bad example:
public void WeakIdLocked ()
{
lock ("CustomString") {
// ...
}
}
Good example:
public void WeakIdNotLocked ()
{
Phone phone = new Phone ();
lock (phone) {
// ...
}
}
You can browse the latest source code of this rule on github.com
Note that this page was autogenerated (3/17/2011 1:55:44 PM) based on the xmldoc
comments inside the rules source code and cannot be edited from this wiki.
Please report any documentation errors, typos or suggestions to the
Gendarme Mailing List. Thanks!