From 2307418f2e87873b8df8c39bde5f88f253aefc23 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 24 Nov 2021 14:19:34 -0700 Subject: [PATCH] Use GeneratedDllImport for blittable p/invokes in System.Console, System.IO.FileSystem.Watcher, System.IO.Pipes (#61996) --- .../Common/src/Interop/OSX/Interop.EventStream.cs | 12 ++++++------ .../Interop.Keychain.macOS.cs | 4 ++-- .../Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs | 4 ++-- .../System.Native/Interop.ReadStdinUnbuffered.cs | 8 ++++---- .../Interop/Unix/System.Native/Interop.SetEUid.cs | 4 ++-- .../Unix/System.Native/Interop.SetSignalForBreak.cs | 8 ++++---- .../Interop.SetTerminalInvalidationHandler.cs | 4 ++-- .../src/Interop/Unix/System.Native/Interop.Sync.cs | 4 ++-- .../Interop.OCSP.cs | 8 ++++---- .../Interop.Pkcs7.cs | 4 ++-- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs b/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs index b0d312ff824f4..db2675f73a58d 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs @@ -140,16 +140,16 @@ internal static partial void FSEventStreamScheduleWithRunLoop( /// Stops receiving events on the specified stream. The stream can be restarted and not miss any events. /// /// The stream to stop receiving events on. - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern void FSEventStreamStop(IntPtr streamRef); + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial void FSEventStreamStop(IntPtr streamRef); /// /// Invalidates an EventStream and removes it from any RunLoops. /// /// The FSEventStream to invalidate /// This can only be called after FSEventStreamScheduleWithRunLoop has be called - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern void FSEventStreamInvalidate(IntPtr streamRef); + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial void FSEventStreamInvalidate(IntPtr streamRef); /// /// Removes the event stream from the RunLoop. @@ -167,7 +167,7 @@ internal static partial void FSEventStreamUnscheduleFromRunLoop( /// Releases a reference count on the specified EventStream and, if necessary, cleans the stream up. /// /// The stream on which to decrement the reference count. - [DllImport(Interop.Libraries.CoreServicesLibrary)] - internal static extern void FSEventStreamRelease(IntPtr streamRef); + [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)] + internal static partial void FSEventStreamRelease(IntPtr streamRef); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs index 8898f400ada6b..ebe9e3af8d2eb 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs @@ -34,8 +34,8 @@ private static partial int AppleCryptoNative_SecKeychainCreate( byte[] utf8Passphrase, out SafeKeychainHandle keychain); - [DllImport(Libraries.AppleCryptoNative)] - private static extern int AppleCryptoNative_SecKeychainDelete(IntPtr keychain); + [GeneratedDllImport(Libraries.AppleCryptoNative)] + private static partial int AppleCryptoNative_SecKeychainDelete(IntPtr keychain); [GeneratedDllImport(Libraries.AppleCryptoNative)] private static partial int AppleCryptoNative_SecKeychainCopyDefault(out SafeKeychainHandle keychain); diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs index 6361f87fc0ee4..c44493fa28630 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs @@ -19,9 +19,9 @@ internal static partial class Fcntl [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlSetPipeSz", SetLastError=true)] internal static partial int SetPipeSz(SafePipeHandle fd, int size); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlCanGetSetPipeSz")] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FcntlCanGetSetPipeSz")] [SuppressGCTransition] - private static extern int FcntlCanGetSetPipeSz(); + private static partial int FcntlCanGetSetPipeSz(); } } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs index 03565b1dd1747..c751528354b76 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs @@ -11,10 +11,10 @@ internal static partial class Sys [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadStdin", SetLastError = true)] internal static unsafe partial int ReadStdin(byte* buffer, int bufferSize); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeConsoleBeforeRead")] - internal static extern void InitializeConsoleBeforeRead(byte minChars = 1, byte decisecondsTimeout = 0); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_InitializeConsoleBeforeRead")] + internal static partial void InitializeConsoleBeforeRead(byte minChars = 1, byte decisecondsTimeout = 0); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UninitializeConsoleAfterRead")] - internal static extern void UninitializeConsoleAfterRead(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UninitializeConsoleAfterRead")] + internal static partial void UninitializeConsoleAfterRead(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetEUid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetEUid.cs index 6a40f17c6dead..2a52122fc51b1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetEUid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetEUid.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetEUid")] - internal static extern int SetEUid(uint euid); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetEUid")] + internal static partial int SetEUid(uint euid); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSignalForBreak.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSignalForBreak.cs index 51603d6d1e4a4..8a504d7a0b8f5 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSignalForBreak.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSignalForBreak.cs @@ -7,11 +7,11 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSignalForBreak")] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSignalForBreak")] [SuppressGCTransition] - internal static extern int GetSignalForBreak(); + internal static partial int GetSignalForBreak(); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSignalForBreak")] - internal static extern int SetSignalForBreak(int signalForBreak); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetSignalForBreak")] + internal static partial int SetSignalForBreak(int signalForBreak); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetTerminalInvalidationHandler.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetTerminalInvalidationHandler.cs index 3082cb96b7183..7661463b7b9cf 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetTerminalInvalidationHandler.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetTerminalInvalidationHandler.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetTerminalInvalidationHandler")] - internal static extern unsafe void SetTerminalInvalidationHandler(delegate* unmanaged handler); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetTerminalInvalidationHandler")] + internal static unsafe partial void SetTerminalInvalidationHandler(delegate* unmanaged handler); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Sync.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Sync.cs index e51680db75089..3b2246fbe9699 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Sync.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Sync.cs @@ -11,7 +11,7 @@ internal static partial class Sys /// /// Forces a write of all modified I/O buffers to their storage mediums. /// - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sync")] - internal static extern void Sync(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sync")] + internal static partial void Sync(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs index c052f5a4c5fe5..86ec6c33191e0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs @@ -12,8 +12,8 @@ internal static partial class Interop { internal static partial class Crypto { - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspRequestDestroy")] - internal static extern void OcspRequestDestroy(IntPtr ocspReq); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspRequestDestroy")] + internal static partial void OcspRequestDestroy(IntPtr ocspReq); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetOcspRequestDerSize")] internal static partial int GetOcspRequestDerSize(SafeOcspRequestHandle req); @@ -31,8 +31,8 @@ ref MemoryMarshal.GetReference(buf), buf.Length); } - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspResponseDestroy")] - internal static extern void OcspResponseDestroy(IntPtr ocspReq); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_OcspResponseDestroy")] + internal static partial void OcspResponseDestroy(IntPtr ocspReq); [GeneratedDllImport(Libraries.CryptoNative, CharSet = CharSet.Ansi)] private static partial int CryptoNative_X509ChainGetCachedOcspStatus( diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs index 657e7cbcda4b9..a1d5568e42edf 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs @@ -24,8 +24,8 @@ internal static SafePkcs7Handle DecodePkcs7(ReadOnlySpan buf) => [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7CreateCertificateCollection")] internal static partial SafePkcs7Handle Pkcs7CreateCertificateCollection(SafeX509StackHandle certs); - [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7Destroy")] - internal static extern void Pkcs7Destroy(IntPtr p7); + [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_Pkcs7Destroy")] + internal static partial void Pkcs7Destroy(IntPtr p7); [GeneratedDllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_GetPkcs7Certificates")] private static partial int GetPkcs7Certificates(SafePkcs7Handle p7, out SafeSharedX509StackHandle certs);