【发布时间】:2011-10-20 14:25:33
【问题描述】:
我的应用程序中有以下代码:
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hwnd, int index);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
[DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
int x, int y, int width, int height, uint flags);
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hwnd, uint msg,
IntPtr wParam, IntPtr lParam);
我从代码分析 (FxCop) 收到以下警告:
CA1060 : Microsoft.Design : 因为它是一个 P/Invoke 方法, 'IconHelper.GetWindowLong(IntPtr, int)' 应该在一个类中定义 命名为 NativeMethods、SafeNativeMethods 或 UnsafeNativeMethods。
谁能告诉我应该把他们放在哪个班级?不知道是 Native、SafeNative 还是 UnsafeNative。
【问题讨论】:
标签: c# code-analysis fxcop