I believe what it should be generating is the following:
using IEnumerator<string> enumerator = p2.GetEnumerator();
while (enumerator.MoveNext())
{
string item = enumerator.Current;
result.Add(item);
}
return result;
I'm not sure if this issue arises in other areas (e.g. generated code from interfaces) as I haven't tested it personally, but I would expect the Mapster.Tool generates the code the same way.
I'm using Mapster.Tool to generate extension methods from my mapping registrations like so:
When inspecting the generated code I noticed that anywhere GetEnumerator() is used, the generic Enumerator is never disposed.
This is a snippet of what is being generated:
I believe what it should be generating is the following:
I'm not sure if this issue arises in other areas (e.g. generated code from interfaces) as I haven't tested it personally, but I would expect the Mapster.Tool generates the code the same way.