It's nicer to be able to dot off returned values than to come up with names for out var parameters for void method calls.
It enables code that looks like this:
FileName = dialog.GetResult().GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEPARSING);
fileTypeIndex = (int)dialog.GetFileTypeIndex();
Instead of:
dialog.GetResult(out var shellItem);
shellItem.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEPARSING, out var displayName);
FileName = new string(displayName);
// TODO: free displayName (my declaration returned `string` from GetDisplayName instead of PWSTR)
dialog.GetFileTypeIndex(out var uintFileTypeIndex);
fileTypeIndex = (int)uintFileTypeIndex;
My own declaration:
/// <summary>
/// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ifileopendialog
/// </summary>
[ComImport, Guid("D57C7288-D4AD-4768-BE02-9D969532D960")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IFileOpenDialog
{
// ...
uint GetFileTypeIndex();
// ...
IShellItem GetResult();
// ...
}
It's nicer to be able to dot off returned values than to come up with names for
out varparameters for void method calls.It enables code that looks like this:
Instead of:
My own declaration: