Corrections to nullability based on CS samples

nullableenabled
David Hall 2023-11-18 22:51:00 -07:00
parent 460a46c899
commit 0f02552a01
12 changed files with 26 additions and 19 deletions

View File

@ -2066,7 +2066,7 @@ public static partial class Crypt32
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "20b3fcfb-55df-46ff-80a5-70f31a3d03b2")]
public static extern SafePCCERT_CONTEXT CertFindCertificateInStore(HCERTSTORE hCertStore, CertEncodingType dwCertEncodingType, CertFindUsageFlags dwFindFlags,
CertFindType dwFindType, [In, MarshalAs(UnmanagedType.LPWStr)] string pvFindPara, PCCERT_CONTEXT pPrevCertContext);
CertFindType dwFindType, [In, MarshalAs(UnmanagedType.LPWStr)] string? pvFindPara, PCCERT_CONTEXT pPrevCertContext);
/// <summary>
/// The <c>CertFreeServerOcspResponseContext</c> function decrements the reference count for a CERT_SERVER_OCSP_RESPONSE_CONTEXT

View File

@ -3057,7 +3057,7 @@ public static partial class Crypt32
// lpszStoreProvider, DWORD dwEncodingType, HCRYPTPROV_LEGACY hCryptProv, DWORD dwFlags, const void *pvPara );
[DllImport(Lib.Crypt32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("wincrypt.h", MSDNShortId = "4edccbfe-c0a8-442b-b6b7-51ef598e7c90")]
public static extern SafeHCERTSTORE CertOpenStore([In] SafeOID lpszStoreProvider, CertEncodingType dwEncodingType, [Optional] HCRYPTPROV hCryptProv, CertStoreFlags dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pvPara);
public static extern SafeHCERTSTORE CertOpenStore([In] SafeOID lpszStoreProvider, CertEncodingType dwEncodingType, [Optional] HCRYPTPROV hCryptProv, CertStoreFlags dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string? pvPara);
/// <summary>
/// The <c>CertOpenSystemStore</c> function is a simplified function that opens the most common system certificate store. To open

View File

@ -2694,7 +2694,8 @@ public static partial class Crypt32
/// string is passed as the pwszKeyName parameter to the NCryptOpenKey function.
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszContainerName;
[MarshalAs(UnmanagedType.LPWStr)]
public string pwszContainerName;
/// <summary>
/// <para>A pointer to a null-terminated Unicode string that contains the name of the CSP.</para>
@ -2703,7 +2704,8 @@ public static partial class Crypt32
/// passed as the pwszProviderName parameter to the NCryptOpenStorageProvider function.
/// </para>
/// </summary>
[MarshalAs(UnmanagedType.LPWStr)] public string pwszProvName;
[MarshalAs(UnmanagedType.LPWStr)]
public string? pwszProvName;
/// <summary>
/// <para>Specifies the CSP type. This can be zero or one of the Cryptographic Provider Types.</para>

View File

@ -1724,7 +1724,7 @@ public static partial class IScsiDsc
// RefreshISNSServerA( PSTR Address );
[DllImport(Lib_Iscsidsc, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("iscsidsc.h", MSDNShortId = "NF:iscsidsc.RefreshISNSServerA")]
public static extern Win32Error RefreshISNSServer([MarshalAs(UnmanagedType.LPTStr)] string Address);
public static extern Win32Error RefreshISNSServer([MarshalAs(UnmanagedType.LPTStr)] string? Address);
/// <summary>The <c>RemoveIscsiConnection</c> function removes a connection from an active session.</summary>
/// <param name="UniqueSessionId">
@ -1771,7 +1771,7 @@ public static partial class IScsiDsc
// RemoveIScsiPersistentTargetA( PSTR InitiatorInstance, ULONG InitiatorPortNumber, PSTR TargetName, PISCSI_TARGET_PORTALA Portal );
[DllImport(Lib_Iscsidsc, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("iscsidsc.h", MSDNShortId = "NF:iscsidsc.RemoveIScsiPersistentTargetA")]
public static extern Win32Error RemoveIScsiPersistentTarget([MarshalAs(UnmanagedType.LPTStr)] string InitiatorInstance, [Optional] uint InitiatorPortNumber,
public static extern Win32Error RemoveIScsiPersistentTarget([MarshalAs(UnmanagedType.LPTStr)] string? InitiatorInstance, [Optional] uint InitiatorPortNumber,
[MarshalAs(UnmanagedType.LPTStr)] string TargetName, in ISCSI_TARGET_PORTAL Portal);
/// <summary>
@ -1802,7 +1802,7 @@ public static partial class IScsiDsc
// RemoveIScsiPersistentTargetA( PSTR InitiatorInstance, ULONG InitiatorPortNumber, PSTR TargetName, PISCSI_TARGET_PORTALA Portal );
[DllImport(Lib_Iscsidsc, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("iscsidsc.h", MSDNShortId = "NF:iscsidsc.RemoveIScsiPersistentTargetA")]
public static extern Win32Error RemoveIScsiPersistentTarget([MarshalAs(UnmanagedType.LPTStr)] string InitiatorInstance, [Optional] uint InitiatorPortNumber,
public static extern Win32Error RemoveIScsiPersistentTarget([MarshalAs(UnmanagedType.LPTStr)] string? InitiatorInstance, [Optional] uint InitiatorPortNumber,
[MarshalAs(UnmanagedType.LPTStr)] string TargetName, [In, Optional] IntPtr Portal);
/// <summary>
@ -2419,7 +2419,7 @@ public static partial class IScsiDsc
// SetIScsiGroupPresharedKey( ULONG KeyLength, PUCHAR Key, BOOLEAN Persist );
[DllImport(Lib_Iscsidsc, SetLastError = false, ExactSpelling = true)]
[PInvokeData("iscsidsc.h", MSDNShortId = "NF:iscsidsc.SetIScsiGroupPresharedKey")]
public static extern Win32Error SetIScsiGroupPresharedKey(uint KeyLength, [In, MarshalAs(UnmanagedType.LPStr)] string Key,
public static extern Win32Error SetIScsiGroupPresharedKey(uint KeyLength, [In, MarshalAs(UnmanagedType.LPStr)] string? Key,
[MarshalAs(UnmanagedType.U1)] bool Persist);
/// <summary>

View File

@ -1415,7 +1415,7 @@ public static partial class Ole32
// dwCapabilities, _In_opt_ void *pReserved3); https://msdn.microsoft.com/en-us/library/windows/desktop/ms693736(v=vs.85).aspx
[DllImport(Lib.Ole32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Objbase.h", MSDNShortId = "ms693736")]
public static extern HRESULT CoInitializeSecurity([Optional] PSECURITY_DESCRIPTOR pSecDesc, int cAuthSvc,
public static extern HRESULT CoInitializeSecurity(PSECURITY_DESCRIPTOR pSecDesc, int cAuthSvc,
[MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] SOLE_AUTHENTICATION_SERVICE[]? asAuthSvc, [Optional] IntPtr pReserved1,
RPC_C_AUTHN_LEVEL dwAuthnLevel, RPC_C_IMP_LEVEL dwImpLevel, [In, Optional] SOLE_AUTHENTICATION_LIST? pAuthList,
EOLE_AUTHENTICATION_CAPABILITIES dwCapabilities, IntPtr pReserved3 = default);

View File

@ -972,7 +972,7 @@ public static partial class ProjectedFSLib
[DllImport(Lib.ProjectedFSLib, SetLastError = false, ExactSpelling = true)]
[PInvokeData("projectedfslib.h", MSDNShortId = "2BE57189-0F68-4CCD-8796-964EFDE0A02E")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool PrjFileNameMatch([MarshalAs(UnmanagedType.LPWStr)] string fileNameToCheck, [MarshalAs(UnmanagedType.LPWStr)] string pattern);
public static extern bool PrjFileNameMatch([MarshalAs(UnmanagedType.LPWStr)] string fileNameToCheck, [MarshalAs(UnmanagedType.LPWStr)] string? pattern);
/// <summary>Provides information for one file or directory to an enumeration.</summary>
/// <param name="fileName">A pointer to a null-terminated string that contains the name of the entry</param>

View File

@ -1040,7 +1040,7 @@ public static partial class AdvApi32
// LPCSTR lpSubKey, LPCSTR lpValueName );
[DllImport(Lib.AdvApi32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winreg.h", MSDNShortId = "a4a082c2-8cf3-41eb-87c0-a6c453821f8b")]
public static extern Win32Error RegDeleteKeyValue(HKEY hKey, string lpSubKey, string lpValueName);
public static extern Win32Error RegDeleteKeyValue(HKEY hKey, string? lpSubKey, string? lpValueName);
/// <summary>
/// <para>Deletes the subkeys and values of the specified key recursively.</para>

View File

@ -318,6 +318,11 @@ public class PRECT : IEquatable<PRECT>, IEquatable<RECT>, IEquatable<Rectangle>
/// <returns>The result of the conversion.</returns>
public static implicit operator PRECT?(Rectangle? r) => r.HasValue ? new PRECT(r.Value) : null;
/// <summary>Performs an implicit conversion from <see cref="RECT"/> to <see cref="PRECT"/>.</summary>
/// <param name="r">The <see cref="RECT"/> to convert.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator PRECT(RECT r) => new(r);
/// <summary>Performs an implicit conversion from <see cref="Nullable{RECT}"/> to <see cref="PRECT"/>.</summary>
/// <param name="r">The <see cref="RECT"/> to convert.</param>
/// <returns>The result of the conversion.</returns>

View File

@ -1283,7 +1283,7 @@ public static partial class MSCTF
// https://docs.microsoft.com/en-us/windows/win32/api/textstor/nf-textstor-itextstoreacp-getformattedtext HRESULT
// GetFormattedText( LONG acpStart, LONG acpEnd, IDataObject **ppDataObject );
[PreserveSig]
HRESULT GetFormattedText([In] int acpStart, [In] int acpEnd, [Out, MarshalAs(UnmanagedType.Interface)] out IDataObject ppDataObject);
HRESULT GetFormattedText([In] int acpStart, [In] int acpEnd, [Out, MarshalAs(UnmanagedType.Interface)] out IDataObject? ppDataObject);
/// <summary>Gets an embedded document.</summary>
/// <param name="acpPos">Contains the character position, within the document, from where the object is obtained.</param>
@ -2632,7 +2632,7 @@ public static partial class MSCTF
// https://docs.microsoft.com/en-us/windows/win32/api/textstor/nf-textstor-itextstoreacp2-getformattedtext HRESULT
// GetFormattedText( LONG acpStart, LONG acpEnd, IDataObject **ppDataObject );
[PreserveSig]
HRESULT GetFormattedText([In] int acpStart, [In] int acpEnd, [Out, MarshalAs(UnmanagedType.Interface)] out IDataObject ppDataObject);
HRESULT GetFormattedText([In] int acpStart, [In] int acpEnd, [Out, MarshalAs(UnmanagedType.Interface)] out IDataObject? ppDataObject);
/// <summary>Gets an embedded document.</summary>
/// <param name="acpPos">Contains the character position, within the document, from where the object is obtained.</param>
@ -6046,7 +6046,7 @@ public static partial class MSCTF
/// <summary>Value of the attribute.</summary>
[MarshalAs(UnmanagedType.Struct)]
public object varValue;
public object? varValue;
}
/// <summary>The <c>TS_RUNINFO</c> structure specifies the properties of text run data.</summary>

View File

@ -900,7 +900,7 @@ public static partial class MSCTF
// https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itffunctionprovider-getdescription HRESULT GetDescription(
// BSTR *pbstrDesc );
[PreserveSig]
HRESULT GetDescription([Out, MarshalAs(UnmanagedType.BStr)] out string pbstrDesc);
HRESULT GetDescription([Out, MarshalAs(UnmanagedType.BStr)] out string? pbstrDesc);
/// <summary>Obtains the specified function object.</summary>
/// <param name="rguid">
@ -939,7 +939,7 @@ public static partial class MSCTF
// https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itffunctionprovider-getfunction HRESULT GetFunction(
// REFGUID rguid, REFIID riid, IUnknown **ppunk );
[PreserveSig]
HRESULT GetFunction(in Guid rguid, in Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown)] out object ppunk);
HRESULT GetFunction(in Guid rguid, in Guid riid, [Out, MarshalAs(UnmanagedType.IUnknown)] out object? ppunk);
}
/// <summary>
@ -2739,7 +2739,7 @@ public static partial class MSCTF
// https://docs.microsoft.com/en-us/windows/win32/api/msctf/nf-msctf-itfpersistentpropertyloaderacp-loadproperty HRESULT
// LoadProperty( const TF_PERSISTENT_PROPERTY_HEADER_ACP *pHdr, IStream **ppStream );
[PreserveSig]
HRESULT LoadProperty(in TF_PERSISTENT_PROPERTY_HEADER_ACP pHdr, out IStream ppStream);
HRESULT LoadProperty(in TF_PERSISTENT_PROPERTY_HEADER_ACP pHdr, out IStream? ppStream);
}
/// <summary>

View File

@ -1749,7 +1749,7 @@ public static partial class WinHTTP
public static extern SafeHINTERNET WinHttpOpenRequest(HINTERNET hConnect, [MarshalAs(UnmanagedType.LPWStr)] string pwszVerb,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszObjectName, [Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszVersion,
[Optional, MarshalAs(UnmanagedType.LPWStr)] string? pwszReferrer,
[In, Optional, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string[]? ppwszAcceptTypes, [Optional] WINHTTP_OPENREQ_FLAG dwFlags);
[In, Optional, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)] string?[]? ppwszAcceptTypes, [Optional] WINHTTP_OPENREQ_FLAG dwFlags);
/// <summary>The <c>WinHttpQueryAuthSchemes</c> function returns the authorization schemes that are supported by the server.</summary>
/// <param name="hRequest">Valid HINTERNET handle returned by WinHttpOpenRequest</param>

View File

@ -231,7 +231,7 @@ public static partial class Ws2_32
/// <para>Type: <c>SOCKET</c></para>
/// <para>The identifier of the socket for which to find status. This parameter is ignored if set to a negative value. See Remarks.</para>
/// </summary>
public SOCKET fd;
public SOCKET? fd;
/// <summary>
/// <para>Type: <c>short</c></para>