RCS1059: Avoid locking on publicly accessible instance
Properties
Property | Value |
---|---|
Default Severity | Warning |
Minimum language version | - |
Examples
Example #1
diagnostic.cs
public void Foo()
{
lock (this)
{
}
}
fix.cs
private readonly object _lockObject = new object();
public void Foo()
{
lock (_lockObject)
{
}
}