fix(win32): PInvoke cleanup#1569
Conversation
|
@pomianowski We might want to rename UnsafeNativeMethods to PInvokeHelper for example as it's not really native methods. We could also bring the two UnsafeReflection methods into that perhaps. |
| <UseWPF>true</UseWPF> | ||
| <LangVersion>preview</LangVersion> | ||
| <EnableWindowsTargeting>true</EnableWindowsTargeting> | ||
| <PolySharpExcludeGeneratedTypes>System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute;System.Diagnostics.CodeAnalysis.UnscopedRefAttribute</PolySharpExcludeGeneratedTypes> |
There was a problem hiding this comment.
CsWin32 also adds these types, so these need to be excluded.
Hey @Nuklon. Thanks for your help and huge contribution to the WPF UI. |
| internal static partial class PInvoke | ||
| { | ||
| [DllImport("USER32.dll", ExactSpelling = true, EntryPoint = "SetWindowLongPtrW", SetLastError = true), DefaultDllImportSearchPaths(DllImportSearchPath.System32)] | ||
| internal static extern nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong); |
There was a problem hiding this comment.
Shouldn't we be able to use NativeMethods.txt here as well?
There was a problem hiding this comment.
Ideally, yes, but this method isn't generated with AnyCPU builds:
microsoft/CsWin32#528
Glad to help 😊 I think moving some of code inline is fine, but some will be duplicated. I'll give this some thinking first. |
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
To avoid cases such as #1566, use CsWin32 and generate these methods from metadata.
What is the new behavior?
Use CsWin32.
Other information
Should be no functional changes. Some methods I've changed to check the result from. I also removed a couple of methods from UnsafeNativeMethods as they weren't used anymore (and relied on undocumented code).