Display com method signature with argument names (#9858)

This commit is contained in:
nbkalex 2019-06-20 23:22:30 +03:00 committed by Aditya Patwardhan
parent 1d2011fc22
commit 358d12ea93
2 changed files with 15 additions and 2 deletions

View file

@ -36,7 +36,11 @@ namespace System.Management.Automation
internal static string GetMethodSignatureFromFuncDesc(COM.ITypeInfo typeinfo, COM.FUNCDESC funcdesc, bool isPropertyPut)
{
StringBuilder builder = new StringBuilder();
string name = GetNameFromFuncDesc(typeinfo, funcdesc);
// First value is function name
int namesCount = funcdesc.cParams + 1;
string[] names = new string[funcdesc.cParams + 1];
typeinfo.GetNames(funcdesc.memid, names, namesCount, out namesCount);
if (!isPropertyPut)
{
@ -46,7 +50,7 @@ namespace System.Management.Automation
}
// Append the function name
builder.Append(name);
builder.Append(names[0]);
builder.Append(" (");
IntPtr ElementDescriptionArrayPtr = funcdesc.lprgelemdescParam;
@ -85,6 +89,7 @@ namespace System.Management.Automation
else
{
builder.Append(paramstring);
builder.Append(" " + names[i + 1]);
if (i < funcdesc.cParams - 1)
{

View file

@ -48,6 +48,14 @@ try {
[System.Object]::ReferenceEquals($element, $drives) | Should -BeFalse
$element | Should -Be $drives.Item($element.DriveLetter)
}
It "ToString() should return method paramter names" {
$shell = New-Object -ComObject "Shell.Application"
$fullSignature = $shell.AddToRecent.ToString()
$fullSignature | Should -BeExactly "void AddToRecent (Variant varFile, string bstrCategory)"
}
}
Describe 'GetMember/SetMember/InvokeMember binders should have more restricted rule for COM object' -Tags "CI" {