Skip to content

Commit efe7aff

Browse files
committed
Fix Recursive Function
1 parent d9684fe commit efe7aff

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Create-ParameterObject.ps1

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,32 @@ function Create-ParameterObjectImpl
4343

4444
if ($typeInfo.FullName -like "Microsoft.*Azure.Management.*.*" -and (-not ($typeInfo.FullName -like "Microsoft.*Azure.Management.*.SubResource")))
4545
{
46-
$typeList.Add($typeInfo.FullName, $typeInfo);
46+
$st = $typeList.Add($typeInfo.FullName, $typeInfo);
4747
}
4848

4949
if ($typeInfo.FullName -eq 'System.String' -or $typeInfo.FullName -eq 'string')
5050
{
51-
return '';
51+
$obj = '';
5252
}
53-
if ($typeInfo.FullName -eq 'System.Uri')
53+
elseif ($typeInfo.FullName -eq 'System.Uri')
5454
{
55-
return '' -as 'System.Uri';
55+
$obj = '' -as 'System.Uri';
5656
}
5757
elseif ($typeInfo.FullName -eq 'System.Boolean')
5858
{
59-
return $false;
59+
$obj = $false;
6060
}
6161
elseif ($typeInfo.FullName -eq 'System.Int32')
6262
{
63-
return 0;
63+
$obj = 0;
6464
}
6565
elseif ($typeInfo.FullName -eq 'System.UInt32')
6666
{
67-
return 0;
67+
$obj = 0;
6868
}
6969
elseif ($typeInfo.FullName -eq 'System.Byte[]')
7070
{
71-
return New-Object -TypeName System.Byte[] -ArgumentList 0;
71+
$obj = New-Object -TypeName System.Byte[] -ArgumentList 0;
7272
}
7373
elseif ($typeInfo.FullName -like 'System.Collections.Generic.IList*' -or $typeInfo.FullName -like 'System.Collections.Generic.List*')
7474
{
@@ -79,16 +79,16 @@ function Create-ParameterObjectImpl
7979
$listObj = New-Object -TypeName $typeName;
8080
$listObj.Add($itemObj);
8181

82-
return $listObj;
82+
$obj = $listObj;
8383
}
8484
elseif ($typeInfo.FullName -like 'System.Collections.Generic.IDictionary*')
8585
{
8686
# Dictionary in client library always consists of string key & values.
87-
return New-Object 'System.Collections.Generic.Dictionary[string,string]';
87+
$obj = New-Object 'System.Collections.Generic.Dictionary[string,string]';
8888
}
8989
elseif ($typeInfo.FullName -like 'System.Nullable*')
9090
{
91-
return $null;
91+
$obj = $null;
9292
}
9393
else
9494
{
@@ -110,18 +110,20 @@ function Create-ParameterObjectImpl
110110
$listTypeName = "System.Collections.Generic.List[" + $itemType.FullName + "]";
111111

112112
$propObjList = New-Object -TypeName $listTypeName;
113-
$propObjList.Add($itemObj);
113+
$st = $propObjList.Add($itemObj);
114114

115-
$prop.SetValue($obj, $propObjList -as $listTypeName);
115+
$st = $prop.SetValue($obj, $propObjList -as $listTypeName);
116116
}
117117
else
118118
{
119119
$propObj = Create-ParameterObjectImpl $prop.PropertyType $typeList;
120-
$prop.SetValue($obj, $propObj);
120+
$st = $prop.SetValue($obj, $propObj);
121121
}
122122
}
123123
}
124124

125+
$st = $typeList.Remove($typeInfo.FullName);
126+
125127
return $obj;
126128
}
127129

0 commit comments

Comments
 (0)