From b429b0e793ab71917aa1d40e68b4c3c26caebe9a Mon Sep 17 00:00:00 2001 From: David Hall Date: Sun, 22 Oct 2023 15:12:23 -0600 Subject: [PATCH] Added nullability to WcnApi --- PInvoke/WcnApi/WcnDevice.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PInvoke/WcnApi/WcnDevice.cs b/PInvoke/WcnApi/WcnDevice.cs index a00e9589..dfe386fb 100644 --- a/PInvoke/WcnApi/WcnDevice.cs +++ b/PInvoke/WcnApi/WcnDevice.cs @@ -158,7 +158,7 @@ public static partial class WcnApi // https://docs.microsoft.com/en-us/windows/win32/api/wcndevice/nf-wcndevice-iwcndevice-setpassword HRESULT SetPassword( // WCN_PASSWORD_TYPE Type, DWORD dwPasswordLength, const BYTE [] pbPassword ); [PreserveSig] - HRESULT SetPassword(WCN_PASSWORD_TYPE Type, uint dwPasswordLength, [MarshalAs(UnmanagedType.LPStr)] string pbPassword); + HRESULT SetPassword(WCN_PASSWORD_TYPE Type, uint dwPasswordLength, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pbPassword); /// The IWCNDevice::Connect method initiates the session. /// @@ -198,7 +198,7 @@ public static partial class WcnApi // https://docs.microsoft.com/en-us/windows/win32/api/wcndevice/nf-wcndevice-iwcndevice-connect HRESULT Connect( // IWCNConnectNotify *pNotify ); [PreserveSig] - HRESULT Connect([In, Optional] IWCNConnectNotify pNotify); + HRESULT Connect([In, Optional] IWCNConnectNotify? pNotify); /// The IWCNDevice::GetAttribute method gets a cached attribute from the device. /// @@ -235,7 +235,7 @@ public static partial class WcnApi // https://docs.microsoft.com/en-us/windows/win32/api/wcndevice/nf-wcndevice-iwcndevice-getattribute HRESULT GetAttribute( // WCN_ATTRIBUTE_TYPE AttributeType, DWORD dwMaxBufferSize, BYTE [] pbBuffer, DWORD *pdwBufferUsed ); [PreserveSig] - HRESULT GetAttribute(WCN_ATTRIBUTE_TYPE AttributeType, uint dwMaxBufferSize, [Out] IntPtr pbBuffer, out uint pdwBufferUsed); + HRESULT GetAttribute(WCN_ATTRIBUTE_TYPE AttributeType, [In, Optional] uint dwMaxBufferSize, [Out, Optional] IntPtr pbBuffer, out uint pdwBufferUsed); /// The GetIntegerAttribute method gets a cached attribute from the device as an integer. /// @@ -498,7 +498,7 @@ public static partial class WcnApi public static T GetIntegerAttribute(this IWCNDevice iDev, WCN_ATTRIBUTE_TYPE AttributeType) where T : struct, IConvertible { var hr = iDev.GetIntegerAttribute(AttributeType, out var u); - return hr.Succeeded ? (T)Convert.ChangeType(u, typeof(T)) : throw hr.GetException(); + return hr.Succeeded ? (T)Convert.ChangeType(u, typeof(T)) : throw hr.GetException()!; } /// The WCN_VENDOR_EXTENSION_SPEC structure contains data that defines a vendor extension.