From dc9276297782c434927514b3d2a2568fff547740 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 15 Nov 2021 10:41:08 -0700 Subject: [PATCH] Use GeneratedDllImport in Microsoft.Win32.SystemEvents --- .../Windows/Kernel32/Interop.GetCurrentThreadId.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.GetModuleHandle.cs | 4 ++-- .../Interop/Windows/Kernel32/Interop.GetProcAddress.cs | 8 ++++---- .../Kernel32/Interop.SetConsoleCtrlHandler.Delegate.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.CreateWindowEx.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.DefWindowProc.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.DestroyWindow.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.DispatchMessage.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.FindWindow.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.GetClassInfo.cs | 4 ++-- .../Windows/User32/Interop.GetProcessWindowStation.cs | 4 ++-- .../Windows/User32/Interop.GetUserObjectInformation.cs | 4 ++-- .../Common/src/Interop/Windows/User32/Interop.IsWindow.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.KillTimer.cs | 4 ++-- .../Windows/User32/Interop.MsgWaitForMultipleObjectsEx.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.PeekMessage.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.RegisterClass.cs | 4 ++-- .../Windows/User32/Interop.RegisterWindowMessage.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.SendMessage.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.SetClassLong.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.SetClassLongPtr.cs | 4 ++-- .../Common/src/Interop/Windows/User32/Interop.SetTimer.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.SetWindowLong.cs | 4 ++-- .../Interop/Windows/User32/Interop.SetWindowLongPtr.cs | 4 ++-- .../Interop/Windows/User32/Interop.TranslateMessage.cs | 4 ++-- .../src/Interop/Windows/User32/Interop.UnregisterClass.cs | 4 ++-- .../tests/Microsoft.Win32.SystemEvents.Tests.csproj | 2 ++ 27 files changed, 56 insertions(+), 54 deletions(-) diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThreadId.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThreadId.cs index e7a0ce9678a779..651ee4a730ca0f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThreadId.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThreadId.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, ExactSpelling = true)] + [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)] [SuppressGCTransition] - public static extern int GetCurrentThreadId(); + public static partial int GetCurrentThreadId(); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs index 99f35d7b3c547a..ad1bbb9b966b18 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleHandle.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, EntryPoint = "GetModuleHandleW", CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr GetModuleHandle(string? moduleName); + [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetModuleHandleW", CharSet = CharSet.Unicode, SetLastError = true)] + internal static partial IntPtr GetModuleHandle(string? moduleName); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs index 214050545ed15b..cce63bf6bee479 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcAddress.cs @@ -10,10 +10,10 @@ internal static partial class Interop { internal static partial class Kernel32 { - [DllImport(Libraries.Kernel32, CharSet = CharSet.Ansi, BestFitMapping = false)] - public static extern IntPtr GetProcAddress(SafeLibraryHandle hModule, string lpProcName); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Ansi)] + public static partial IntPtr GetProcAddress(SafeLibraryHandle hModule, string lpProcName); - [DllImport(Libraries.Kernel32, CharSet = CharSet.Ansi, BestFitMapping = false)] - public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); + [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Ansi)] + public static partial IntPtr GetProcAddress(IntPtr hModule, string lpProcName); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.Delegate.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.Delegate.cs index 159c26438c2809..64f516a7f7d049 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.Delegate.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetConsoleCtrlHandler.Delegate.cs @@ -11,7 +11,7 @@ internal static partial class Kernel32 { internal delegate bool ConsoleCtrlHandlerRoutine(int controlType); - [DllImport(Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine handler, bool addOrRemove); + [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)] + internal static partial bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine handler, bool addOrRemove); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs index e68dfd52f5df3a..98897d8ab7042e 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateWindowEx.cs @@ -8,8 +8,8 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - public static extern IntPtr CreateWindowExW( + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + public static partial IntPtr CreateWindowExW( int exStyle, string lpszClassName, string lpszWindowName, diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs index 6b654003533c52..16470a45f104cb 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DefWindowProc.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern IntPtr DefWindowProcW(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr DefWindowProcW(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyWindow.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyWindow.cs index c1f6b0f1fbbb53..e54676b56c4e24 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyWindow.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyWindow.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern bool DestroyWindow(IntPtr hWnd); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static partial bool DestroyWindow(IntPtr hWnd); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs index 0ebea0ef105983..4b3ed61586ed2b 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DispatchMessage.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern int DispatchMessageW([In] ref MSG msg); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial int DispatchMessageW(ref MSG msg); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs index 550fc1fdc0afa8..e41de1e359c795 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.FindWindow.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet=CharSet.Auto, ExactSpelling = true)] - public static extern IntPtr FindWindowW(string lpClassName, string lpWindowName); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr FindWindowW(string lpClassName, string lpWindowName); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs index 17804dc70f9f2f..680100ddffedd1 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetClassInfo.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern bool GetClassInfoW(IntPtr hInst, string lpszClass, ref WNDCLASS wc); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial bool GetClassInfoW(IntPtr hInst, string lpszClass, ref WNDCLASS wc); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs index d624e2850a5dab..fe83921de3459a 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetProcessWindowStation.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - internal static extern IntPtr GetProcessWindowStation(); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + internal static partial IntPtr GetProcessWindowStation(); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs index 14d09b968e7091..ad1e903f206262 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetUserObjectInformation.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern unsafe bool GetUserObjectInformationW(IntPtr hObj, int nIndex, void* pvBuffer, uint nLength, ref uint lpnLengthNeeded); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + public static unsafe partial bool GetUserObjectInformationW(IntPtr hObj, int nIndex, void* pvBuffer, uint nLength, ref uint lpnLengthNeeded); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindow.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindow.cs index 12e380cc7dcddc..6a179ac1e32454 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindow.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.IsWindow.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern bool IsWindow(IntPtr hWnd); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static partial bool IsWindow(IntPtr hWnd); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.KillTimer.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.KillTimer.cs index 2de52e0f347383..71fb4d29318cc8 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.KillTimer.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.KillTimer.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern bool KillTimer(IntPtr hwnd, IntPtr idEvent); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static partial bool KillTimer(IntPtr hwnd, IntPtr idEvent); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.MsgWaitForMultipleObjectsEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.MsgWaitForMultipleObjectsEx.cs index 0b47d2be7659f2..8f1bf5dc52f561 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.MsgWaitForMultipleObjectsEx.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.MsgWaitForMultipleObjectsEx.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern int MsgWaitForMultipleObjectsEx(int nCount, IntPtr pHandles, int dwMilliseconds, int dwWakeMask, int dwFlags); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static partial int MsgWaitForMultipleObjectsEx(int nCount, IntPtr pHandles, int dwMilliseconds, int dwWakeMask, int dwFlags); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.PeekMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.PeekMessage.cs index 45710968dba9da..6bcfa1488d6848 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.PeekMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.PeekMessage.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern bool PeekMessageW([In, Out] ref MSG msg, IntPtr hwnd, int msgMin, int msgMax, int remove); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial bool PeekMessageW(ref MSG msg, IntPtr hwnd, int msgMin, int msgMax, int remove); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs index 270b0de4000618..7067518c4ce7cb 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterClass.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - public static extern short RegisterClassW(ref WNDCLASS wc); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + public static partial short RegisterClassW(ref WNDCLASS wc); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs index df46561daab79c..978ccf81107856 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.RegisterWindowMessage.cs @@ -7,7 +7,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern int RegisterWindowMessageW(string msg); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial int RegisterWindowMessageW(string msg); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs index aafb7c7e6f0a4a..9fa455f0b57bf1 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SendMessage.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 IntPtr SendMessageW(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr SendMessageW(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern IntPtr SendMessageW(HandleRef hWnd, int msg, IntPtr wParam, IntPtr lParam); diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs index 1278d8bdb95f80..03228c0f503cd0 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLong.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern IntPtr SetClassLongW(IntPtr hwnd, int nIndex, IntPtr dwNewLong); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr SetClassLongW(IntPtr hwnd, int nIndex, IntPtr dwNewLong); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs index 2277ae1f230a4b..5bcd1f36689f30 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetClassLongPtr.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern IntPtr SetClassLongPtrW(IntPtr hwnd, int nIndex, IntPtr dwNewLong); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr SetClassLongPtrW(IntPtr hwnd, int nIndex, IntPtr dwNewLong); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetTimer.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetTimer.cs index 0049286c2cacfd..5c5f1cb5b59bc7 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetTimer.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetTimer.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, int uElapse, IntPtr lpTimerProc); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static partial IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, int uElapse, IntPtr lpTimerProc); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs index 669ff2310a14e8..588270b69dcfc1 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLong.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern IntPtr SetWindowLongW(IntPtr hWnd, int nIndex, IntPtr dwNewLong); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr SetWindowLongW(IntPtr hWnd, int nIndex, IntPtr dwNewLong); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs index e9f915ee89ff52..9bc08ca7571a2e 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.SetWindowLongPtr.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] - public static extern IntPtr SetWindowLongPtrW(IntPtr hWnd, int nIndex, IntPtr dwNewLong); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static partial IntPtr SetWindowLongPtrW(IntPtr hWnd, int nIndex, IntPtr dwNewLong); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.TranslateMessage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.TranslateMessage.cs index fe866df167886b..be2a58ca710713 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.TranslateMessage.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.TranslateMessage.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, ExactSpelling = true)] - public static extern bool TranslateMessage([In, Out] ref MSG msg); + [GeneratedDllImport(Libraries.User32, ExactSpelling = true)] + public static partial bool TranslateMessage(ref MSG msg); } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs index bf321d2a9028f7..06a552c64ab926 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.UnregisterClass.cs @@ -8,7 +8,7 @@ internal static partial class Interop { internal static partial class User32 { - [DllImport(Libraries.User32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - public static extern short UnregisterClassW(string lpClassName, IntPtr hInstance); + [GeneratedDllImport(Libraries.User32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)] + public static partial short UnregisterClassW(string lpClassName, IntPtr hInstance); } } diff --git a/src/libraries/Microsoft.Win32.SystemEvents/tests/Microsoft.Win32.SystemEvents.Tests.csproj b/src/libraries/Microsoft.Win32.SystemEvents/tests/Microsoft.Win32.SystemEvents.Tests.csproj index 9f54ccc27082a5..b74ffd4352b8bf 100644 --- a/src/libraries/Microsoft.Win32.SystemEvents/tests/Microsoft.Win32.SystemEvents.Tests.csproj +++ b/src/libraries/Microsoft.Win32.SystemEvents/tests/Microsoft.Win32.SystemEvents.Tests.csproj @@ -2,6 +2,8 @@ $(NetCoreAppCurrent)-windows;$(NetFrameworkMinimum) true + true + true