@autorest/powershell 3.0.509 → 3.0.511
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +17 -16
- package/dist/cmdlets/class.d.ts +1 -1
- package/dist/cmdlets/class.d.ts.map +1 -1
- package/dist/cmdlets/class.js +35 -8
- package/dist/cmdlets/class.js.map +1 -1
- package/dist/internal/powershell-declarations.d.ts +1 -0
- package/dist/internal/powershell-declarations.d.ts.map +1 -1
- package/dist/internal/powershell-declarations.js +1 -0
- package/dist/internal/powershell-declarations.js.map +1 -1
- package/dist/plugins/modifiers-v2.d.ts.map +1 -1
- package/dist/plugins/modifiers-v2.js +20 -12
- package/dist/plugins/modifiers-v2.js.map +1 -1
- package/package.json +1 -1
- package/resources/assets/build-module.ps1 +8 -1
- package/resources/assets/generate-help.ps1 +2 -2
- package/resources/assets/generate-portal-ux.ps1 +381 -0
- package/resources/assets/tools/Resources/how-to.md +2 -0
- package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
- package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +4 -1
- package/resources/psruntime/BuildTime/MarkdownRenderer.cs +16 -8
- package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +8 -1
- package/resources/psruntime/BuildTime/PsAttributes.cs +7 -0
- package/resources/psruntime/MessageAttribute.cs +22 -3
- package/resources/psruntime/MessageAttributeHelper.cs +26 -7
- package/resources/psruntime/Properties/Resources.Designer.cs +10 -1
- package/resources/psruntime/Properties/Resources.resx +4 -1
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------
|
|
2
|
+
${$project.pwshCommentHeader}
|
|
3
|
+
#
|
|
4
|
+
# This Script will create a folder dedicated to Azure-specific content and includes metadata files essential for enhancing the user experience (UX) within the Azure portal.
|
|
5
|
+
# These files are utilized by the Azure portal to effectively present the usage of cmdlets related to specific resources on portal pages.
|
|
6
|
+
# ----------------------------------------------------------------------------------
|
|
7
|
+
param([switch]$Isolated)
|
|
8
|
+
$ErrorActionPreference = 'Stop'
|
|
9
|
+
|
|
10
|
+
$pwsh = [System.Diagnostics.Process]::GetCurrentProcess().Path
|
|
11
|
+
if(-not $Isolated) {
|
|
12
|
+
Write-Host -ForegroundColor Green 'Creating isolated process...'
|
|
13
|
+
& "$pwsh" -NonInteractive -NoLogo -NoProfile -File $MyInvocation.MyCommand.Path @PSBoundParameters -Isolated
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$exportsFolder = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.exportsFolder)}'
|
|
18
|
+
if(-not (Test-Path $exportsFolder)) {
|
|
19
|
+
Write-Error "Exports folder '$exportsFolder' was not found."
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
$directories = Get-ChildItem -Directory -Path $exportsFolder
|
|
23
|
+
$hasProfiles = ($directories | Measure-Object).Count -gt 0
|
|
24
|
+
if(-not $hasProfiles) {
|
|
25
|
+
$directories = Get-Item -Path $exportsFolder
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
$docsFolder = Join-Path $PSScriptRoot '${$lib.path.relative($project.baseFolder, $project.docsFolder)}'
|
|
29
|
+
if(Test-Path $docsFolder) {
|
|
30
|
+
$null = Get-ChildItem -Path $docsFolder -Recurse -Exclude 'README.md' | Remove-Item -Recurse -ErrorAction SilentlyContinue
|
|
31
|
+
}
|
|
32
|
+
$null = New-Item -ItemType Directory -Force -Path $docsFolder -ErrorAction SilentlyContinue
|
|
33
|
+
|
|
34
|
+
$moduleName = '${$project.moduleName}'
|
|
35
|
+
$rootModuleName = '${$project.rootModuleName}'
|
|
36
|
+
if ($rootModuleName -eq "")
|
|
37
|
+
{
|
|
38
|
+
$rootModuleName = $moduleName
|
|
39
|
+
}
|
|
40
|
+
$modulePsd1 = Get-Item -Path (Join-Path $PSScriptRoot "./$moduleName.psd1")
|
|
41
|
+
$modulePath = $modulePsd1.FullName
|
|
42
|
+
|
|
43
|
+
# Load DLL to use build-time cmdlets
|
|
44
|
+
Import-Module -Name $modulePath
|
|
45
|
+
Import-Module -Name (Join-Path $PSScriptRoot "./bin/$moduleName.private.dll")
|
|
46
|
+
$instance = [${$project.serviceNamespace.moduleClass.declaration}]::Instance
|
|
47
|
+
# Module info is shared per profile
|
|
48
|
+
$moduleInfo = Get-Module -Name $moduleName
|
|
49
|
+
$parameterSetsInfo = Get-Module -Name "$moduleName.private"
|
|
50
|
+
|
|
51
|
+
$buildinFunctions = @("Export-CmdletSurface", "Export-ExampleStub", "Export-FormatPs1xml", "Export-HelpMarkdown", "Export-ModelSurface", "Export-ProxyCmdlet", "Export-Psd1", "Export-TestStub", "Get-CommonParameter", "Get-ModuleGuid", "Get-ScriptCmdlet")
|
|
52
|
+
|
|
53
|
+
function Test-FunctionSupported()
|
|
54
|
+
{
|
|
55
|
+
[CmdletBinding()]
|
|
56
|
+
Param (
|
|
57
|
+
[Parameter()]
|
|
58
|
+
[string]
|
|
59
|
+
$FunctionName
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
If ($buildinfunctions.Contains($FunctionName)) {
|
|
63
|
+
return $false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
$cmdletName, $parameterSetName = $FunctionName.Split("_")
|
|
67
|
+
If ($parameterSetName.Contains("List") -or $parameterSetName.Contains("ViaIdentity")) {
|
|
68
|
+
return $false
|
|
69
|
+
}
|
|
70
|
+
If ($cmdletName.StartsWith("New") -or $cmdletName.StartsWith("Set") -or $cmdletName.StartsWith("Update")) {
|
|
71
|
+
return $false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
$parameterSetInfo = $parameterSetsInfo.ExportedCmdlets[$FunctionName]
|
|
75
|
+
foreach ($parameterInfo in $parameterSetInfo.Parameters.Values)
|
|
76
|
+
{
|
|
77
|
+
$category = (Get-ParameterAttribute -ParameterInfo $parameterInfo -AttributeName "CategoryAttribute").Categories
|
|
78
|
+
$invalideCategory = @('Query', 'Body')
|
|
79
|
+
if ($invalideCategory -contains $category)
|
|
80
|
+
{
|
|
81
|
+
return $false
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
$customFiles = Get-ChildItem -Path custom -Filter "$cmdletName.*"
|
|
86
|
+
if ($customFiles.Length -ne 0)
|
|
87
|
+
{
|
|
88
|
+
return $false
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return $true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function Get-MappedCmdletFromFunctionName()
|
|
95
|
+
{
|
|
96
|
+
[CmdletBinding()]
|
|
97
|
+
Param (
|
|
98
|
+
[Parameter()]
|
|
99
|
+
[string]
|
|
100
|
+
$FunctionName
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
$cmdletName, $parameterSetName = $FunctionName.Split("_")
|
|
104
|
+
|
|
105
|
+
return $cmdletName
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function Get-ParameterAttribute()
|
|
109
|
+
{
|
|
110
|
+
[CmdletBinding()]
|
|
111
|
+
Param (
|
|
112
|
+
[Parameter()]
|
|
113
|
+
[System.Management.Automation.ParameterMetadata]
|
|
114
|
+
$ParameterInfo,
|
|
115
|
+
[Parameter()]
|
|
116
|
+
[String]
|
|
117
|
+
$AttributeName
|
|
118
|
+
)
|
|
119
|
+
return $ParameterInfo.Attributes | Where-Object { $_.TypeId.Name -eq $AttributeName }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function Get-CmdletAttribute()
|
|
123
|
+
{
|
|
124
|
+
[CmdletBinding()]
|
|
125
|
+
Param (
|
|
126
|
+
[Parameter()]
|
|
127
|
+
[System.Management.Automation.CommandInfo]
|
|
128
|
+
$CmdletInfo,
|
|
129
|
+
[Parameter()]
|
|
130
|
+
[String]
|
|
131
|
+
$AttributeName
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
return $CmdletInfo.ImplementingType.GetTypeInfo().GetCustomAttributes([System.object], $true) | Where-Object { $_.TypeId.Name -eq $AttributeName }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function Get-CmdletDescription()
|
|
138
|
+
{
|
|
139
|
+
[CmdletBinding()]
|
|
140
|
+
Param (
|
|
141
|
+
[Parameter()]
|
|
142
|
+
[String]
|
|
143
|
+
$CmdletName
|
|
144
|
+
)
|
|
145
|
+
$helpInfo = Get-Help $CmdletName -Full
|
|
146
|
+
|
|
147
|
+
$description = $helpInfo.Description.Text
|
|
148
|
+
if ($null -eq $description)
|
|
149
|
+
{
|
|
150
|
+
return ""
|
|
151
|
+
}
|
|
152
|
+
return $description
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
# Test whether the parameter is from swagger http path
|
|
156
|
+
function Test-ParameterFromSwagger()
|
|
157
|
+
{
|
|
158
|
+
[CmdletBinding()]
|
|
159
|
+
Param (
|
|
160
|
+
[Parameter()]
|
|
161
|
+
[System.Management.Automation.ParameterMetadata]
|
|
162
|
+
$ParameterInfo
|
|
163
|
+
)
|
|
164
|
+
$category = (Get-ParameterAttribute -ParameterInfo $ParameterInfo -AttributeName "CategoryAttribute").Categories
|
|
165
|
+
$doNotExport = Get-ParameterAttribute -ParameterInfo $ParameterInfo -AttributeName "DoNotExportAttribute"
|
|
166
|
+
if ($null -ne $doNotExport)
|
|
167
|
+
{
|
|
168
|
+
return $false
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
$valideCategory = @('Path')
|
|
172
|
+
if ($valideCategory -contains $category)
|
|
173
|
+
{
|
|
174
|
+
return $true
|
|
175
|
+
}
|
|
176
|
+
return $false
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function New-ExampleForParameterSet()
|
|
180
|
+
{
|
|
181
|
+
[CmdletBinding()]
|
|
182
|
+
Param (
|
|
183
|
+
[Parameter()]
|
|
184
|
+
[System.Management.Automation.CommandInfo]
|
|
185
|
+
$ParameterSetInfo
|
|
186
|
+
)
|
|
187
|
+
$parameters = $ParameterSetInfo.Parameters.Values | Where-Object { Test-ParameterFromSwagger $_ }
|
|
188
|
+
$result = @()
|
|
189
|
+
foreach ($parameter in $parameters)
|
|
190
|
+
{
|
|
191
|
+
$category = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "CategoryAttribute").Categories
|
|
192
|
+
$sourceName = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "InfoAttribute").SerializedName
|
|
193
|
+
$name = $parameter.Name
|
|
194
|
+
$result += [ordered]@{
|
|
195
|
+
name = "-$Name"
|
|
196
|
+
value = "[$category.$sourceName]"
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return $result
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function New-ParameterArrayInParameterSet()
|
|
204
|
+
{
|
|
205
|
+
[CmdletBinding()]
|
|
206
|
+
Param (
|
|
207
|
+
[Parameter()]
|
|
208
|
+
[System.Management.Automation.CommandInfo]
|
|
209
|
+
$ParameterSetInfo
|
|
210
|
+
)
|
|
211
|
+
$parameters = $ParameterSetInfo.Parameters.Values | Where-Object { Test-ParameterFromSwagger $_ }
|
|
212
|
+
$result = @()
|
|
213
|
+
foreach ($parameter in $parameters)
|
|
214
|
+
{
|
|
215
|
+
$isMandatory = (Get-ParameterAttribute -parameterInfo $parameter -AttributeName "ParameterAttribute").Mandatory
|
|
216
|
+
$parameterName = $parameter.Name
|
|
217
|
+
$parameterType = $parameter.ParameterType.ToString().Split('.')[1]
|
|
218
|
+
if ($parameter.SwitchParameter)
|
|
219
|
+
{
|
|
220
|
+
$parameterSignature = "-$parameterName"
|
|
221
|
+
}
|
|
222
|
+
else
|
|
223
|
+
{
|
|
224
|
+
$parameterSignature = "-$parameterName <$parameterType>"
|
|
225
|
+
}
|
|
226
|
+
if ($parameterName -eq "SubscriptionId")
|
|
227
|
+
{
|
|
228
|
+
$isMandatory = $false
|
|
229
|
+
}
|
|
230
|
+
if (-not $isMandatory)
|
|
231
|
+
{
|
|
232
|
+
$parameterSignature = "[$parameterSignature]"
|
|
233
|
+
}
|
|
234
|
+
$result += $parameterSignature
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return $result
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function New-MetadataForParameterSet()
|
|
241
|
+
{
|
|
242
|
+
[CmdletBinding()]
|
|
243
|
+
Param (
|
|
244
|
+
[Parameter()]
|
|
245
|
+
[System.Management.Automation.CommandInfo]
|
|
246
|
+
$ParameterSetInfo
|
|
247
|
+
)
|
|
248
|
+
$httpAttribute = Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "HttpPathAttribute"
|
|
249
|
+
$httpPath = $httpAttribute.Path
|
|
250
|
+
$apiVersion = $httpAttribute.ApiVersion
|
|
251
|
+
$provider = [System.Text.RegularExpressions.Regex]::New("/providers/([\w+\.]+)/").Match($httpPath).Groups[1].Value
|
|
252
|
+
$resourcePath = "/" + $httpPath.Split("$provider/")[1]
|
|
253
|
+
$resourceType = [System.Text.RegularExpressions.Regex]::New("/([\w]+)/\{\w+\}").Matches($resourcePath) | ForEach-Object {$_.groups[1].Value} | Join-String -Separator "/"
|
|
254
|
+
$cmdletName = Get-MappedCmdletFromFunctionName $ParameterSetInfo.Name
|
|
255
|
+
$description = (Get-CmdletAttribute -CmdletInfo $ParameterSetInfo -AttributeName "DescriptionAttribute").Description
|
|
256
|
+
[object[]]$example = New-ExampleForParameterSet $ParameterSetInfo
|
|
257
|
+
[string[]]$signature = New-ParameterArrayInParameterSet $ParameterSetInfo
|
|
258
|
+
|
|
259
|
+
return @{
|
|
260
|
+
Path = $httpPath
|
|
261
|
+
Provider = $provider
|
|
262
|
+
ResourceType = $resourceType
|
|
263
|
+
ApiVersion = $apiVersion
|
|
264
|
+
CmdletName = $cmdletName
|
|
265
|
+
Description = $description
|
|
266
|
+
Example = $example
|
|
267
|
+
Signature = @{
|
|
268
|
+
parameters = $signature
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function Merge-WithExistCmdletMetadata()
|
|
274
|
+
{
|
|
275
|
+
[CmdletBinding()]
|
|
276
|
+
Param (
|
|
277
|
+
[Parameter()]
|
|
278
|
+
[System.Collections.Specialized.OrderedDictionary]
|
|
279
|
+
$ExistedCmdletInfo,
|
|
280
|
+
[Parameter()]
|
|
281
|
+
[Hashtable]
|
|
282
|
+
$ParameterSetMetadata
|
|
283
|
+
)
|
|
284
|
+
$ExistedCmdletInfo.help.parameterSets += $ParameterSetMetadata.Signature
|
|
285
|
+
$ExistedCmdletInfo.examples += [ordered]@{
|
|
286
|
+
description = $ParameterSetMetadata.Description
|
|
287
|
+
parameters = $ParameterSetMetadata.Example
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return $ExistedCmdletInfo
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function New-MetadataForCmdlet()
|
|
294
|
+
{
|
|
295
|
+
[CmdletBinding()]
|
|
296
|
+
Param (
|
|
297
|
+
[Parameter()]
|
|
298
|
+
[Hashtable]
|
|
299
|
+
$ParameterSetMetadata
|
|
300
|
+
)
|
|
301
|
+
$cmdletName = $ParameterSetMetadata.CmdletName
|
|
302
|
+
$description = Get-CmdletDescription $cmdletName
|
|
303
|
+
$result = [ordered]@{
|
|
304
|
+
name = $cmdletName
|
|
305
|
+
description = $description
|
|
306
|
+
path = $ParameterSetMetadata.Path
|
|
307
|
+
help = [ordered]@{
|
|
308
|
+
learnMore = [ordered]@{
|
|
309
|
+
url = "https://learn.microsoft.com/powershell/module/$rootModuleName/$cmdletName".ToLower()
|
|
310
|
+
}
|
|
311
|
+
parameterSets = @()
|
|
312
|
+
}
|
|
313
|
+
examples = @()
|
|
314
|
+
}
|
|
315
|
+
$result = Merge-WithExistCmdletMetadata -ExistedCmdletInfo $result -ParameterSetMetadata $ParameterSetMetadata
|
|
316
|
+
return $result
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
$parameterSets = $parameterSetsInfo.ExportedCmdlets.Keys | Where-Object { Test-functionSupported($_) }
|
|
320
|
+
$resourceTypes = @{}
|
|
321
|
+
foreach ($parameterSetName in $parameterSets)
|
|
322
|
+
{
|
|
323
|
+
$cmdletInfo = $parameterSetsInfo.ExportedCommands[$parameterSetName]
|
|
324
|
+
$parameterSetMetadata = New-MetadataForParameterSet -ParameterSetInfo $cmdletInfo
|
|
325
|
+
$cmdletName = $parameterSetMetadata.CmdletName
|
|
326
|
+
if (-not ($moduleInfo.ExportedCommands.ContainsKey($cmdletName)))
|
|
327
|
+
{
|
|
328
|
+
continue
|
|
329
|
+
}
|
|
330
|
+
if ($resourceTypes.ContainsKey($parameterSetMetadata.ResourceType))
|
|
331
|
+
{
|
|
332
|
+
$ExistedCmdletInfo = $resourceTypes[$parameterSetMetadata.ResourceType].commands | Where-Object { $_.name -eq $cmdletName }
|
|
333
|
+
if ($ExistedCmdletInfo)
|
|
334
|
+
{
|
|
335
|
+
$ExistedCmdletInfo = Merge-WithExistCmdletMetadata -ExistedCmdletInfo $ExistedCmdletInfo -ParameterSetMetadata $parameterSetMetadata
|
|
336
|
+
}
|
|
337
|
+
else
|
|
338
|
+
{
|
|
339
|
+
$cmdletInfo = New-MetadataForCmdlet -ParameterSetMetadata $parameterSetMetadata
|
|
340
|
+
$resourceTypes[$parameterSetMetadata.ResourceType].commands += $cmdletInfo
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else
|
|
344
|
+
{
|
|
345
|
+
$cmdletInfo = New-MetadataForCmdlet -ParameterSetMetadata $parameterSetMetadata
|
|
346
|
+
$resourceTypes[$parameterSetMetadata.ResourceType] = [ordered]@{
|
|
347
|
+
resourceType = $parameterSetMetadata.ResourceType
|
|
348
|
+
apiVersion = $parameterSetMetadata.ApiVersion
|
|
349
|
+
learnMore = @{
|
|
350
|
+
url = "https://learn.microsoft.com/powershell/module/$rootModuleName".ToLower()
|
|
351
|
+
}
|
|
352
|
+
commands = @($cmdletInfo)
|
|
353
|
+
provider = $parameterSetMetadata.Provider
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
$UXFolder = '${$lib.path.relative($project.baseFolder, $project.uxFolder)}'
|
|
359
|
+
if (Test-Path $UXFolder)
|
|
360
|
+
{
|
|
361
|
+
Remove-Item -Path $UXFolder -Recurse
|
|
362
|
+
}
|
|
363
|
+
$null = New-Item -ItemType Directory -Path $UXFolder
|
|
364
|
+
|
|
365
|
+
foreach ($resourceType in $resourceTypes.Keys)
|
|
366
|
+
{
|
|
367
|
+
$resourceTypeFileName = $resourceType -replace "/", "-"
|
|
368
|
+
if ($resourceTypeFileName -eq "")
|
|
369
|
+
{
|
|
370
|
+
continue
|
|
371
|
+
}
|
|
372
|
+
$resourceTypeInfo = $resourceTypes[$resourceType]
|
|
373
|
+
$provider = $resourceTypeInfo.provider
|
|
374
|
+
$providerFolder = "$UXFolder/$provider"
|
|
375
|
+
if (-not (Test-Path $providerFolder))
|
|
376
|
+
{
|
|
377
|
+
$null = New-Item -ItemType Directory -Path $providerFolder
|
|
378
|
+
}
|
|
379
|
+
$resourceTypeInfo.Remove("provider")
|
|
380
|
+
$resourceTypeInfo | ConvertTo-Json -Depth 10 | Out-File "$providerFolder/$resourceTypeFileName.json"
|
|
381
|
+
}
|
|
@@ -48,6 +48,8 @@ There are multiple scripts created for performing different actions for developi
|
|
|
48
48
|
- Generates the Markdown documents for the modules into the `docs` folder.
|
|
49
49
|
- Same as `-Docs` in `build-module.ps1`.
|
|
50
50
|
- This process is now integrated into `build-module.ps1` automatically. To disable, use `-NoDocs` when running `build-module.ps1`.
|
|
51
|
+
- `generate-portal-ux.ps1`
|
|
52
|
+
- Generates a folder dedicated to Azure-specific content and includes metadata files essential for enhancing the user experience (UX) within the Azure portal.
|
|
51
53
|
- `export-surface.ps1`
|
|
52
54
|
- Generates Markdown documents for both the cmdlet surface and the model (class) surface of the module.
|
|
53
55
|
- These files are placed into the `resources` folder.
|
|
@@ -33,6 +33,9 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
33
33
|
[ValidateNotNullOrEmpty]
|
|
34
34
|
public string ExamplesFolder { get; set; }
|
|
35
35
|
|
|
36
|
+
[Parameter()]
|
|
37
|
+
public SwitchParameter AddComplexInterfaceInfo { get; set; }
|
|
38
|
+
|
|
36
39
|
protected override void ProcessRecord()
|
|
37
40
|
{
|
|
38
41
|
try
|
|
@@ -41,7 +44,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
41
44
|
var variantGroups = FunctionInfo.Select(fi => fi.BaseObject).Cast<FunctionInfo>()
|
|
42
45
|
.Join(helpInfos, fi => fi.Name, phi => phi.CmdletName, (fi, phi) => fi.ToVariants(phi))
|
|
43
46
|
.Select(va => new VariantGroup(ModuleInfo.Name, va.First().CmdletName, va, String.Empty));
|
|
44
|
-
WriteMarkdowns(variantGroups, ModuleInfo.ToModuleInfo(), DocsFolder, ExamplesFolder);
|
|
47
|
+
WriteMarkdowns(variantGroups, ModuleInfo.ToModuleInfo(), DocsFolder, ExamplesFolder, AddComplexInterfaceInfo.IsPresent);
|
|
45
48
|
}
|
|
46
49
|
catch (Exception ee)
|
|
47
50
|
{
|
|
@@ -52,6 +52,9 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
52
52
|
[Parameter(Mandatory = true, ParameterSetName = "NoDocs")]
|
|
53
53
|
public SwitchParameter ExcludeDocs { get; set; }
|
|
54
54
|
|
|
55
|
+
[Parameter(ParameterSetName = "Docs")]
|
|
56
|
+
public SwitchParameter AddComplexInterfaceInfo { get; set; }
|
|
57
|
+
|
|
55
58
|
protected override void ProcessRecord()
|
|
56
59
|
{
|
|
57
60
|
try
|
|
@@ -152,7 +155,7 @@ ${$project.pwshCommentHeaderForCsharp}
|
|
|
152
155
|
var isValidProfile = !String.IsNullOrEmpty(profileName) && profileName != NoProfiles;
|
|
153
156
|
var docsFolder = isValidProfile ? Path.Combine(DocsFolder, profileName) : DocsFolder;
|
|
154
157
|
var examplesFolder = isValidProfile ? Path.Combine(ExamplesFolder, profileName) : ExamplesFolder;
|
|
155
|
-
WriteMarkdowns(variantGroupsByProfile, moduleInfo, docsFolder, examplesFolder);
|
|
158
|
+
WriteMarkdowns(variantGroupsByProfile, moduleInfo, docsFolder, examplesFolder, AddComplexInterfaceInfo.IsPresent);
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
}
|
|
@@ -14,7 +14,7 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
14
14
|
{
|
|
15
15
|
internal static class MarkdownRenderer
|
|
16
16
|
{
|
|
17
|
-
public static void WriteMarkdowns(IEnumerable<VariantGroup> variantGroups, PsModuleHelpInfo moduleHelpInfo, string docsFolder, string examplesFolder)
|
|
17
|
+
public static void WriteMarkdowns(IEnumerable<VariantGroup> variantGroups, PsModuleHelpInfo moduleHelpInfo, string docsFolder, string examplesFolder, bool AddComplexInterfaceInfo = true)
|
|
18
18
|
{
|
|
19
19
|
Directory.CreateDirectory(docsFolder);
|
|
20
20
|
var markdownInfos = variantGroups.Where(vg => !vg.IsInternal).Select(vg => new MarkdownHelpInfo(vg, examplesFolder)).OrderBy(mhi => mhi.CmdletName).ToArray();
|
|
@@ -69,18 +69,26 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
sb.Append($"## NOTES{Environment.NewLine}{Environment.NewLine}");
|
|
72
|
-
|
|
73
|
-
foreach (var alias in markdownInfo.Aliases)
|
|
72
|
+
if (markdownInfo.Aliases.Any())
|
|
74
73
|
{
|
|
75
|
-
sb.Append($"{
|
|
74
|
+
sb.Append($"ALIASES{Environment.NewLine}{Environment.NewLine}");
|
|
76
75
|
}
|
|
77
|
-
|
|
76
|
+
foreach (var alias in markdownInfo.Aliases)
|
|
78
77
|
{
|
|
79
|
-
sb.Append($"{
|
|
78
|
+
sb.Append($"{alias}{Environment.NewLine}{Environment.NewLine}");
|
|
80
79
|
}
|
|
81
|
-
|
|
80
|
+
|
|
81
|
+
if (AddComplexInterfaceInfo)
|
|
82
82
|
{
|
|
83
|
-
|
|
83
|
+
if (markdownInfo.ComplexInterfaceInfos.Any())
|
|
84
|
+
{
|
|
85
|
+
sb.Append($"{ComplexParameterHeader}{Environment.NewLine}");
|
|
86
|
+
}
|
|
87
|
+
foreach (var complexInterfaceInfo in markdownInfo.ComplexInterfaceInfos)
|
|
88
|
+
{
|
|
89
|
+
sb.Append($"{complexInterfaceInfo.ToNoteOutput(includeDashes: true, includeBackticks: true)}{Environment.NewLine}{Environment.NewLine}");
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
}
|
|
85
93
|
|
|
86
94
|
sb.Append($"## RELATED LINKS{Environment.NewLine}{Environment.NewLine}");
|
|
@@ -191,8 +191,15 @@ namespace Microsoft.Rest.ClientRuntime.PowerShell
|
|
|
191
191
|
|
|
192
192
|
public string GetProcessCustomAttributesAtRuntime()
|
|
193
193
|
{
|
|
194
|
-
return VariantGroup.IsInternal ? "" : $@"{Indent}{Indent}$cmdInfo = Get-Command -Name $mapping[$parameterSet]
|
|
194
|
+
return VariantGroup.IsInternal ? "" : IsAzure ? $@"{Indent}{Indent}$cmdInfo = Get-Command -Name $mapping[$parameterSet]
|
|
195
|
+
{Indent}{Indent}[Microsoft.Message.ClientRuntime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
|
|
196
|
+
{Indent}{Indent}if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Message.ClientRuntime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){{
|
|
197
|
+
{Indent}{Indent}{Indent}[Microsoft.Message.ClientRuntime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
|
|
198
|
+
{Indent}{Indent}{Indent}[Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name)
|
|
199
|
+
{Indent}{Indent}}}" : $@"{Indent}{Indent}$cmdInfo = Get-Command -Name $mapping[$parameterSet]{Environment.NewLine}{Indent}{Indent}[Microsoft.Message.ClientRuntime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)
|
|
200
|
+
{Indent}{Indent}[Microsoft.Message.ClientRuntime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet)";
|
|
195
201
|
}
|
|
202
|
+
|
|
196
203
|
private string GetTelemetry()
|
|
197
204
|
{
|
|
198
205
|
if (!VariantGroup.IsInternal && IsAzure)
|
|
@@ -48,6 +48,13 @@ namespace Microsoft.Rest
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
[AttributeUsage(AttributeTargets.Class)]
|
|
52
|
+
public class HttpPathAttribute : Attribute
|
|
53
|
+
{
|
|
54
|
+
public string Path { get; set; }
|
|
55
|
+
public string ApiVersion { get; set; }
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
52
59
|
public class CategoryAttribute : Attribute
|
|
53
60
|
{
|
|
@@ -168,6 +168,11 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
168
168
|
{
|
|
169
169
|
public string _message;
|
|
170
170
|
|
|
171
|
+
public DateTime EstimatedGaDate { get; }
|
|
172
|
+
|
|
173
|
+
public bool IsEstimatedGaDateSet { get; } = false;
|
|
174
|
+
|
|
175
|
+
|
|
171
176
|
public PreviewMessageAttribute()
|
|
172
177
|
{
|
|
173
178
|
this._message = Resources.PreviewCmdletMessage;
|
|
@@ -175,12 +180,26 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
175
180
|
|
|
176
181
|
public PreviewMessageAttribute(string message)
|
|
177
182
|
{
|
|
178
|
-
this._message = message;
|
|
183
|
+
this._message = string.IsNullOrEmpty(message) ? Resources.PreviewCmdletMessage : message;
|
|
179
184
|
}
|
|
180
185
|
|
|
181
|
-
public
|
|
186
|
+
public PreviewMessageAttribute(string message, string estimatedDateOfGa) : this(message)
|
|
187
|
+
{
|
|
188
|
+
if (DateTime.TryParse(estimatedDateOfGa, new CultureInfo("en-US"), DateTimeStyles.None, out DateTime result))
|
|
189
|
+
{
|
|
190
|
+
this.EstimatedGaDate = result;
|
|
191
|
+
this.IsEstimatedGaDateSet = true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public void PrintCustomAttributeInfo(Action<string> writeOutput)
|
|
182
196
|
{
|
|
183
|
-
|
|
197
|
+
writeOutput(this._message);
|
|
198
|
+
|
|
199
|
+
if (IsEstimatedGaDateSet)
|
|
200
|
+
{
|
|
201
|
+
writeOutput(string.Format(Resources.PreviewCmdletETAMessage, this.EstimatedGaDate.ToShortDateString()));
|
|
202
|
+
}
|
|
184
203
|
}
|
|
185
204
|
|
|
186
205
|
public virtual bool IsApplicableToInvocation(InvocationInfo invocation)
|
|
@@ -35,7 +35,7 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
35
35
|
* the boundParameterNames is a list of parameters bound to the cmdlet at runtime,
|
|
36
36
|
* We only process the Parameter beaking change attributes attached only params listed in this list (if present)
|
|
37
37
|
* */
|
|
38
|
-
public static void ProcessCustomAttributesAtRuntime(CommandInfo commandInfo, InvocationInfo invocationInfo, String parameterSet, System.Management.Automation.PSCmdlet psCmdlet)
|
|
38
|
+
public static void ProcessCustomAttributesAtRuntime(CommandInfo commandInfo, InvocationInfo invocationInfo, String parameterSet, System.Management.Automation.PSCmdlet psCmdlet, bool showPreviewMessage = true)
|
|
39
39
|
{
|
|
40
40
|
bool supressWarningOrError = false;
|
|
41
41
|
|
|
@@ -57,36 +57,49 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
57
57
|
{
|
|
58
58
|
psCmdlet.WriteWarning("The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.");
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
ProcessBreakingChangeAttributesAtRuntime(commandInfo, invocationInfo, parameterSet, psCmdlet);
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private static void ProcessBreakingChangeAttributesAtRuntime(CommandInfo commandInfo, InvocationInfo invocationInfo, String parameterSet, System.Management.Automation.PSCmdlet psCmdlet)
|
|
66
|
+
{
|
|
60
67
|
List<GenericBreakingChangeAttribute> attributes = new List<GenericBreakingChangeAttribute>(GetAllBreakingChangeAttributesInType(commandInfo, invocationInfo, parameterSet));
|
|
61
68
|
StringBuilder sb = new StringBuilder();
|
|
62
|
-
Action<string>
|
|
69
|
+
Action<string> appendAttributeMessage = (string s) => sb.Append(s);
|
|
63
70
|
|
|
64
71
|
if (attributes != null && attributes.Count > 0)
|
|
65
72
|
{
|
|
66
|
-
|
|
73
|
+
appendAttributeMessage(string.Format(Resources.BreakingChangesAttributesHeaderMessage, commandInfo.Name.Split('_')[0]));
|
|
67
74
|
|
|
68
75
|
foreach (GenericBreakingChangeAttribute attribute in attributes)
|
|
69
76
|
{
|
|
70
|
-
attribute.PrintCustomAttributeInfo(
|
|
77
|
+
attribute.PrintCustomAttributeInfo(appendAttributeMessage);
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
|
|
80
|
+
appendAttributeMessage(string.Format(Resources.BreakingChangesAttributesFooterMessage, BREAKING_CHANGE_ATTRIBUTE_INFORMATION_LINK));
|
|
74
81
|
|
|
75
82
|
psCmdlet.WriteWarning(sb.ToString());
|
|
76
83
|
}
|
|
84
|
+
}
|
|
77
85
|
|
|
86
|
+
|
|
87
|
+
public static void ProcessPreviewMessageAttributesAtRuntime(CommandInfo commandInfo, InvocationInfo invocationInfo, String parameterSet, System.Management.Automation.PSCmdlet psCmdlet)
|
|
88
|
+
{
|
|
78
89
|
List<PreviewMessageAttribute> previewAttributes = new List<PreviewMessageAttribute>(GetAllPreviewAttributesInType(commandInfo, invocationInfo));
|
|
90
|
+
StringBuilder sb = new StringBuilder();
|
|
91
|
+
Action<string> appendAttributeMessage = (string s) => sb.Append(s);
|
|
79
92
|
|
|
80
93
|
if (previewAttributes != null && previewAttributes.Count > 0)
|
|
81
94
|
{
|
|
82
95
|
foreach (PreviewMessageAttribute attribute in previewAttributes)
|
|
83
96
|
{
|
|
84
|
-
attribute.PrintCustomAttributeInfo(
|
|
97
|
+
attribute.PrintCustomAttributeInfo(appendAttributeMessage);
|
|
85
98
|
}
|
|
99
|
+
psCmdlet.WriteWarning(sb.ToString());
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
102
|
|
|
89
|
-
|
|
90
103
|
/**
|
|
91
104
|
* This function takes in a CommandInfo (CmdletInfo or FunctionInfo)
|
|
92
105
|
* And returns all the deprecation attributes attached to it
|
|
@@ -128,6 +141,12 @@ namespace Microsoft.Message.ClientRuntime
|
|
|
128
141
|
}
|
|
129
142
|
return invocationInfo == null ? attributeList : attributeList.Where(e => e.GetType() == typeof(ParameterSetBreakingChangeAttribute) ? ((ParameterSetBreakingChangeAttribute)e).IsApplicableToInvocation(invocationInfo, parameterSet) : e.IsApplicableToInvocation(invocationInfo));
|
|
130
143
|
}
|
|
144
|
+
|
|
145
|
+
public static bool ContainsPreviewAttribute(CommandInfo commandInfo, InvocationInfo invocationInfo)
|
|
146
|
+
{
|
|
147
|
+
return GetAllPreviewAttributesInType(commandInfo, invocationInfo)?.Count() > 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
131
150
|
private static IEnumerable<PreviewMessageAttribute> GetAllPreviewAttributesInType(CommandInfo commandInfo, InvocationInfo invocationInfo)
|
|
132
151
|
{
|
|
133
152
|
List<PreviewMessageAttribute> attributeList = new List<PreviewMessageAttribute>();
|
|
@@ -3135,7 +3135,16 @@ namespace Microsoft.generated.runtime.Properties
|
|
|
3135
3135
|
}
|
|
3136
3136
|
|
|
3137
3137
|
/// <summary>
|
|
3138
|
-
///
|
|
3138
|
+
/// Looks up a localized string similar to The estimated generally available date is '{0}'..
|
|
3139
|
+
/// </summary>
|
|
3140
|
+
public static string PreviewCmdletETAMessage {
|
|
3141
|
+
get {
|
|
3142
|
+
return ResourceManager.GetString("PreviewCmdletETAMessage", resourceCulture);
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
/// <summary>
|
|
3147
|
+
/// Looks up a localized string similar to This cmdlet is in preview. Its behavior is subject to change based on customer feedback..
|
|
3139
3148
|
/// </summary>
|
|
3140
3149
|
public static string PreviewCmdletMessage
|
|
3141
3150
|
{
|
|
@@ -1736,7 +1736,10 @@ The type of the parameter is changing from '{0}' to '{1}'.</value>
|
|
|
1736
1736
|
Note : Go to {0} for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.</value>
|
|
1737
1737
|
</data>
|
|
1738
1738
|
<data name="PreviewCmdletMessage" xml:space="preserve">
|
|
1739
|
-
<value>This cmdlet is in preview.
|
|
1739
|
+
<value>This cmdlet is in preview. Its behavior is subject to change based on customer feedback.</value>
|
|
1740
|
+
</data>
|
|
1741
|
+
<data name="PreviewCmdletETAMessage" xml:space="preserve">
|
|
1742
|
+
<value> The estimated generally available date is '{0}'.</value>
|
|
1740
1743
|
</data>
|
|
1741
1744
|
<data name="BreakingChangesAttributesInEffectByAzVersion" xml:space="preserve">
|
|
1742
1745
|
<value>- The change is expected to take effect from Az version : '{0}'</value>
|