Skip to content

Commit 59ccb74

Browse files
committed
Update
1 parent bad46c8 commit 59ccb74

File tree

5 files changed

+67
-38
lines changed

5 files changed

+67
-38
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
function Load-AssemblyFile
16+
{
17+
param
18+
(
19+
[Parameter(Mandatory = $true)]
20+
[string]$dllPath
21+
)
22+
23+
$assembly = [System.Reflection.Assembly]::LoadFrom($dllPath);
24+
$st = [System.Reflection.Assembly]::LoadWithPartialName("System.Collections.Generic");
25+
return $assembly;
26+
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Common.ps1 renamed to src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Automation/Import-CommonVariables.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,36 @@ $code_common_header =
7272
// Changes to this file may cause incorrect behavior and will be lost if the
7373
// code is regenerated.
7474
"@;
75+
76+
$client_model_namespace = $client_library_namespace + '.Models';
77+
$is_hyak_mode = $client_library_namespace -like "Microsoft.WindowsAzure.*.*";
78+
$component_name = $client_library_namespace.Substring($client_library_namespace.LastIndexOf('.') + 1);
79+
80+
$all_return_type_names = @();
81+
82+
Write-Verbose $BAR_LINE;
83+
Write-Verbose "Input Parameters:";
84+
Write-Verbose "DLL Folder = $dllFolder";
85+
Write-Verbose "Out Folder = $outFolder";
86+
Write-Verbose "Client NameSpace = $client_library_namespace";
87+
Write-Verbose "Model NameSpace = $client_model_namespace";
88+
Write-Verbose "Component Name = $component_name";
89+
Write-Verbose "Base Cmdlet Full Name = $baseCmdletFullName";
90+
Write-Verbose "Base Client Name = $base_class_client_field";
91+
Write-Verbose "Cmdlet Flavor = $cmdletFlavor";
92+
Write-Verbose "Operation Name Filter = $operationNameFilter";
93+
Write-Verbose $BAR_LINE;
94+
Write-Verbose "${new_line_str}";
95+
96+
$code_common_namespace = ($client_library_namespace.Replace('.Management.', '.Commands.')) + '.Automation';
97+
$code_model_namespace = ($client_library_namespace.Replace('.Management.', '.Commands.')) + '.Automation.Models';
98+
99+
function Get-SortedUsingsCode
100+
{
101+
$list_of_usings = @() + $code_common_usings + $client_library_namespace + $client_model_namespace + $code_model_namespace;
102+
$sorted_usings = $list_of_usings | Sort-Object -Unique | foreach { "using ${_};" };
103+
$text = [string]::Join($NEW_LINE, $sorted_usings);
104+
return $text;
105+
}
106+
107+
$code_using_strs = Get-SortedUsingsCode;

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

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,44 +61,11 @@ param(
6161
[string[]]$operationNameFilter = $null
6262
)
6363

64-
. "$PSScriptRoot\Common.ps1";
65-
66-
$client_model_namespace = $client_library_namespace + '.Models';
67-
$is_hyak_mode = $client_library_namespace -like "Microsoft.WindowsAzure.*.*";
68-
$component_name = $client_library_namespace.Substring($client_library_namespace.LastIndexOf('.') + 1);
69-
70-
$all_return_type_names = @();
71-
72-
Write-Verbose $BAR_LINE;
73-
Write-Verbose "Input Parameters:";
74-
Write-Verbose "DLL Folder = $dllFolder";
75-
Write-Verbose "Out Folder = $outFolder";
76-
Write-Verbose "Client NameSpace = $client_library_namespace";
77-
Write-Verbose "Model NameSpace = $client_model_namespace";
78-
Write-Verbose "Component Name = $component_name";
79-
Write-Verbose "Base Cmdlet Full Name = $baseCmdletFullName";
80-
Write-Verbose "Base Client Name = $base_class_client_field";
81-
Write-Verbose "Cmdlet Flavor = $cmdletFlavor";
82-
Write-Verbose "Operation Name Filter = $operationNameFilter";
83-
Write-Verbose $BAR_LINE;
84-
Write-Verbose "${new_line_str}";
85-
86-
$code_common_namespace = ($client_library_namespace.Replace('.Management.', '.Commands.')) + '.Automation';
87-
$code_model_namespace = ($client_library_namespace.Replace('.Management.', '.Commands.')) + '.Automation.Models';
88-
89-
function Get-SortedUsingsCode
90-
{
91-
$list_of_usings = @() + $code_common_usings + $client_library_namespace + $client_model_namespace + $code_model_namespace;
92-
$sorted_usings = $list_of_usings | Sort-Object -Unique | foreach { "using ${_};" };
93-
$text = [string]::Join($NEW_LINE, $sorted_usings);
94-
return $text;
95-
}
96-
97-
$code_using_strs = Get-SortedUsingsCode;
98-
64+
. "$PSScriptRoot\Import-CommonVariables.ps1";
65+
. "$PSScriptRoot\Import-AssemblyFunction.ps1";
9966
. "$PSScriptRoot\Import-StringFunction.ps1";
10067
. "$PSScriptRoot\Import-TypeFunction.ps1";
101-
. "$PSScriptRoot\OperationTypeHelper.ps1";
68+
. "$PSScriptRoot\Import-OperationFunction.ps1";
10269

10370
function Write-PSArgumentFile
10471
{
@@ -1876,8 +1843,7 @@ if (-not (Test-Path -Path $dllFileFullPath))
18761843
}
18771844
else
18781845
{
1879-
$assembly = [System.Reflection.Assembly]::LoadFrom($dllFileFullPath);
1880-
[System.Reflection.Assembly]::LoadWithPartialName("System.Collections.Generic");
1846+
$assembly = Load-AssemblyFile $dllFileFullPath;
18811847

18821848
# All original types
18831849
$types = $assembly.GetTypes();

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Commands.ServiceManagement.Preview.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,16 @@
187187
<Compile Include="ServiceManagementPreviewProfile.cs" />
188188
</ItemGroup>
189189
<ItemGroup>
190+
<None Include="Automation\Import-CommonVariables.ps1" />
190191
<None Include="Automation\Generate-FunctionCommand.ps1" />
192+
<None Include="Automation\Generate-PowershellParameterCmdlet.ps1" />
193+
<None Include="Automation\Import-AssemblyFunction.ps1" />
191194
<None Include="Automation\Import-TypeFunction.ps1" />
192195
<None Include="Automation\Import-StringFunction.ps1" />
193196
<None Include="Automation\Generate-ParameterCommand.ps1" />
194197
<None Include="Automation\Create-ParameterTree.ps1" />
195198
<None Include="Automation\Create-ParameterObject.ps1" />
199+
<None Include="Automation\Import-OperationFunction.ps1" />
196200
<None Include="Automation\RunCodeGeneration.ps1" />
197201
<None Include="Automation\ConvertTo-Json.ps1" />
198202
<None Include="AzurePreview.psd1">

0 commit comments

Comments
 (0)