Skip to content

Commit

Permalink
Use LibraryImport in some Interop User32 (#7172)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetrou authored Jun 8, 2022
1 parent 9ebacf6 commit 86eff93
Show file tree
Hide file tree
Showing 115 changed files with 238 additions and 239 deletions.
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "7.0.100-preview.3.22154.3",
"dotnet": "7.0.100-preview.5.22228.6",
"runtimes": {
"dotnet/x64": [
"$(VSRedistCommonNetCoreSharedFrameworkx6470PackageVersion)"
Expand All @@ -11,7 +11,7 @@
}
},
"sdk": {
"version": "7.0.100-preview.3.22154.3"
"version": "7.0.100-preview.5.22228.6"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22306.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr ActivateKeyboardLayout(IntPtr hkl, uint Flags);
[LibraryImport(Libraries.User32)]
public static partial IntPtr ActivateKeyboardLayout(IntPtr hkl, uint Flags);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true, EntryPoint = "AreDpiAwarenessContextsEqual", SetLastError = true)]
private static extern BOOL AreDpiAwarenessContextsEqualInternal(IntPtr dpiContextA, IntPtr dpiContextB);
[LibraryImport(Libraries.User32, EntryPoint = "AreDpiAwarenessContextsEqual", SetLastError = true)]
private static partial BOOL AreDpiAwarenessContextsEqualInternal(IntPtr dpiContextA, IntPtr dpiContextB);

/// <summary>
/// Tries to compare two DPIawareness context values. Return true if they were equal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL BlockInput(BOOL fBlockIt);
[LibraryImport(Libraries.User32)]
public static partial BOOL BlockInput(BOOL fBlockIt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern nint CallNextHookEx(IntPtr hhook, User32.HC nCode, nint wparam, nint lparam);
[LibraryImport(Libraries.User32)]
public static partial nint CallNextHookEx(IntPtr hhook, User32.HC nCode, nint wparam, nint lparam);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr CallWindowProcW(
[LibraryImport(Libraries.User32)]
public static partial IntPtr CallWindowProcW(
IntPtr wndProc,
IntPtr hWnd,
WM msg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static unsafe extern BOOL ClipCursor(RECT* rcClip);
[LibraryImport(Libraries.User32)]
public static unsafe partial BOOL ClipCursor(RECT* rcClip);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)]
public static extern BOOL CloseDesktop(IntPtr hDesktop);
[LibraryImport(Libraries.User32, SetLastError = true)]
public static partial BOOL CloseDesktop(IntPtr hDesktop);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr CopyImage(IntPtr hImage, IMAGE type, int cx, int cy, LR flags);
[LibraryImport(Libraries.User32)]
public static partial IntPtr CopyImage(IntPtr hImage, IMAGE type, int cx, int cy, LR flags);

public static IntPtr CopyImage(IHandle hImage, IMAGE type, int cx, int cy, LR flags)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public unsafe static extern IntPtr CreateAcceleratorTableW(ACCEL* paccel, int cAccel);
[LibraryImport(Libraries.User32)]
public unsafe static partial IntPtr CreateAcceleratorTableW(ACCEL* paccel, int cAccel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr CreateMenu();
[LibraryImport(Libraries.User32)]
public static partial IntPtr CreateMenu();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr CreatePopupMenu();
[LibraryImport(Libraries.User32)]
public static partial IntPtr CreatePopupMenu();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr DefFrameProcW(IntPtr hWnd, IntPtr hWndClient, WM msg, IntPtr wParam, IntPtr lParam);
[LibraryImport(Libraries.User32)]
public static partial IntPtr DefFrameProcW(IntPtr hWnd, IntPtr hWndClient, WM msg, IntPtr wParam, IntPtr lParam);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr DefMDIChildProcW(IntPtr hWnd, WM msg, IntPtr wParam, IntPtr lParam);
[LibraryImport(Libraries.User32)]
public static partial IntPtr DefMDIChildProcW(IntPtr hWnd, WM msg, IntPtr wParam, IntPtr lParam);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr DefWindowProcW(
[LibraryImport(Libraries.User32)]
public static partial IntPtr DefWindowProcW(
IntPtr hWnd,
WM msg,
IntPtr wParam,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL DestroyAcceleratorTable(IntPtr hAccel);
[LibraryImport(Libraries.User32)]
public static partial BOOL DestroyAcceleratorTable(IntPtr hAccel);

public static BOOL DestroyAcceleratorTable(HandleRef hAccel)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]

public static extern BOOL DestroyCursor(IntPtr hCurs);
[LibraryImport(Libraries.User32)]
public static partial BOOL DestroyCursor(IntPtr hCurs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)]
public extern static BOOL DestroyIcon(IntPtr handle);
[LibraryImport(Libraries.User32, SetLastError = true)]
public static partial BOOL DestroyIcon(IntPtr handle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL DestroyMenu(IntPtr hMenu);
[LibraryImport(Libraries.User32)]
public static partial BOOL DestroyMenu(IntPtr hMenu);

public static BOOL DestroyMenu(HandleRef hMenu)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL DestroyWindow(IntPtr hWnd);
[LibraryImport(Libraries.User32)]
public static partial BOOL DestroyWindow(IntPtr hWnd);

public static BOOL DestroyWindow(IHandle hWnd)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL DrawIcon(IntPtr hDC, int x, int y, IntPtr hIcon);
[LibraryImport(Libraries.User32)]
public static partial BOOL DrawIcon(IntPtr hDC, int x, int y, IntPtr hIcon);

public static BOOL DrawIcon(IntPtr hDC, int x, int y, IHandle hIcon)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL DrawIconEx(
[LibraryImport(Libraries.User32)]
public static partial BOOL DrawIconEx(
Gdi32.HDC hDC,
int xLeft,
int yTop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
private static extern BOOL DrawMenuBar(IntPtr hWnd);
[LibraryImport(Libraries.User32)]
private static partial BOOL DrawMenuBar(IntPtr hWnd);

public static BOOL DrawMenuBar(IHandle hWnd)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL EnableMenuItem(IntPtr hMenu, SC uIDEnableItem, MF uEnable);
[LibraryImport(Libraries.User32)]
public static partial BOOL EnableMenuItem(IntPtr hMenu, SC uIDEnableItem, MF uEnable);

public static BOOL EnableMenuItem(HandleRef hMenu, SC uIDEnableItem, MF uEnable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)]
public static extern BOOL EnableScrollBar(IntPtr hWnd, SB wSBflags, ESB wArrows);
[LibraryImport(Libraries.User32, SetLastError = true)]
public static partial BOOL EnableScrollBar(IntPtr hWnd, SB wSBflags, ESB wArrows);

public static BOOL EnableScrollBar(IHandle hWnd, SB wSBflags, ESB wArrows)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL EnableWindow(IntPtr hWnd, BOOL bEnable);
[LibraryImport(Libraries.User32)]
public static partial BOOL EnableWindow(IntPtr hWnd, BOOL bEnable);

public static BOOL EnableWindow(HandleRef hWnd, BOOL bEnable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern BOOL EndDialog(IntPtr hDlg, IntPtr nResult);
[LibraryImport(Libraries.User32)]
public static partial BOOL EndDialog(IntPtr hDlg, IntPtr nResult);

public static BOOL EndDialog(HandleRef hDlg, IntPtr nResult)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public unsafe static extern BOOL EndPaint(IntPtr hWnd, PAINTSTRUCT* lpPaint);
[LibraryImport(Libraries.User32)]
public unsafe static partial BOOL EndPaint(IntPtr hWnd, PAINTSTRUCT* lpPaint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr GetActiveWindow();
[LibraryImport(Libraries.User32)]
public static partial IntPtr GetActiveWindow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr GetAncestor(IntPtr hwnd, GA flags);
[LibraryImport(Libraries.User32)]
public static partial IntPtr GetAncestor(IntPtr hwnd, GA flags);

public static IntPtr GetAncestor(IHandle hwnd, GA flags)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern short GetAsyncKeyState(int vkey);
[LibraryImport(Libraries.User32)]
public static partial short GetAsyncKeyState(int vkey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr GetCapture();
[LibraryImport(Libraries.User32)]
public static partial IntPtr GetCapture();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern uint GetCaretBlinkTime();
[LibraryImport(Libraries.User32)]
public static partial uint GetCaretBlinkTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
private static unsafe extern int GetClipboardFormatNameW(uint format, char* lpszFormatName, int cchMaxCount);
[LibraryImport(Libraries.User32)]
private static unsafe partial int GetClipboardFormatNameW(uint format, char* lpszFormatName, int cchMaxCount);

public static unsafe string? GetClipboardFormatNameW(uint format)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr GetCursor();
[LibraryImport(Libraries.User32)]
public static partial IntPtr GetCursor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[LibraryImport(Libraries.User32)]
public static partial IntPtr GetDesktopWindow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal static partial class Interop
{
internal static partial class User32
{
[DllImport(Libraries.User32, ExactSpelling = true)]
public static extern IntPtr GetDlgItem(IntPtr hWnd, DialogItemID nIDDlgItem);
[LibraryImport(Libraries.User32)]
public static partial IntPtr GetDlgItem(IntPtr hWnd, DialogItemID nIDDlgItem);

public static IntPtr GetDlgItem(IHandle hWnd, DialogItemID nIDDlgItem)
{
Expand Down
Loading

0 comments on commit 86eff93

Please sign in to comment.