From 8a2335ea21e1440c6db9d4ca14a028431af6f7d9 Mon Sep 17 00:00:00 2001 From: dahall Date: Mon, 20 Dec 2021 10:51:04 -0700 Subject: [PATCH] Updated IEnumFromCom to support intialized (new) items so it covers structures and classes. --- PInvoke/Shared/Collections/IEnumFromCom.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PInvoke/Shared/Collections/IEnumFromCom.cs b/PInvoke/Shared/Collections/IEnumFromCom.cs index 0e9d08a7..a2ebd628 100644 --- a/PInvoke/Shared/Collections/IEnumFromCom.cs +++ b/PInvoke/Shared/Collections/IEnumFromCom.cs @@ -49,7 +49,7 @@ namespace Vanara.Collections /// if a class doesn't support or like some COM objects. /// /// The type of the item. - public class IEnumFromCom : IEnumFromNext + public class IEnumFromCom : IEnumFromNext where TItem : new() { private readonly ComTryGetNext cnext; @@ -90,7 +90,7 @@ namespace Vanara.Collections private bool TryGet(out TItem item) { - var res = new TItem[1]; + var res = new TItem[] { new TItem() }; item = default; if (cnext(1, res, out var ret) != HRESULT.S_OK) return false;