Winforms: There are now 3 copies of NativeMethods in winforms

Created on 6 Apr 2019  路  6Comments  路  Source: dotnet/winforms

These should be able to be consolidated. I'll give this a punt when my outstanding PRs are merged

Most helpful comment

Somewhat relevant, @AArnott has a library containing all P/Invoke code so you don't have to import it every time https://github.com/AArnott/pinvoke/
Perhaps instead of hand crafting all imports worth considering using the above library?

All 6 comments

When we work on NativeMethods we should also look at some of the other common files between WinForms Binaries. UnsafeNativeMethods and SafeNativeMethods fall into this scenario. DPIHelper is another one, but not quite as closely related. We should create a new shared dll for these files.

Somewhat relevant, @AArnott has a library containing all P/Invoke code so you don't have to import it every time https://github.com/AArnott/pinvoke/
Perhaps instead of hand crafting all imports worth considering using the above library?

@hughbe are you working on this? You can work with @zsd4yr to see what we've done with our internal designer code. We will work with our compliance team to find out if/how we can incorporate the PInvoke stuff. Let's make this a separate issue.

We did unified the various native methods into a single one and while doing so, we also changed many instances of HandlePtr to HandleRefs. We could start this work by copying the unified copy into this repo and making signature changes in the corresponding function calls. @zsd4yr , do you know a best way to share that file on github ( as those changes were made on private repo) and a sample file where we made signature change in the call ( from IntPtr to Handleref)

@hughbe @dreddy-work here is a _gist_ containing a copy of the NativeMethods from the private repo https://gist.github.com/zsd4yr/cbee82529a8bde0a6cbb11be80f84d7f

This is ongoing cleaning effort. With that it is almost complete.

Was this page helpful?
0 / 5 - 0 ratings