From 2c10bf7415234d7ae5c4cfb897697b2634260acb Mon Sep 17 00:00:00 2001 From: David Hall Date: Mon, 25 Sep 2023 07:37:32 -0600 Subject: [PATCH] Added nullability to AclUI and tests --- PInvoke/AclUI/AclUI.cs | 21 ++++++++++++++------- UnitTests/PInvoke/AclUI/AclUITests.cs | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/PInvoke/AclUI/AclUI.cs b/PInvoke/AclUI/AclUI.cs index 6f5fdfd9..e39f2144 100644 --- a/PInvoke/AclUI/AclUI.cs +++ b/PInvoke/AclUI/AclUI.cs @@ -586,7 +586,7 @@ public static partial class AclUI /// or destroyed. /// [PreserveSig] - HRESULT PropertySheetPageCallback([In] HWND hwnd, [In] PropertySheetCallbackMessage uMsg, [In] SI_PAGE_TYPE uPage); + HRESULT PropertySheetPageCallback([In, Optional] HWND hwnd, [In] PropertySheetCallbackMessage uMsg, [In] SI_PAGE_TYPE uPage); } /// @@ -805,8 +805,10 @@ public static partial class AclUI /// /// [PInvokeData("aclui.h", MSDNShortId = "E451BBB9-4E01-4A8F-9ACD-750351F16453")] +#pragma warning disable IL2050 // Correctness of COM interop cannot be guaranteed after trimming. Interfaces and interface members might be removed. public static HRESULT EditSecurityAdvanced([Optional] HWND hwndOwner, ISecurityInformation psi, SI_PAGE_TYPE pageType, SI_PAGE_ACTIVATED pageActivated) => EditSecurityAdvanced(hwndOwner, psi, COMBINE_PAGE_ACTIVATION(pageType, pageActivated)); +#pragma warning restore IL2050 // Correctness of COM interop cannot be guaranteed after trimming. Interfaces and interface members might be removed. /// The EFFPERM_RESULT_LIST structure lists the effective permissions. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] @@ -814,7 +816,8 @@ public static partial class AclUI public struct EFFPERM_RESULT_LIST { /// Indicates if the effective permissions results have been evaluated. - [MarshalAs(UnmanagedType.Bool)] public bool fEvaluated; + [MarshalAs(UnmanagedType.Bool)] + public bool fEvaluated; /// The number of elements in both the pObjectTypeList and pGrantedAccessList members. public uint cObjectTypeListLength; @@ -822,12 +825,14 @@ public static partial class AclUI /// /// A pointer to an array of OBJECT_TYPE_LIST structures that specifies the properties and property sets for which access was evaluated. /// - [MarshalAs(UnmanagedType.LPArray)] public OBJECT_TYPE_LIST[] pObjectTypeList; + [MarshalAs(UnmanagedType.LPArray)] + public OBJECT_TYPE_LIST[] pObjectTypeList; /// /// A pointer to an array of ACCESS_MASK values that specifies the access rights granted for each corresponding object type. /// - [MarshalAs(UnmanagedType.LPArray)] public uint[] pGrantedAccessList; + [MarshalAs(UnmanagedType.LPArray)] + public uint[] pGrantedAccessList; } /// The SECURITY_OBJECT structure contains the security object information. @@ -836,7 +841,8 @@ public static partial class AclUI public struct SECURITY_OBJECT { /// A pointer to the name. - [MarshalAs(UnmanagedType.LPWStr)] public string pwszName; + [MarshalAs(UnmanagedType.LPWStr)] + public string pwszName; /// A pointer to the security data. public IntPtr pData; @@ -866,7 +872,8 @@ public static partial class AclUI public uint Id; /// TRUE if the security object represents one of the well-know security objects listed in the Id member. - [MarshalAs(UnmanagedType.Bool)] public bool fWellKnown; + [MarshalAs(UnmanagedType.Bool)] + public bool fWellKnown; } /// @@ -969,7 +976,7 @@ public static partial class AclUI /// designated for the SID structure, the value of this parameter is NULL. /// [MarshalAs(UnmanagedType.LPWStr)] - public string pwzUPN; + public string? pwzUPN; } /// diff --git a/UnitTests/PInvoke/AclUI/AclUITests.cs b/UnitTests/PInvoke/AclUI/AclUITests.cs index b1ba4300..681bcbc4 100644 --- a/UnitTests/PInvoke/AclUI/AclUITests.cs +++ b/UnitTests/PInvoke/AclUI/AclUITests.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. +using NUnit.Framework; using static Vanara.PInvoke.AclUI; namespace Vanara.PInvoke.Tests;