var queue = new Queue<string>();
UpdateQueue();
while (queue.Count > 0) queue.Dequeue();
void UpdateQueue() => queue.Enqueue("foo");
Now S4158 is reported on Dequeue because it doesn’t recognize the call to Enqueue. Passing the queue to the local method seems to be a workaround, regardless of the method using this parameter:
var queue = new Queue<string>();
UpdateQueue(queue);
while (queue.Count > 0) queue.Dequeue();
void UpdateQueue(object _) => queue.Enqueue("foo");