Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all DLLIMPORTGENERATOR_ENABLED usage. #61476

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion eng/generators.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<EnableDllImportGenerator Condition="'$(EnableDllImportGenerator)' == ''
and '$(MSBuildProjectName)' == 'System.Private.CoreLib'">true</EnableDllImportGenerator>
<SetDllImportGeneratorConstants>false</SetDllImportGeneratorConstants>
<IncludeDllImportGeneratorSources Condition="'$(IncludeDllImportGeneratorSources)' == ''">true</IncludeDllImportGeneratorSources>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ internal enum CryptAcquireContextFlags : uint
CRYPT_VERIFYCONTEXT = 0xF0000000 // CRYPT_VERIFYCONTEXT
}

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)]
public static partial bool CryptAcquireContext(
#else
[DllImport(Libraries.Advapi32, EntryPoint = "CryptAcquireContextW", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptAcquireContext(
#endif
out SafeProvHandle phProv,
string? szContainer,
string? szProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static partial bool CryptDestroyHash(IntPtr hHash);
#else
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptDestroyHash(IntPtr hHash);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static partial bool CryptDestroyKey(IntPtr hKey);
#else
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CryptDestroyKey(IntPtr hKey);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,22 @@ internal enum CryptProvParam : int
PP_UNIQUE_CONTAINER = 36
}

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
public static partial bool CryptSetProvParam(
#else
[DllImport(Libraries.Advapi32, SetLastError = true)]
public static extern bool CryptSetProvParam(
#endif
SafeHandle safeProvHandle,
CryptProvParam dwParam,
IntPtr pbData,
int dwFlags);

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
public static partial bool CryptSetProvParam(
#else
[DllImport(Libraries.Advapi32, SetLastError = true)]
public static extern bool CryptSetProvParam(
#endif
SafeProvHandle hProv,
CryptProvParam dwParam,
ref IntPtr pbData,
int dwFlags);

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
public static partial bool CryptGetProvParam(
#else
[DllImport(Libraries.Advapi32, SetLastError = true)]
public static extern bool CryptGetProvParam(
#endif
SafeHandle safeProvHandle,
CryptProvParam dwParam,
IntPtr pbData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
public static partial bool CryptReleaseContext(
#else
[DllImport(Libraries.Advapi32, SetLastError = true)]
public static extern bool CryptReleaseContext(
#endif
IntPtr hProv,
int dwFlags);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ internal static partial class Advapi32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use EncryptFile.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", CharSet = CharSet.Unicode, SetLastError = true)]
private static partial bool EncryptFilePrivate(string lpFileName);
#else
[DllImport(Libraries.Advapi32, EntryPoint = "EncryptFileW", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool EncryptFilePrivate(string lpFileName);
#endif

internal static bool EncryptFile(string path)
{
Expand All @@ -28,13 +23,8 @@ internal static bool EncryptFile(string path)
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DecryptFile.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", CharSet = CharSet.Unicode, SetLastError = true)]
private static partial bool DecryptFileFilePrivate(
#else
[DllImport(Libraries.Advapi32, EntryPoint = "DecryptFileW", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool DecryptFileFilePrivate(
#endif
string lpFileName,
int dwReserved);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool OpenProcessToken(
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern bool OpenProcessToken(
#endif
IntPtr ProcessToken,
TokenAccessLevels DesiredAccess,
out SafeAccessTokenHandle TokenHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial bool CertCloseStore(IntPtr hCertStore, uint dwFlags);
#else
[DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CertCloseStore(IntPtr hCertStore, uint dwFlags);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial SafeCertContextHandle CertDuplicateCertificateContext(IntPtr pCertContext);
#else
[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern SafeCertContextHandle CertDuplicateCertificateContext(IntPtr pCertContext);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
#if UNITTEST
AaronRobinsonMSFT marked this conversation as resolved.
Show resolved Hide resolved
[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern unsafe CERT_CONTEXT* CertEnumCertificatesInStore(
#else
[GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
public static unsafe partial CERT_CONTEXT* CertEnumCertificatesInStore(
#else
[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
public static unsafe extern CERT_CONTEXT* CertEnumCertificatesInStore(
#endif
IntPtr hCertStore,
CERT_CONTEXT* pPrevCertContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ internal static partial class Interop
internal static partial class Crypt32
{
// Note: This api always return TRUE, regardless of success.
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial bool CertFreeCertificateContext(IntPtr pCertContext);
#else
[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CertFreeCertificateContext(IntPtr pCertContext);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED

[GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial bool CertGetCertificateContextProperty(
SafeCertContextHandle pCertContext,
Expand All @@ -31,30 +29,5 @@ internal static partial bool CertGetCertificateContextProperty(
CertContextPropId dwPropId,
out DATA_BLOB pvData,
ref int pcbData);

#else

[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CertGetCertificateContextProperty(
SafeCertContextHandle pCertContext,
CertContextPropId dwPropId,
[Out] byte[]? pvData,
[In, Out] ref int pcbData);

[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CertGetCertificateContextProperty(
SafeCertContextHandle pCertContext,
CertContextPropId dwPropId,
out IntPtr pvData,
[In, Out] ref int pcbData);

[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CertGetCertificateContextProperty(
SafeCertContextHandle pCertContext,
CertContextPropId dwPropId,
[Out] out DATA_BLOB pvData,
[In, Out] ref int pcbData);

#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,11 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial bool CertGetCertificateContextProperty(
SafeCertContextHandle pCertContext,
CertContextPropId dwPropId,
byte[] pvData,
ref int pcbData);
#else
[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CertGetCertificateContextProperty(
SafeCertContextHandle pCertContext,
CertContextPropId dwPropId,
[Out] byte[] pvData,
[In, Out] ref int pcbData);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, EntryPoint = "CertNameToStrW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static unsafe partial int CertNameToStr(
#else
[DllImport(Libraries.Crypt32, EntryPoint = "CertNameToStrW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern unsafe int CertNameToStr(
#endif
int dwCertEncodingType,
void* pName,
int dwStrType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial bool CryptMsgClose(IntPtr hCryptMsg);
#else
[DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CryptMsgClose(IntPtr hCryptMsg);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,32 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, SetLastError = true)]
internal static partial bool CryptMsgGetParam(
#else
[DllImport(Libraries.Crypt32, SetLastError = true)]
internal static extern bool CryptMsgGetParam(
#endif
SafeCryptMsgHandle hCryptMsg,
CryptMsgParamType dwParamType,
int dwIndex,
out int pvData,
ref int pcbData);

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, SetLastError = true)]
internal static unsafe partial bool CryptMsgGetParam(
#else
[DllImport(Libraries.Crypt32, SetLastError = true)]
internal static unsafe extern bool CryptMsgGetParam(
#endif
SafeCryptMsgHandle hCryptMsg,
CryptMsgParamType dwParamType,
int dwIndex,
byte* pvData,
ref int pcbData);

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, SetLastError = true)]
internal static partial bool CryptMsgGetParam(
#else
[DllImport(Libraries.Crypt32, SetLastError = true)]
internal static extern bool CryptMsgGetParam(
#endif
SafeCryptMsgHandle hCryptMsg,
CryptMsgParamType dwParamType,
int dwIndex,
out CryptMsgType pvData,
ref int pcbData);

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Crypt32, SetLastError = true)]
internal static partial bool CryptMsgGetParam(
#else
[DllImport(Libraries.Crypt32, SetLastError = true)]
internal static extern bool CryptMsgGetParam(
#endif
SafeCryptMsgHandle hCryptMsg,
CryptMsgParamType dwParamType,
int dwIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,13 @@ internal static partial class Interop
{
internal static partial class Crypt32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool CertFreeCertificateContext(IntPtr pCertContext);
#else
[DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CertFreeCertificateContext(IntPtr pCertContext);
#endif

#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool CertVerifyCertificateChainPolicy(
#else
[DllImport(Interop.Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool CertVerifyCertificateChainPolicy(
#endif
IntPtr pszPolicyOID,
SafeX509ChainHandle pChainContext,
ref CERT_CHAIN_POLICY_PARA pPolicyPara,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ internal static partial class Kernel32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static unsafe partial SafeFileHandle CreateFilePrivate(
#else
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static unsafe extern SafeFileHandle CreateFilePrivate(
#endif
string lpFileName,
int dwDesiredAccess,
FileShare dwShareMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static partial bool FlushFileBuffers(SafeHandle hHandle);
#else
[DllImport(Libraries.Kernel32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FlushFileBuffers(SafeHandle hHandle);
#endif
}
}
Loading