For all COM IEnumXX interfaces, fixed the Next method's array parameter so that it references the size on input, not output. This prevents a bug when implementing these interfaces. Thanks to @wangfu91 for finding this and submitting #143.

pull/161/head
dahall 2020-07-12 14:09:40 -06:00
parent b153e67354
commit f510b2d32e
14 changed files with 25 additions and 23 deletions

View File

@ -142,7 +142,9 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/wincodec/nf-wincodec-iwicenummetadataitem-next HRESULT Next( ULONG celt,
// PROPVARIANT *rgeltSchema, PROPVARIANT *rgeltId, PROPVARIANT *rgeltValue, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [In, Out, Optional] PROPVARIANT_IMMUTABLE[] rgeltSchema, [In, Out] PROPVARIANT_IMMUTABLE[] rgeltId, [In, Out, Optional] PROPVARIANT_IMMUTABLE[] rgeltValue, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Optional] PROPVARIANT_IMMUTABLE[] rgeltSchema,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPVARIANT_IMMUTABLE[] rgeltId,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Optional] PROPVARIANT_IMMUTABLE[] rgeltValue, out uint pceltFetched);
/// <summary>Skips to given number of objects.</summary>
/// <param name="celt">

View File

@ -220,7 +220,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumcategoryinfo-next HRESULT Next( ULONG celt,
// CATEGORYINFO *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] CATEGORYINFO[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] CATEGORYINFO[] rgelt, out uint pceltFetched);
/// <summary>Skips over the specified number of items in the enumeration sequence.</summary>
/// <param name="celt">The number of items to be skipped.</param>
@ -277,7 +277,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/comcat/nf-comcat-ienumguid-next HRESULT Next( ULONG celt, GUID *rgelt,
// ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] Guid[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] Guid[] rgelt, out uint pceltFetched);
/// <summary>Skips over the specified number of items in the enumeration sequence.</summary>
/// <param name="celt">The number of items to be skipped.</param>

View File

@ -1106,7 +1106,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ienumcontextprops-next HRESULT Next( ULONG celt,
// ContextProperty *pContextProperties, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ContextProperty[] pContextProperties,
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] ContextProperty[] pContextProperties,
out uint pceltFetched);
/// <summary>Skips over the specified number of items in the enumeration sequence.</summary>
@ -1173,7 +1173,7 @@ namespace Vanara.PInvoke
/// </returns>
[PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
HRESULT Next([In] uint celt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] STATSTG[] rgelt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] STATSTG[] rgelt,
out uint pceltFetched);
/// <summary>Skips a specified number of STATSTG structures in the enumeration sequence.</summary>
@ -1225,7 +1225,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nf-objidl-ienumunknown-next HRESULT Next( ULONG celt, IUnknown
// **rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] rgelt, out uint pceltFetched);
/// <summary>Skips over the specified number of items in the enumeration sequence.</summary>
/// <param name="celt">The number of items to be skipped.</param>

View File

@ -918,7 +918,7 @@ namespace Vanara.PInvoke
[PInvokeData("oleidl.h", MSDNShortId = "bb934017-9054-42b5-89d4-a24f12829503")]
[PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
HRESULT Next([In] uint celt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] OLEVERB[] rgelt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] OLEVERB[] rgelt,
out uint pceltFetched);
/// <summary>Skips over the specified number of items in the enumeration sequence.</summary>

View File

@ -146,7 +146,7 @@ namespace Vanara.PInvoke
// STATPROPSETSTG *rgelt, ULONG *pceltFetched );
[PInvokeData("propidl.h", MSDNShortId = "3af3c518-3db4-4436-b1c1-86587ce8fbf3")]
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] STATPROPSETSTG[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] STATPROPSETSTG[] rgelt, out uint pceltFetched);
/// <summary>The <c>Skip</c> method skips a specified number of STATPROPSETSTG structures in the enumeration sequence.</summary>
/// <param name="celt">The number of STATPROPSETSTG structures to skip.</param>
@ -232,7 +232,7 @@ namespace Vanara.PInvoke
// STATPROPSTG *rgelt, ULONG *pceltFetched );
[PInvokeData("propidl.h", MSDNShortId = "8e911da9-0056-4267-b9d0-c4ba929ddb94")]
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] STATPROPSTG[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] STATPROPSTG[] rgelt, out uint pceltFetched);
/// <summary>The <c>Skip</c> method skips the specified number of STATPROPSTG structures in the enumeration sequence.</summary>
/// <param name="celt">The number of STATPROPSTG structures to skip.</param>

View File

@ -1254,7 +1254,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_caps-next HRESULT Next( ULONG celt,
// WIA_DEV_CAP *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] WIA_DEV_CAP[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] WIA_DEV_CAP[] rgelt, out uint pceltFetched);
/// <summary>
/// The <c>IEnumWIA_DEV_CAPS::Skip</c> method skips the specified number of hardware device capabilities during an enumeration
@ -1329,7 +1329,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_dev_info-next HRESULT Next( ULONG celt,
// IWiaPropertyStorage **rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IWiaPropertyStorage[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] IWiaPropertyStorage[] rgelt, out uint pceltFetched);
/// <summary>
/// The <c>IEnumWIA_DEV_INFO::Skip</c> method skips the specified number of hardware devices during an enumeration of available devices.
@ -1397,7 +1397,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwia_format_info-next HRESULT Next( ULONG celt,
// WIA_FORMAT_INFO *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] WIA_FORMAT_INFO[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] WIA_FORMAT_INFO[] rgelt, out uint pceltFetched);
/// <summary>The <c>IEnumWIA_FORMAT_INFO::Skip</c> method skips the specified number of structures in the enumeration.</summary>
/// <param name="celt">Specifies the number of structures to skip.</param>
@ -1488,7 +1488,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/wia_xp/nf-wia_xp-ienumwiaitem-next HRESULT Next( ULONG celt, IWiaItem
// **ppIWiaItem, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IWiaItem[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IWiaItem[] rgelt, out uint pceltFetched);
/// <summary>
/// The <c>IEnumWiaItem::Skip</c> method skips the specified number of items during an enumeration of available IWiaItem objects.

View File

@ -568,7 +568,7 @@ namespace Vanara.PInvoke
// ISearchRoot **rgelt, ULONG *pceltFetched );
[PInvokeData("searchapi.h")]
[PreserveSig]
HRESULT Next([In] uint celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] ISearchRoot[] rgelt, out uint pceltFetched);
HRESULT Next([In] uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] ISearchRoot[] rgelt, out uint pceltFetched);
/// <summary>Skips the specified number of elements.</summary>
/// <param name="celt">
@ -648,7 +648,7 @@ namespace Vanara.PInvoke
// celt, ISearchScopeRule **pprgelt, ULONG *pceltFetched );
[PInvokeData("searchapi.h")]
[PreserveSig]
HRESULT Next([In] uint celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] ISearchScopeRule[] pprgelt, ref uint pceltFetched);
HRESULT Next([In] uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] ISearchScopeRule[] pprgelt, ref uint pceltFetched);
/// <summary>Skips the specified number of elements.</summary>
/// <remarks>

View File

@ -285,7 +285,7 @@ namespace Vanara.PInvoke
/// </returns>
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ienumassochandlers-next HRESULT Next( ULONG
// celt, IAssocHandler **rgelt, ULONG *pceltFetched );
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IAssocHandler[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] IAssocHandler[] rgelt, out uint pceltFetched);
}
}
}

View File

@ -42,7 +42,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ienumobjects-next HRESULT Next( ULONG celt,
// REFIID riid, void **rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, in Guid riid, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown, SizeParamIndex = 3)] object[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, in Guid riid, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown, SizeParamIndex = 0)] object[] rgelt, out uint pceltFetched);
/// <summary>Skips a specified number of objects.</summary>
/// <param name="celt">

View File

@ -112,7 +112,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ienumexplorercommand-next HRESULT Next(
// ULONG celt, IExplorerCommand **pUICommand, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next([In] uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IExplorerCommand[] pUICommand, out uint pceltFetched);
HRESULT Next([In] uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] IExplorerCommand[] pUICommand, out uint pceltFetched);
/// <summary>Not currently implemented.</summary>
/// <param name="celt">

View File

@ -443,7 +443,7 @@ namespace Vanara.PInvoke
/// <returns>Returns S_OK if successful, or a COM-defined error code otherwise.</returns>
[PreserveSig]
HRESULT Next([In] uint celt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] EXTRASEARCH[] rgelt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] EXTRASEARCH[] rgelt,
out uint pceltFetched);
/// <summary>Skip a specified number of objects.</summary>

View File

@ -387,7 +387,7 @@ namespace Vanara.PInvoke
/// value will be 0 if there are no more items to retrieve.
/// </returns>
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 2)] IShellItem[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Interface, SizeParamIndex = 0)] IShellItem[] rgelt, out uint pceltFetched);
/// <summary>Skips the specified number of elements in the enumeration sequence.</summary>
/// <param name="celt">The number of IShellItem interfaces to skip.</param>

View File

@ -34,7 +34,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/fr-fr/windows/win32/api/shobjidl_core/nf-shobjidl_core-ienumresources-next HRESULT Next( ULONG
// celt, SHELL_ITEM_RESOURCE *psir, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] SHELL_ITEM_RESOURCE[] psir, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] SHELL_ITEM_RESOURCE[] psir, out uint pceltFetched);
/// <summary>Skips a specified number of resources.</summary>
/// <param name="celt">

View File

@ -1047,7 +1047,7 @@ namespace Vanara.PInvoke
/// value will be 0 if there are no more items to retrieve.
/// </returns>
[PreserveSig]
HRESULT Next(uint celt, [In, Out, MarshalAs(UnmanagedType.LPArray)] IntPtr[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] rgelt, out uint pceltFetched);
/// <summary>Skips the specified number of elements in the enumeration sequence.</summary>
/// <param name="celt">The number of item identifiers to skip.</param>
@ -1108,7 +1108,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ienumfullidlist-next HRESULT Next( ULONG
// celt, PIDLIST_ABSOLUTE *rgelt, ULONG *pceltFetched );
[PreserveSig]
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] rgelt, out uint pceltFetched);
HRESULT Next(uint celt, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] rgelt, out uint pceltFetched);
/// <summary>Skips a specified number of IDLIST_ABSOLUTE items.</summary>
/// <param name="celt">