From 0c1a93fcfe1935cd45ecd7f6e1fe6f2c99a22f00 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Thu, 11 Nov 2021 17:04:00 -0800 Subject: [PATCH 1/4] Use GeneratedDllImport for blittable p/invokes in System.Diagnostics.Process --- .../Common/src/Interop/Unix/Interop.Errors.cs | 24 +++++++++---------- .../Unix/System.Native/Interop.GetEGid.cs | 4 ++-- .../Unix/System.Native/Interop.GetEUid.cs | 4 ++-- .../Unix/System.Native/Interop.GetGroups.cs | 4 ++-- .../Unix/System.Native/Interop.GetSid.cs | 4 ++-- .../Unix/System.Native/Interop.GetUid.cs | 4 ++-- .../Interop.RegisterForSigChld.cs | 4 ++-- ...ayedSigChildConsoleConfigurationHandler.cs | 4 ++-- .../Windows/Kernel32/Interop.GetCPInfoEx.cs | 4 ++-- .../Windows/Kernel32/Interop.GetConsoleCP.cs | 4 ++-- .../Kernel32/Interop.GetConsoleOutputCP.cs | 4 ++-- .../Windows/Kernel32/Interop.GetStdHandle.cs | 4 ++-- .../Kernel32/Interop.MultiByteToWideChar.cs | 4 ++-- .../Kernel32/Interop.VerLanguageName.cs | 4 ++-- .../Kernel32/Interop.WideCharToMultiByte.cs | 4 ++-- .../NtDll/Interop.NtQuerySystemInformation.cs | 4 ++-- .../Windows/User32/Interop.EnumWindows.cs | 4 ++-- .../Windows/User32/Interop.GetKeyState.cs | 4 ++-- .../Windows/User32/Interop.GetWindow.cs | 4 ++-- .../Windows/User32/Interop.GetWindowLong.cs | 4 ++-- .../Interop.GetWindowThreadProcessId.cs | 4 ++-- .../Windows/User32/Interop.IsWindowVisible.cs | 4 ++-- .../Windows/User32/Interop.PostMessage.cs | 4 ++-- .../User32/Interop.SendMessageTimeout.cs | 4 ++-- ...m.Diagnostics.FileVersionInfo.Tests.csproj | 3 ++- .../src/System.Text.Encoding.CodePages.csproj | 1 + 26 files changed, 61 insertions(+), 59 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs index 4e9b16098dcad..88af774f71912 100644 --- a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs +++ b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs @@ -183,25 +183,25 @@ internal static unsafe string StrError(int platformErrno) } #if SERIAL_PORTS - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")] - internal static extern Error ConvertErrorPlatformToPal(int platformErrno); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPlatformToPal")] + internal static partial Error ConvertErrorPlatformToPal(int platformErrno); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")] - internal static extern int ConvertErrorPalToPlatform(Error error); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_ConvertErrorPalToPlatform")] + internal static partial int ConvertErrorPalToPlatform(Error error); - [DllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")] - private static extern unsafe byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.IOPortsNative, EntryPoint = "SystemIoPortsNative_StrErrorR")] + private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #else - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPlatformToPal")] [SuppressGCTransition] - internal static extern Error ConvertErrorPlatformToPal(int platformErrno); + internal static partial Error ConvertErrorPlatformToPal(int platformErrno); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ConvertErrorPalToPlatform")] [SuppressGCTransition] - internal static extern int ConvertErrorPalToPlatform(Error error); + internal static partial int ConvertErrorPalToPlatform(Error error); - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")] - private static extern unsafe byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_StrErrorR")] + private static unsafe partial byte* StrErrorR(int platformErrno, byte* buffer, int bufferSize); #endif } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEGid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEGid.cs index 87aede1e85ec0..6ee390bf8b35e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEGid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEGid.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEGid")] - internal static extern uint GetEGid(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEGid")] + internal static partial uint GetEGid(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs index 1b8aa005b15ff..f11d4efd443e1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEUid.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEUid")] - internal static extern uint GetEUid(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEUid")] + internal static partial uint GetEUid(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroups.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroups.cs index 2fd31563f1745..0754fabbe6d98 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroups.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetGroups.cs @@ -44,7 +44,7 @@ internal static partial class Sys while (true); } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroups", SetLastError = true)] - private static extern unsafe int GetGroups(int ngroups, uint* groups); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetGroups", SetLastError = true)] + private static unsafe partial int GetGroups(int ngroups, uint* groups); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSid.cs index 6137740fc0f1f..5b20a8660a647 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSid.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSid")] - internal static extern int GetSid(int pid); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetSid")] + internal static partial int GetSid(int pid); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUid.cs index 0d1bec671eaf9..e82897460d9d8 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUid.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUid")] - internal static extern uint GetUid(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUid")] + internal static partial uint GetUid(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RegisterForSigChld.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RegisterForSigChld.cs index e11fcfaf0e65c..2bbac8ac39255 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RegisterForSigChld.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.RegisterForSigChld.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RegisterForSigChld")] - internal static extern unsafe void RegisterForSigChld(delegate* unmanaged handler); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_RegisterForSigChld")] + internal static unsafe partial void RegisterForSigChld(delegate* unmanaged handler); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetDelayedSigChildConsoleConfigurationHandler.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetDelayedSigChildConsoleConfigurationHandler.cs index bd09aa12abc00..f9c6b2be289ac 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetDelayedSigChildConsoleConfigurationHandler.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SetDelayedSigChildConsoleConfigurationHandler.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetDelayedSigChildConsoleConfigurationHandler")] + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetDelayedSigChildConsoleConfigurationHandler")] [SuppressGCTransition] - internal static extern unsafe void SetDelayedSigChildConsoleConfigurationHandler(delegate* unmanaged callback); + internal static unsafe partial void SetDelayedSigChildConsoleConfigurationHandler(delegate* unmanaged callback); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs index b0c64b5c80b4d..773f7ddb90110 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfoEx.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "GetCPInfoExW")] - private static extern unsafe Interop.BOOL GetCPInfoExW(uint CodePage, uint dwFlags, CPINFOEXW* lpCPInfoEx); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetCPInfoExW", CharSet = CharSet.Unicode)] + private static unsafe partial Interop.BOOL GetCPInfoExW(uint CodePage, uint dwFlags, CPINFOEXW* lpCPInfoEx); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] private unsafe struct CPINFOEXW diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleCP.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleCP.cs index e76c06990b4b9..33e73f8042b77 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleCP.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleCP.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - internal static extern uint GetConsoleCP(); + [GeneratedDllImport(Libraries.Kernel32)] + internal static partial uint GetConsoleCP(); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleOutputCP.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleOutputCP.cs index fd59f4dddf1ca..3d8c546dce5c1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleOutputCP.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetConsoleOutputCP.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - internal static extern uint GetConsoleOutputCP(); + [GeneratedDllImport(Libraries.Kernel32)] + internal static partial uint GetConsoleOutputCP(); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetStdHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetStdHandle.cs index b317b13e5499a..501c25f54e4d7 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetStdHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetStdHandle.cs @@ -8,10 +8,10 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] + [GeneratedDllImport(Libraries.Kernel32)] #if !NO_SUPPRESS_GC_TRANSITION [SuppressGCTransition] #endif - internal static extern IntPtr GetStdHandle(int nStdHandle); // param is NOT a handle, but it returns one! + internal static partial IntPtr GetStdHandle(int nStdHandle); // param is NOT a handle, but it returns one! } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MultiByteToWideChar.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MultiByteToWideChar.cs index 2cd6f2b58d910..dfb7a73c52131 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MultiByteToWideChar.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MultiByteToWideChar.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - internal static extern unsafe int MultiByteToWideChar( + [GeneratedDllImport(Libraries.Kernel32)] + internal static unsafe partial int MultiByteToWideChar( uint CodePage, uint dwFlags, byte* lpMultiByteStr, int cbMultiByte, char* lpWideCharStr, int cchWideChar); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerLanguageName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerLanguageName.cs index 6c665a47e4955..af062f0a4f2d0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerLanguageName.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerLanguageName.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "VerLanguageNameW")] - internal static extern unsafe int VerLanguageName(uint wLang, char* szLang, uint cchLang); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "VerLanguageNameW")] + internal static unsafe partial int VerLanguageName(uint wLang, char* szLang, uint cchLang); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WideCharToMultiByte.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WideCharToMultiByte.cs index ce255b45a1fcc..ad2d77e538c92 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WideCharToMultiByte.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WideCharToMultiByte.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - internal static extern unsafe int WideCharToMultiByte( + [GeneratedDllImport(Libraries.Kernel32)] + internal static unsafe partial int WideCharToMultiByte( uint CodePage, uint dwFlags, char* lpWideCharStr, int cchWideChar, byte* lpMultiByteStr, int cbMultiByte, diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs index 3c556031418b7..6e6ef56975dbf 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs @@ -7,8 +7,8 @@ internal static partial class Interop { internal static partial class NtDll { - [DllImport(Libraries.NtDll, ExactSpelling = true)] - internal static extern unsafe uint NtQuerySystemInformation(int SystemInformationClass, void* SystemInformation, uint SystemInformationLength, uint* ReturnLength); + [GeneratedDllImport(Libraries.NtDll, ExactSpelling = true)] + internal static unsafe partial uint NtQuerySystemInformation(int SystemInformationClass, void* SystemInformation, uint SystemInformationLength, uint* ReturnLength); internal const uint STATUS_INFO_LENGTH_MISMATCH = 0xC0000004; } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs index eff18b1b9d409..c5008429fac73 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.EnumWindows.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32)] - public static extern unsafe Interop.BOOL EnumWindows(delegate* unmanaged callback, IntPtr extraData); + [GeneratedDllImport(Libraries.User32)] + public static unsafe partial Interop.BOOL EnumWindows(delegate* unmanaged callback, IntPtr extraData); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetKeyState.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetKeyState.cs index bff237b379ef6..9ee51a05404fc 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetKeyState.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetKeyState.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32)] - internal static extern short GetKeyState(int virtualKeyCode); + [GeneratedDllImport(Libraries.User32)] + internal static partial short GetKeyState(int virtualKeyCode); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindow.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindow.cs index 1ece26d7fdd6a..3091b5c58e5af 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindow.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindow.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32)] - public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd); + [GeneratedDllImport(Libraries.User32)] + public static partial IntPtr GetWindow(IntPtr hWnd, int uCmd); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowLong.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowLong.cs index 1a0310987f990..9cc34ee12fbcb 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowLong.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowLong.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, EntryPoint = "GetWindowLongW")] - public static extern int GetWindowLong(IntPtr hWnd, int uCmd); + [GeneratedDllImport(Libraries.User32, EntryPoint = "GetWindowLongW")] + public static partial int GetWindowLong(IntPtr hWnd, int uCmd); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs index 3b145fea4cc29..daee2bf32eb17 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetWindowThreadProcessId.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static unsafe extern int GetWindowThreadProcessId(IntPtr handle, int* processId); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static unsafe partial int GetWindowThreadProcessId(IntPtr handle, int* processId); [DllImport(Libraries.User32, ExactSpelling = true)] public static extern int GetWindowThreadProcessId(HandleRef handle, out int processId); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs index 15a829a9cf557..c09bfb716fada 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindowVisible.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32)] - public static extern BOOL IsWindowVisible(IntPtr hWnd); + [GeneratedDllImport(Libraries.User32)] + public static partial BOOL IsWindowVisible(IntPtr hWnd); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs index eeec1ba0b518f..962ccd2e2be1b 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.PostMessage.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern int PostMessageW(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial int PostMessageW(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam); [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern int PostMessageW(HandleRef hwnd, int msg, IntPtr wparam, IntPtr lparam); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs index c84dfdab7378c..d3ebb4a04a4d9 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessageTimeout.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, EntryPoint = "SendMessageTimeoutW")] - public static unsafe extern IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, int flags, int timeout, IntPtr* pdwResult); + [GeneratedDllImport(Libraries.User32, EntryPoint = "SendMessageTimeoutW")] + public static unsafe partial IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, int flags, int timeout, IntPtr* pdwResult); } } diff --git a/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj b/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj index ad027e8be2547..9b99ef0ab8124 100644 --- a/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj +++ b/src/libraries/System.Diagnostics.FileVersionInfo/tests/System.Diagnostics.FileVersionInfo.Tests/System.Diagnostics.FileVersionInfo.Tests.csproj @@ -3,6 +3,7 @@ $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser true true + true @@ -41,4 +42,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj b/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj index 061c30752e435..8cb7e64b98ed3 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj +++ b/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj @@ -81,6 +81,7 @@ System.Text.CodePagesEncodingProvider + From a42a872a263774abdea18bcddcff3308913b60e1 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 12 Nov 2021 13:29:59 -0800 Subject: [PATCH 2/4] System.Runtime.InteropServices.RuntimeInformation --- .../Interop/Unix/System.Native/Interop.GetOSArchitecture.cs | 4 ++-- .../Unix/System.Native/Interop.GetProcessArchitecture.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs | 4 ++-- .../src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetOSArchitecture.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetOSArchitecture.cs index de7b9cd37ad2b..50bf35c2d2cd7 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetOSArchitecture.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetOSArchitecture.cs @@ -9,7 +9,7 @@ internal static partial class Interop internal static partial class Sys { [SuppressGCTransition] - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetOSArchitecture")] - internal static extern int GetOSArchitecture(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetOSArchitecture")] + internal static partial int GetOSArchitecture(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs index 2dbb0b1eed13a..2086b4a015a11 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessArchitecture.cs @@ -9,7 +9,7 @@ internal static partial class Interop internal static partial class Sys { [SuppressGCTransition] - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessArchitecture")] - internal static extern int GetProcessArchitecture(); + [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessArchitecture")] + internal static partial int GetProcessArchitecture(); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs index 2322bdd4d7b14..076079e0bb393 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetNativeSystemInfo.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - internal static unsafe extern void GetNativeSystemInfo(SYSTEM_INFO* lpSystemInfo); + [GeneratedDllImport(Libraries.Kernel32)] + internal static unsafe partial void GetNativeSystemInfo(SYSTEM_INFO* lpSystemInfo); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs index f3872f106180e..383a26f280d43 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemInfo.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32)] - internal static unsafe extern void GetSystemInfo(SYSTEM_INFO* lpSystemInfo); + [GeneratedDllImport(Libraries.Kernel32)] + internal static unsafe partial void GetSystemInfo(SYSTEM_INFO* lpSystemInfo); } } From 4540a1a5d76a99a93794ebbc0ee02f164dbfb1ce Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 12 Nov 2021 14:26:17 -0800 Subject: [PATCH 3/4] Fix System.Net.Primitives.UnitTests.Tests --- .../UnitTests/System.Net.Primitives.UnitTests.Tests.csproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj b/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj index 077938e6ceb34..4e77239fae905 100644 --- a/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj +++ b/src/libraries/System.Net.Primitives/tests/UnitTests/System.Net.Primitives.UnitTests.Tests.csproj @@ -4,9 +4,10 @@ 169,649 ../../src/Resources/Strings.resx $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser + true - $(DefineConstants);SYSTEM_NET_PRIMITIVES_DLL @@ -106,4 +107,4 @@ - \ No newline at end of file + From 5cc51a87a35f423866530d62767e4e46436ae089 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Fri, 12 Nov 2021 16:03:30 -0800 Subject: [PATCH 4/4] Fix System.Text.Encoding.CodePages --- eng/generators.targets | 4 +++- .../src/System.Text.Encoding.CodePages.csproj | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/generators.targets b/eng/generators.targets index bcedd85243ed3..aec6e667a6efd 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -22,7 +22,9 @@ and ( ('@(Reference)' != '' and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.InteropServices')) - and @(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe')) + and (@(Reference->AnyHaveMetadataValue('Identity', 'System.Runtime.CompilerServices.Unsafe')) + or ('@(ProjectReference)' != '' + and @(ProjectReference->AnyHaveMetadataValue('Identity', $([MSBuild]::NormalizePath('$(LibrariesProjectRoot)', 'System.Runtime.CompilerServices.Unsafe', 'src', 'System.Runtime.CompilerServices.Unsafe.ilproj')))))) and @(Reference->AnyHaveMetadataValue('Identity', 'System.Memory'))) or ('@(ProjectReference)' != '' and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))))" /> diff --git a/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj b/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj index 8cb7e64b98ed3..061c30752e435 100644 --- a/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj +++ b/src/libraries/System.Text.Encoding.CodePages/src/System.Text.Encoding.CodePages.csproj @@ -81,7 +81,6 @@ System.Text.CodePagesEncodingProvider -