In my free time I’ve been working on a Resharper Plugin designed for assisting developers with Interop.
Interop can be a bit tricky, and small errors can cause a lot of problems. I wanted to make something that would help me, as well as others with interop and be more productive.
As well as helping with some of the trickier stuff, helping beginners is useful too. So far, the project is capable of:
- Presenting a warning and quickfix for missing DllImportAttribute declarations.
- Presenting a warning and quickfix for extern methods that are not static and have a DllImportAttribute.
- A bulb for automatically inserting the EntryPoint parameter into the DllImportAttribute explicitly.
- Warning when an int32 is used when a native (IntPtr) should be used.
This requires a “library” of sorts to know which parameters should be an IntPtr. This library needs vast expanding, but can be seen working in the screenshot above.
The source code for this plug in is available on GitHub: https://github.com/vcsjones/ResharperInteropHelpers
Currently there is no installer for the extension, something I don’t know a lot about creating (yet) for Resharper Plugins.
While I admit the feature set is a bit lacking at the moment, my roadmap for the extension is to provide as much assistance with marshaling known interop calls, like to CloseHandle.
Building the library of data to do that will require a lot of work, but it’s something that I am familiar with and there is a lot of documentation about it.