-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SafeHandle overload should be generated for functions with out
parameters
#1183
Comments
out
parameters
Shouldn't every method that includes |
Probably. But I'm not sure I understand the question. Already our SafeHandle overloads return derived types and accept the base type. The |
One method coming from the top of my head that does not contain unsafe void GetBuffer(byte** ppData, out uint pNumFramesToRead, out uint pdwFlags, [Optional] ulong* pu64DevicePosition, [Optional] ulong* pu64QPCPosition); and its extension method: internal static unsafe void GetBuffer(this winmdroot.Media.Audio.IAudioCaptureClient @this, out byte* ppData, out uint pNumFramesToRead, out uint pdwFlags, ulong* pu64DevicePosition, ulong* pu64QPCPosition)
{
fixed (byte** ppDataLocal = &ppData)
{
@this.GetBuffer(ppDataLocal, out pNumFramesToRead, out pdwFlags, pu64DevicePosition, pu64QPCPosition);
}
} Couldn't the extension method be like this instead? ( internal static void GetBuffer(this winmdroot.Media.Audio.IAudioCaptureClient @this, out SafeHandle ppData, out uint pNumFramesToRead, out uint pdwFlags, in ulong pu64DevicePosition, in ulong pu64QPCPosition) |
No. I'm afraid we can't turn I also don't understand why you would define the last two parameters as |
I understand. Although it is unfortunate not being able to have
Oops! My bad. I wrote that comment late at evening before going to sleep haha. |
What I don't see here is an actual
SafeHandle
-derived type being emitted by CsWin32 even when the allocatingInitializeProcThreadAttributeList
function is generated. This is unexpected, and is probably due toInitializeProcThreadAttributeList
using an output parameter to provide the handle to its caller instead of its return value. CsWin32 may not be prepared to trigger its SafeHandle overload and type for allocating functions except by return value.Originally posted by @AArnott in #1180 (comment)
From the metadata:
That should be enough to produce an overload like this:
Now, I also see that the
out
parameter is optional, yet C# doesn't allow for optional out parameters, and the friendly overload couldn't tell whether the caller usedout _
, so that may also complicate fixing this.The text was updated successfully, but these errors were encountered: