You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a struct that implicitly acts as an Enumerator:
public struct EnumeratorStruct : IDisposable
{
public int Current { get; }
public bool MoveNext() => foo;
public EnumeratorStruct GetEnumerator() => this;
public void Dispose() => Console.WriteLine("Disposed");
}
If you use EnumeratorStruct as the supplier in a foreach statement, EnumeratorStruct.Dispose() is called but the analyzer still gives the IDISP004 warning.
All examples bellow are non-compliant despite being false-positives.
foreach (int element in new EnumeratorStruct())
{
...
}
public static EnumeratorStruct Enumerate(this Foo source) => new EnumeratorStruct(source);
Foo source = new Foo();
foreach (int element in source.Enumerate())
{
...
}
EnumeratorStruct enumerator = new EnumeratorStruct();
foreach (int element in enumerator)
{
...
}
The text was updated successfully, but these errors were encountered:
If you have a struct that implicitly acts as an Enumerator:
If you use
EnumeratorStruct
as the supplier in aforeach
statement,EnumeratorStruct.Dispose()
is called but the analyzer still gives the IDISP004 warning.All examples bellow are non-compliant despite being false-positives.
The text was updated successfully, but these errors were encountered: