dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

Ole32 project #356

Closed ghost closed 6 years ago

ghost commented 6 years ago

Question: Should CoEnableCallCancellation(IntPtr) and CoDisableCallCancellation(IntPtr) be made private, in favor of exclusively exposing the helper metohds CoEnableCallCancellation(void) and CoDisableCallCancellation(void) respectively ?

ghost commented 6 years ago

Addressed feedback.

The one thing I couldn't do was add =default(IntPtr) or void* = null. When I tried doing this, I got the following CodeAnalysis warning:

Ole32.cs(22,45): warning RS0027: Symbol 'CoEnableCallCancellation' violates the backcompat requirement: 'Public API with optional parameter(s) should have the most parameters amongst its public overloads'. See 'https://github.com/dotnet/roslyn/blob/master/docs/Adding%20Optional%20Parameters%20in%20Public%20API.md' for details. [D:\src\repos\pinvoke\src\Ole32\Ole32.csproj]

I suspect this warning occurs because the code-generator isn't currently transfering over default arguments (i..e, it is not converting void* pReserved = null to System.IntPtr pReserved = IntPtr.Zero), and the resultant generated code simply skips the addition of a default value.

Optional argument/default value would have been nice to have given that the only legal value for these arguments in CoEnableCallCancellation and CoDisableCallCancellatoin is null/IntPtr.Zero. That said, this is really only a minor drawback.