Permalink
707b719 Jun 14, 2018
1 contributor

Users who have contributed to this file

43 lines (32 sloc) 845 Bytes

RCS1059: Avoid locking on publicly accessible instance

Property Value
Id RCS1059
Category Design
Default Severity Warning
Enabled by Default
Supports Fade-Out -
Supports Fade-Out Analyzer -

Example

Code with Diagnostic

public void Foo()
{
    lock (this) // RCS1059
    {
    }
}

Code with Fix

private readonly object _lockObject = new object();

public void Foo()
{
    lock (_lockObject)
    {
    }
}

See Also

(Generated with DotMarkdown)