When defining a Visual Studio COM interface in C#, which class / method / parameter attributes should I use?
See the question and my original answer on StackOverflowIt's just that JustDecompile does a bad job here. Other tools such as DotPeek, DnSpy and Reflector (commercial) all seem to work fine. Visual Studio F12 is only useful because it's integrated, but useless for interop.
Another option is to use the C/C++/H/IDL files when they are available. The IDL is available here <programfiles>Microsoft Visual Studio\2017\<sku>\VSSDK\VisualStudioIntegration\Common\IDL\vsshell150.idl
and the resulting .h header file here <programfiles>Microsoft Visual Studio\2017\<sku>\VSSDK\VisualStudioIntegration\Common\inc\vsshell150.h
They are the law. When in doubt, refer to one of them (I prefer the .h, the lowest binary level).
This is how IVsSolutionEvents7
is defined in the .h file:
MIDL_INTERFACE("A459C228-5617-4136-BCBE-C282DF6D9A62")
IVsSolutionEvents7 : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE OnAfterOpenFolder(
/* [in] */ __RPC__in LPCOLESTR folderPath) = 0;
virtual HRESULT STDMETHODCALLTYPE OnBeforeCloseFolder(
/* [in] */ __RPC__in LPCOLESTR folderPath) = 0;
virtual HRESULT STDMETHODCALLTYPE OnQueryCloseFolder(
/* [in] */ __RPC__in LPCOLESTR folderPath,
/* [out][in] */ __RPC__inout BOOL *pfCancel) = 0;
virtual HRESULT STDMETHODCALLTYPE OnAfterCloseFolder(
/* [in] */ __RPC__in LPCOLESTR folderPath) = 0;
virtual HRESULT STDMETHODCALLTYPE OnAfterLoadAllDeferredProjects( void) = 0;
};