-
I am exploring the library and noticed the warning This would be a solution: public override IEnumerator<T> GetEnumerator()
{
var enumerator = ids.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
yield return getID(enumerator.Current);
}
}
finally
{
if (enumerator is IDisposable disposable)
{
disposable.Dispose();
}
}
} I would like to know if the warning was intentionally ignored, and if yes, why. Reading your blog posts I learned something about working with AutoCAD APIs. I wish the official documentation had this and this tables! Exploring your library I am learning about clean C# and project organization. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Isn't it automatically disposed in the |
Beta Was this translation helpful? Give feedback.
-
Hi, stenci, I'm very glad my posts and the Code have been helpful. Feel free to reach out if you have any further questions. I do not get the warning in my IDE (I'm using VS 2022). Calling |
Beta Was this translation helpful? Give feedback.
Hi, stenci,
I'm very glad my posts and the Code have been helpful. Feel free to reach out if you have any further questions.
I do not get the warning in my IDE (I'm using VS 2022).
Calling
Dispose()
is ignored here on purpuse, because the underlying object is an AutoCAD container object (eg.BlockTable
) and it would have a negative effect if we dispose of the object here and then use it further down the call chain. Furthermore, there are only two AutoCAD classes I'm aware of whose objects have to be disposed of explicitly,ObjectIdCollection
andIdMapping
.