I've upgraded to VS2019 16.2 and begin to see messages like these:
IDE0068 C# Use recommended dispose pattern to ensure that object created by is disposed on all paths: using statement/declaration or try/finally
The referred code look like this:
var tagsCollection = new TagCollection();
foreach (var tag in tags)
{
tagsCollection.Add(new TagEntity
{
FileId = fileId,
Tag = tag
});
}
tagsCollection.SaveMulti();
if I add tagsCollection.Displose(); the recommendation disappears.
Should I always call Dispose in code like the above?
Thanks in advance.
Best regards
Morten