Skip to content

Commit 8817f40

Browse files
committed
Update
1 parent 3f053cb commit 8817f40

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Generate-FunctionCommand.ps1

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15-
param(
15+
param
16+
(
1617
# VirtualMachine, VirtualMachineScaleSet, etc.
1718
[Parameter(Mandatory = $true)]
1819
[string]$OperationName,
@@ -27,7 +28,7 @@ param(
2728
[string]$FileOutputFolder,
2829

2930
[Parameter(Mandatory = $false)]
30-
[System.Reflection.MethodInfo]$FriendMethodInfo
31+
[System.Reflection.MethodInfo]$FriendMethodInfo = $null
3132
)
3233

3334
. "$PSScriptRoot\Import-StringFunction.ps1";
@@ -37,22 +38,27 @@ param(
3738
# Sample: VirtualMachineGetMethod.cs
3839
function Generate-PsFunctionCommandImpl
3940
{
40-
param(
41+
param
42+
(
4143
[Parameter(Mandatory = $true)]
4244
[string]$opShortName,
4345

4446
[Parameter(Mandatory = $true)]
4547
[System.Reflection.MethodInfo]$operation_method_info,
4648

4749
[Parameter(Mandatory = $true)]
48-
[string]$fileOutputFolder
50+
[string]$fileOutputFolder,
51+
52+
[Parameter(Mandatory = $false)]
53+
[System.Reflection.MethodInfo]$FriendMethodInfo = $null
4954
)
5055

5156
$componentName = Get-ComponentName $ModelClassNameSpace;
5257
$invoke_cmdlet_class_name = 'InvokeAzure' + $componentName + 'MethodCmdlet';
5358
$parameter_cmdlet_class_name = 'NewAzure' + $componentName + 'ArgumentListCmdlet';
5459

5560
$methodName = ($operation_method_info.Name.Replace('Async', ''));
61+
5662
$return_type_info = $operation_method_info.ReturnType;
5763
$normalized_output_type_name = Get-NormalizedTypeName $return_type_info;
5864
$cmdlet_verb = "Invoke";
@@ -73,6 +79,13 @@ function Generate-PsFunctionCommandImpl
7379

7480
$invoke_param_set_name = $cmdlet_op_short_name + $methodName;
7581

82+
# Process Friend Parameter Set and Method Names
83+
if ($FriendMethodInfo -ne $null -and $FriendMethodInfo.Name -ne $null)
84+
{
85+
$friendMethodName = ($FriendMethodInfo.Name.Replace('Async', ''));
86+
$friend_param_set_name = $cmdlet_op_short_name + $friendMethodName;
87+
}
88+
7689
$file_full_path = $fileOutputFolder + '/' + $cmdlet_class_name + '.cs';
7790
if (Test-Path $file_full_path)
7891
{
@@ -547,7 +560,8 @@ ${cmdlet_partial_class_code}
547560
# azure vm get
548561
function Generate-CliFunctionCommandImpl
549562
{
550-
param(
563+
param
564+
(
551565
# VirtualMachine, VirtualMachineScaleSet, etc.
552566
[Parameter(Mandatory = $true)]
553567
[string]$OperationName,
@@ -948,7 +962,7 @@ function Generate-CliFunctionCommandImpl
948962
return $code;
949963
}
950964

951-
Generate-PsFunctionCommandImpl $OperationName $MethodInfo $FileOutputFolder;
965+
Generate-PsFunctionCommandImpl $OperationName $MethodInfo $FileOutputFolder $FriendMethodInfo;
952966

953967
# CLI Function Command Code
954968
Generate-CliFunctionCommandImpl $OperationName $MethodInfo $ModelClassNameSpace $FileOutputFolder;

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/RunCodeGeneration.ps1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ else
11721172

11731173
$qualified_methods = @();
11741174
$total_method_count = 0;
1175-
$friendMethodDict = @{};
1175+
[System.Collections.Hashtable]$friendMethodDict = @{};
11761176
foreach ($mtItem in $methods)
11771177
{
11781178
[System.Reflection.MethodInfo]$methodInfo = $mtItem;
@@ -1215,11 +1215,24 @@ else
12151215
{
12161216
[System.Reflection.MethodInfo]$methodInfo = $mtItem;
12171217
$method_count++;
1218+
1219+
# Get Friend Method (if any)
1220+
$friendMethodInfo = $null;
1221+
if ($friendMethodDict.ContainsKey($methodInfo.Name))
1222+
{
1223+
$friendMethodInfo = $friendMethodDict[$methodInfo.Name];
1224+
}
1225+
1226+
$friendMethodMessage = '';
1227+
if ($friendMethodInfo -ne $null -and $friendMethodInfo.Name -ne $null)
1228+
{
1229+
$friendMethodMessage = '(Friend: ' + ($friendMethodInfo.Name.Replace('Async', '')) + ')';
1230+
}
12181231

12191232
# Output Info for Method Signature
12201233
Write-Verbose "";
12211234
Write-Verbose $SEC_LINE;
1222-
Write-Verbose ("[${operation_type_count}] ${method_count}/${total_method_count} " + $methodInfo.Name.Replace('Async', ''));
1235+
Write-Verbose ("[${operation_type_count}] ${method_count}/${total_method_count} " + $methodInfo.Name.Replace('Async', '') + ' ' + $friendMethodMessage);
12231236
foreach ($paramInfoItem in $methodInfo.GetParameters())
12241237
{
12251238
[System.Reflection.ParameterInfo]$paramInfo = $paramInfoItem;
@@ -1236,7 +1249,6 @@ else
12361249
}
12371250
Write-Verbose $SEC_LINE;
12381251

1239-
$friendMethodInfo = $friendMethodDict[$methodInfo.Name];
12401252
$outputs = (. $PSScriptRoot\Generate-FunctionCommand.ps1 -OperationName $opShortName `
12411253
-MethodInfo $methodInfo `
12421254
-ModelClassNameSpace $client_model_namespace `

0 commit comments

Comments
 (0)