IAudioSessionManager2::GetSessionEnumerator missing parameter
seanyu0 opened this issue · comments
IAudioSessionManager2::GetSessionEnumerator should have a parameter in document. But in generated code:
winmdroot.Media.Audio.IAudioSessionEnumerator GetSessionEnumerator();
And I check the SDK win32metadata, GetSessionEnumerator have a [out] [retval] parameter.
So the parameter is missing.
NativeMethods.txt
content:
IAudioSessionControl
IAudioSessionControl2
IAudioSessionEnumerator
IAudioSessionEvents
IAudioSessionManager
IAudioSessionManager2
IAudioSessionNotification
IAudioVolumeLevel
IAudioVolumeDuckNotification
NativeMethods.json
content:
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"public": true
}
- CsWin32 version: 0.3.49-beta
- Win32Metadata version: 58.0.18-preview
- Target Framework: .NET 7
LangVersion
: 12
This is by design. The method is declared like this in the metadata:
unsafe HRESULT GetSessionEnumerator([Out][RetVal] IAudioSessionEnumerator* SessionEnum);
Note the [retval]
attribute on the out parameter. That's an indicator that a projection may choose to move the out parameter to the return value position. In .NET, this is the default behavior for COM interfaces, and CsWin32 follows the same pattern.
It's not missing an argument. CsWin32 is performing return value transformation here--note how the generated method is returning IAudioSessionEnumerator
.
You can preserve the original signature by modifying NativeMethods.json
(or creating one if it doesn't exist):
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"comInterop": {
"preserveSigMethods": [
"IAudioSessionEnumerator.GetSessionEnumerator"
]
}
}
Drat, @AArnott beat me to it!
@riverar: I'll slow down. I love it when you respond to these issues. :)