Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/System.Management.Automation/engine/COM/ComUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ internal class ComUtil
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)
{
Expand All @@ -46,7 +50,7 @@ internal static string GetMethodSignatureFromFuncDesc(COM.ITypeInfo typeinfo, CO
}

// Append the function name
builder.Append(name);
builder.Append(names[0]);
builder.Append(" (");

IntPtr ElementDescriptionArrayPtr = funcdesc.lprgelemdescParam;
Expand Down Expand Up @@ -85,6 +89,7 @@ internal static string GetMethodSignatureFromFuncDesc(COM.ITypeInfo typeinfo, CO
else
{
builder.Append(paramstring);
builder.Append(" " + names[i + 1]);

if (i < funcdesc.cParams - 1)
{
Expand Down
8 changes: 8 additions & 0 deletions test/powershell/engine/COM/COM.Basic.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down