Is there any annotation or analyzer that marks a member which requires to always be used inside a specific lock.
public class Example
{
private readonly object _lock = new object();
// Some annotation that requires this to be used inside a lock of _lock
private readonly List<int> _collection = new List<int>();
public void Add(int value)
{
lock (_lock)
{
_collection.Add(value);
}
}
public void Remove(int value)
{
lock (_lock)
{
_collection.Remove(value);
}
}
}