Regression IDISP016 in foreach
JohanLarsson opened this issue · comments
Johan Larsson commented
namespace N
{
using System;
using System.Collections.ObjectModel;
public sealed class C : IDisposable
{
private bool disposed;
public ObservableCollection<Disposable> Disposables{ get; } = new();
public void M()
{
foreach (var conversion in this.Disposables)
{
conversion.Dispose();
}
}
public void Dispose()
{
if (this.disposed)
{
return;
}
this.disposed = true;
foreach (var conversion in this.Disposables)
{
conversion.Dispose();
}
this.Disposables.Clear();
}
}
}