Skip to content

Commit 367651b

Browse files
wyunchi-msazurepowershell
andauthored
Move BotService to main (#15636)
* Move BotService to main * Update Changelog.md Co-authored-by: azurepowershell <[email protected]> Co-authored-by: wyunchi-ms <[email protected]>
1 parent 615fb74 commit 367651b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+8494
-163
lines changed

src/BotService/Az.BotService.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 2021-03-11
6+
# Generated on: 8/10/2021
77
#
88

99
@{
@@ -110,7 +110,7 @@ PrivateData = @{
110110
# IconUri = ''
111111

112112
# ReleaseNotes of this module
113-
ReleaseNotes = '* Updated the online links.'
113+
# ReleaseNotes = ''
114114

115115
# Prerelease string of this module
116116
# Prerelease = ''

src/BotService/Az.BotService.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
}
3333

3434
if(-not $accountsModule) {
35-
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/en-us/powershell/azure/install-az-ps" -ErrorAction Stop
35+
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. For installation instructions, please see: https://docs.microsoft.com/powershell/azure/install-az-ps" -ErrorAction Stop
3636
} elseif (($accountsModule.Version -lt [System.Version]'2.2.3') -and (-not $localAccounts)) {
37-
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to remove '.PSSharedModules' in your home directory. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
37+
Write-Error "`nThis module requires $accountsName version 2.2.3 or greater. An earlier version of Az.Accounts is imported in the current PowerShell session. If you are running test, please try to add the switch '-RegenerateSupportModule' when executing 'test-module.ps1'. Otherwise please open a new PowerShell session and import this module again.`nAdditionally, this error could indicate that multiple incompatible versions of Azure PowerShell modules are installed on your system. For troubleshooting information, please see: https://aka.ms/azps-version-error" -ErrorAction Stop
3838
}
3939
Write-Information "Loaded Module '$($accountsModule.Name)'"
4040

src/BotService/BotService.sln

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,90 @@
1+
12
Microsoft Visual Studio Solution File, Format Version 12.00
23
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.29709.97
4+
VisualStudioVersion = 16.6.30114.105
45
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accounts", "..\Accounts\Accounts\Accounts.csproj", "{75E060CE-B2DA-4FCD-99B7-D2556C680A97}"
67
EndProject
7-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{62843FE6-7575-4D88-B989-7DF7EEC0BC01}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authentication", "..\Accounts\Authentication\Authentication.csproj", "{515536C5-5785-4A0C-A802-19525A580D4B}"
89
EndProject
9-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{442C609B-A431-4A71-B289-08F0B63C83E5}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authentication.ResourceManager", "..\Accounts\Authentication.ResourceManager\Authentication.ResourceManager.csproj", "{B75C3C64-838A-48CF-8050-680FA319C3C0}"
1011
EndProject
11-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{59E8F6B8-8F0E-403F-B88B-9736DBC396D9}"
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Authenticators", "..\Accounts\Authenticators\Authenticators.csproj", "{2B871AAD-94E7-498A-ABED-0ECC22AC384F}"
1213
EndProject
13-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Az.BotService", "Az.BotService.csproj", "{1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}"
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.BotService", "Az.BotService.csproj", "{632974A6-B006-488B-BBE8-18CD2E8CB8AD}"
1415
EndProject
1516
Global
1617
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1718
Debug|Any CPU = Debug|Any CPU
19+
Debug|x64 = Debug|x64
20+
Debug|x86 = Debug|x86
1821
Release|Any CPU = Release|Any CPU
19-
EndGlobalSection
20-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21-
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22-
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
23-
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
24-
{142D7B0B-388A-4CEB-A228-7F6D423C5C2E}.Release|Any CPU.Build.0 = Release|Any CPU
25-
{62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26-
{62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Debug|Any CPU.Build.0 = Debug|Any CPU
27-
{62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Release|Any CPU.ActiveCfg = Release|Any CPU
28-
{62843FE6-7575-4D88-B989-7DF7EEC0BC01}.Release|Any CPU.Build.0 = Release|Any CPU
29-
{442C609B-A431-4A71-B289-08F0B63C83E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30-
{442C609B-A431-4A71-B289-08F0B63C83E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
31-
{442C609B-A431-4A71-B289-08F0B63C83E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
32-
{442C609B-A431-4A71-B289-08F0B63C83E5}.Release|Any CPU.Build.0 = Release|Any CPU
33-
{59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34-
{59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
35-
{59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
36-
{59E8F6B8-8F0E-403F-B88B-9736DBC396D9}.Release|Any CPU.Build.0 = Release|Any CPU
37-
{1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38-
{1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Debug|Any CPU.Build.0 = Debug|Any CPU
39-
{1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Release|Any CPU.ActiveCfg = Release|Any CPU
40-
{1C203C0C-E0FD-40D2-B79E-C6DA52E4E350}.Release|Any CPU.Build.0 = Release|Any CPU
22+
Release|x64 = Release|x64
23+
Release|x86 = Release|x86
4124
EndGlobalSection
4225
GlobalSection(SolutionProperties) = preSolution
4326
HideSolutionNode = FALSE
4427
EndGlobalSection
45-
GlobalSection(ExtensibilityGlobals) = postSolution
46-
SolutionGuid = {F9B3D96E-9680-40BE-A917-02EE655D6030}
28+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Debug|x64.ActiveCfg = Debug|Any CPU
32+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Debug|x64.Build.0 = Debug|Any CPU
33+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Debug|x86.ActiveCfg = Debug|Any CPU
34+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Debug|x86.Build.0 = Debug|Any CPU
35+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Release|x64.ActiveCfg = Release|Any CPU
38+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Release|x64.Build.0 = Release|Any CPU
39+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Release|x86.ActiveCfg = Release|Any CPU
40+
{75E060CE-B2DA-4FCD-99B7-D2556C680A97}.Release|x86.Build.0 = Release|Any CPU
41+
{515536C5-5785-4A0C-A802-19525A580D4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{515536C5-5785-4A0C-A802-19525A580D4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{515536C5-5785-4A0C-A802-19525A580D4B}.Debug|x64.ActiveCfg = Debug|Any CPU
44+
{515536C5-5785-4A0C-A802-19525A580D4B}.Debug|x64.Build.0 = Debug|Any CPU
45+
{515536C5-5785-4A0C-A802-19525A580D4B}.Debug|x86.ActiveCfg = Debug|Any CPU
46+
{515536C5-5785-4A0C-A802-19525A580D4B}.Debug|x86.Build.0 = Debug|Any CPU
47+
{515536C5-5785-4A0C-A802-19525A580D4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
48+
{515536C5-5785-4A0C-A802-19525A580D4B}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{515536C5-5785-4A0C-A802-19525A580D4B}.Release|x64.ActiveCfg = Release|Any CPU
50+
{515536C5-5785-4A0C-A802-19525A580D4B}.Release|x64.Build.0 = Release|Any CPU
51+
{515536C5-5785-4A0C-A802-19525A580D4B}.Release|x86.ActiveCfg = Release|Any CPU
52+
{515536C5-5785-4A0C-A802-19525A580D4B}.Release|x86.Build.0 = Release|Any CPU
53+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
55+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Debug|x64.ActiveCfg = Debug|Any CPU
56+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Debug|x64.Build.0 = Debug|Any CPU
57+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Debug|x86.ActiveCfg = Debug|Any CPU
58+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Debug|x86.Build.0 = Debug|Any CPU
59+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
60+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Release|Any CPU.Build.0 = Release|Any CPU
61+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Release|x64.ActiveCfg = Release|Any CPU
62+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Release|x64.Build.0 = Release|Any CPU
63+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Release|x86.ActiveCfg = Release|Any CPU
64+
{B75C3C64-838A-48CF-8050-680FA319C3C0}.Release|x86.Build.0 = Release|Any CPU
65+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Debug|Any CPU.Build.0 = Debug|Any CPU
67+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Debug|x64.ActiveCfg = Debug|Any CPU
68+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Debug|x64.Build.0 = Debug|Any CPU
69+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Debug|x86.ActiveCfg = Debug|Any CPU
70+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Debug|x86.Build.0 = Debug|Any CPU
71+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Release|Any CPU.ActiveCfg = Release|Any CPU
72+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Release|Any CPU.Build.0 = Release|Any CPU
73+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Release|x64.ActiveCfg = Release|Any CPU
74+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Release|x64.Build.0 = Release|Any CPU
75+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Release|x86.ActiveCfg = Release|Any CPU
76+
{2B871AAD-94E7-498A-ABED-0ECC22AC384F}.Release|x86.Build.0 = Release|Any CPU
77+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
78+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
79+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Debug|x64.ActiveCfg = Debug|Any CPU
80+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Debug|x64.Build.0 = Debug|Any CPU
81+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Debug|x86.ActiveCfg = Debug|Any CPU
82+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Debug|x86.Build.0 = Debug|Any CPU
83+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
84+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Release|Any CPU.Build.0 = Release|Any CPU
85+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Release|x64.ActiveCfg = Release|Any CPU
86+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Release|x64.Build.0 = Release|Any CPU
87+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Release|x86.ActiveCfg = Release|Any CPU
88+
{632974A6-B006-488B-BBE8-18CD2E8CB8AD}.Release|x86.Build.0 = Release|Any CPU
4789
EndGlobalSection
4890
EndGlobal

src/BotService/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fixed the issue that `New-AzBotService` will fail in WebApp mode. [#15608]
2122

2223
## Version 0.3.0
2324
* Updated the online links.

src/BotService/build-module.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ $moduleName = 'Az.BotService'
120120
$examplesFolder = Join-Path $PSScriptRoot 'examples'
121121
$null = New-Item -ItemType Directory -Force -Path $examplesFolder
122122

123+
Write-Host -ForegroundColor Green 'Creating cmdlets for specified models...'
124+
$modelCmdlets = @()
125+
if ($modelCmdlets.Count -gt 0) {
126+
. (Join-Path $PSScriptRoot 'create-model-cmdlets.ps1')
127+
CreateModelCmdlet($modelCmdlets)
128+
}
129+
123130
if($NoDocs) {
124131
Write-Host -ForegroundColor Green 'Creating exports...'
125132
Export-ProxyCmdlet -ModuleName $moduleName -ModulePath $modulePaths -ExportsFolder $exportsFolder -InternalFolder $internalFolder -ExcludeDocs -ExamplesFolder $examplesFolder

src/BotService/check-dependencies.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $tools = Join-Path $PSScriptRoot 'tools'
5353
$resourceDir = Join-Path $tools 'Resources'
5454
$resourceModule = Join-Path $HOME '.PSSharedModules\Resources\Az.Resources.TestSupport.psm1'
5555

56-
if ($Resources.IsPresent -and (-not (Test-Path -Path $resourceModule))) {
56+
if ($Resources.IsPresent -and ((-not (Test-Path -Path $resourceModule)) -or $RegenerateSupportModule.IsPresent)) {
5757
Write-Host -ForegroundColor Green "Building local Resource module used for test..."
5858
Set-Location $resourceDir
5959
$null = autorest .\readme.md --use:@autorest/powershell@3.0.414 --output-folder=$HOME/.PSSharedModules/Resources
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
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 CreateModelCmdlet {
16+
17+
param([string[]]$Models)
18+
19+
if ($Models.Count -eq 0)
20+
{
21+
return
22+
}
23+
24+
$ModelCsPath = Join-Path (Join-Path $PSScriptRoot 'generated\api') 'Models'
25+
$ModuleName = 'Az.BotService'.Split(".")[1]
26+
$OutputDir = Join-Path $PSScriptRoot 'custom\autogen-model-cmdlets'
27+
$null = New-Item -ItemType Directory -Force -Path $OutputDir
28+
29+
$CsFiles = Get-ChildItem -Path $ModelCsPath -Recurse -Filter *.cs
30+
$Content = ''
31+
$null = $CsFiles | ForEach-Object -Process { if ($_.Name.Split('.').count -eq 2 )
32+
{ $Content += get-content $_.fullname -raw
33+
} }
34+
35+
$Tree = [Microsoft.CodeAnalysis.CSharp.SyntaxFactory]::ParseCompilationUnit($Content)
36+
$Nodes = $Tree.ChildNodes().ChildNodes()
37+
foreach ($Model in $Models)
38+
{
39+
$InterfaceNode = $Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq "I$Model") }
40+
if ($InterfaceNode.count -eq 0) {
41+
continue
42+
}
43+
# through a queue, we iterate all the parent models.
44+
$Queue = @($InterfaceNode)
45+
$visited = @("I$Model")
46+
$AllInterfaceNodes = @()
47+
while ($Queue.count -ne 0)
48+
{
49+
$AllInterfaceNodes += $Queue[0]
50+
# Baselist contains the direct parent models.
51+
foreach ($parent in $Queue[0].BaseList.Types)
52+
{
53+
if (($parent.Type.Right.Identifier.Value -ne 'IJsonSerializable') -and (-not $visited.Contains($parent.Type.Right.Identifier.Value)))
54+
{
55+
$Queue = [Array]$Queue + ($Nodes | Where-Object { ($_.Keyword.value -eq 'interface') -and ($_.Identifier.value -eq $parent.Type.Right.Identifier.Value) })
56+
$visited = [Array]$visited + $parent.Type.Right.Identifier.Value
57+
}
58+
}
59+
$first, $Queue = $Queue
60+
}
61+
62+
$Namespace = $InterfaceNode.Parent.Name
63+
$ObjectType = $Model
64+
$ObjectTypeWithNamespace = "${Namespace}.${ObjectType}"
65+
# remove duplicated module name
66+
if ($ObjectType.StartsWith($ModuleName)) {
67+
$ModulePrefix = ''
68+
} else {
69+
$ModulePrefix = $ModuleName
70+
}
71+
$OutputPath = Join-Path -ChildPath "New-Az${ModulePrefix}${ObjectType}Object.ps1" -Path $OutputDir
72+
73+
$ParameterDefineScriptList = New-Object System.Collections.Generic.List[string]
74+
$ParameterAssignScriptList = New-Object System.Collections.Generic.List[string]
75+
foreach ($Node in $AllInterfaceNodes)
76+
{
77+
foreach ($Member in $Node.Members)
78+
{
79+
$Arguments = $Member.AttributeLists.Attributes.ArgumentList.Arguments
80+
$Required = $false
81+
$Description = ""
82+
$Readonly = $False
83+
foreach ($Argument in $Arguments)
84+
{
85+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Required")
86+
{
87+
$Required = $Argument.Expression.Token.Value
88+
}
89+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Description")
90+
{
91+
$Description = $Argument.Expression.Token.Value.Trim('.').replace('"', '`"')
92+
}
93+
if ($Argument.NameEquals.Name.Identifier.Value -eq "Readonly")
94+
{
95+
$Readonly = $Argument.Expression.Token.Value
96+
}
97+
}
98+
if ($Readonly)
99+
{
100+
continue
101+
}
102+
$Identifier = $Member.Identifier.Value
103+
$Type = $Member.Type.ToString().replace('?', '').Split("::")[-1]
104+
$ParameterDefinePropertyList = New-Object System.Collections.Generic.List[string]
105+
if ($Required)
106+
{
107+
$ParameterDefinePropertyList.Add("Mandatory")
108+
}
109+
if ($Description -ne "")
110+
{
111+
$ParameterDefinePropertyList.Add("HelpMessage=`"${Description}.`"")
112+
}
113+
$ParameterDefineProperty = [System.String]::Join(", ", $ParameterDefinePropertyList)
114+
$ParameterDefineScript = "
115+
[Parameter($ParameterDefineProperty)]
116+
[${Type}]
117+
`$${Identifier}"
118+
$ParameterDefineScriptList.Add($ParameterDefineScript)
119+
$ParameterAssignScriptList.Add("
120+
`$Object.${Identifier} = `$${Identifier}")
121+
}
122+
}
123+
$ParameterDefineScript = $ParameterDefineScriptList | Join-String -Separator ","
124+
$ParameterAssignScript = $ParameterAssignScriptList | Join-String -Separator ""
125+
126+
$Script = "
127+
# ----------------------------------------------------------------------------------
128+
#
129+
# Copyright Microsoft Corporation
130+
# Licensed under the Apache License, Version 2.0 (the \`"License\`");
131+
# you may not use this file except in compliance with the License.
132+
# You may obtain a copy of the License at
133+
# http://www.apache.org/licenses/LICENSE-2.0
134+
# Unless required by applicable law or agreed to in writing, software
135+
# distributed under the License is distributed on an \`"AS IS\`" BASIS,
136+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
137+
# See the License for the specific language governing permissions and
138+
# limitations under the License.
139+
# ----------------------------------------------------------------------------------
140+
141+
<#
142+
.Synopsis
143+
Create a in-memory object for ${ObjectType}
144+
.Description
145+
Create a in-memory object for ${ObjectType}
146+
147+
.Outputs
148+
${ObjectTypeWithNamespace}
149+
.Link
150+
https://docs.microsoft.com/powershell/module/az.${ModuleName}/new-Az${ModulePrefix}${ObjectType}Object
151+
#>
152+
function New-Az${ModulePrefix}${ObjectType}Object {
153+
[OutputType('${ObjectTypeWithNamespace}')]
154+
[CmdletBinding(PositionalBinding=`$false)]
155+
Param(
156+
${ParameterDefineScript}
157+
)
158+
159+
process {
160+
`$Object = [${ObjectTypeWithNamespace}]::New()
161+
${ParameterAssignScript}
162+
return `$Object
163+
}
164+
}
165+
"
166+
Set-Content -Path $OutputPath -Value $Script
167+
}
168+
}

0 commit comments

Comments
 (0)