Use GeneratedDllImport for blittable p/invokes in System.Console, System.IO.FileSyste...
authorElinor Fung <elfung@microsoft.com>
Wed, 24 Nov 2021 21:19:34 +0000 (14:19 -0700)
committerGitHub <noreply@github.com>
Wed, 24 Nov 2021 21:19:34 +0000 (14:19 -0700)
src/libraries/Common/src/Interop/OSX/Interop.EventStream.cs
src/libraries/Common/src/Interop/OSX/System.Security.Cryptography.Native.Apple/Interop.Keychain.macOS.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.Fcntl.Pipe.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadStdinUnbuffered.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetEUid.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetSignalForBreak.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetTerminalInvalidationHandler.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.Sync.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.OCSP.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Pkcs7.cs

index b0d312f..db2675f 100644 (file)
@@ -140,16 +140,16 @@ internal static partial class Interop
         /// Stops receiving events on the specified stream. The stream can be restarted and not miss any events.
         /// </summary>
         /// <param name="streamRef">The stream to stop receiving events on.</param>
-        [DllImport(Interop.Libraries.CoreServicesLibrary)]
-        internal static extern void FSEventStreamStop(IntPtr streamRef);
+        [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)]
+        internal static partial void FSEventStreamStop(IntPtr streamRef);
 
         /// <summary>
         /// Invalidates an EventStream and removes it from any RunLoops.
         /// </summary>
         /// <param name="streamRef">The FSEventStream to invalidate</param>
         /// <remarks>This can only be called after FSEventStreamScheduleWithRunLoop has be called</remarks>
-        [DllImport(Interop.Libraries.CoreServicesLibrary)]
-        internal static extern void FSEventStreamInvalidate(IntPtr streamRef);
+        [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)]
+        internal static partial void FSEventStreamInvalidate(IntPtr streamRef);
 
         /// <summary>
         /// Removes the event stream from the RunLoop.
@@ -167,7 +167,7 @@ internal static partial class Interop
         /// Releases a reference count on the specified EventStream and, if necessary, cleans the stream up.
         /// </summary>
         /// <param name="streamRef">The stream on which to decrement the reference count.</param>
-        [DllImport(Interop.Libraries.CoreServicesLibrary)]
-        internal static extern void FSEventStreamRelease(IntPtr streamRef);
+        [GeneratedDllImport(Interop.Libraries.CoreServicesLibrary)]
+        internal static partial void FSEventStreamRelease(IntPtr streamRef);
     }
 }
index 8898f40..ebe9e3a 100644 (file)
@@ -34,8 +34,8 @@ internal static partial class Interop
             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);
index 6361f87..c44493f 100644 (file)
@@ -19,9 +19,9 @@ internal static partial class Interop
             [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();
         }
     }
 }
index 03565b1..c751528 100644 (file)
@@ -11,10 +11,10 @@ internal static partial class Interop
         [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();
     }
 }
index 6a40f17..2a52122 100644 (file)
@@ -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);
     }
 }
index 51603d6..8a504d7 100644 (file)
@@ -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);
     }
 }
index 3082cb9..7661463 100644 (file)
@@ -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<void> handler);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetTerminalInvalidationHandler")]
+        internal static unsafe partial void SetTerminalInvalidationHandler(delegate* unmanaged<void> handler);
     }
 }
index e51680d..3b2246f 100644 (file)
@@ -11,7 +11,7 @@ internal static partial class Interop
         /// <summary>
         /// Forces a write of all modified I/O buffers to their storage mediums.
         /// </summary>
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sync")]
-        internal static extern void Sync();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Sync")]
+        internal static partial void Sync();
     }
 }
index c052f5a..86ec6c3 100644 (file)
@@ -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 @@ internal static partial class Interop
                 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(
index 657e7cb..a1d5568 100644 (file)
@@ -24,8 +24,8 @@ internal static partial class Interop
         [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);