@autorest/powershell 4.0.0-dev.3 → 4.0.0-dev.5

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.
Files changed (262) hide show
  1. package/.rush/temp/package-deps_build.json +66 -41
  2. package/.rush/temp/shrinkwrap-deps.json +21 -21
  3. package/autorest-configuration-for-sdk.md +110 -0
  4. package/autorest-configuration.md +2 -1
  5. package/dist/cmdlets/class.d.ts +1 -0
  6. package/dist/cmdlets/class.d.ts.map +1 -1
  7. package/dist/cmdlets/class.js +168 -86
  8. package/dist/cmdlets/class.js.map +1 -1
  9. package/dist/cmdlets/namespace.d.ts.map +1 -1
  10. package/dist/cmdlets/namespace.js +3 -1
  11. package/dist/cmdlets/namespace.js.map +1 -1
  12. package/dist/cmdlets/parameter.js +1 -0
  13. package/dist/cmdlets/parameter.js.map +1 -1
  14. package/dist/enums/namespace.js +2 -1
  15. package/dist/enums/namespace.js.map +1 -1
  16. package/dist/file-formats/md-file.js +1 -0
  17. package/dist/file-formats/md-file.js.map +1 -1
  18. package/dist/file-formats/psd-file.js +1 -0
  19. package/dist/file-formats/psd-file.js.map +1 -1
  20. package/dist/file-formats/psscript-file.js +1 -0
  21. package/dist/file-formats/psscript-file.js.map +1 -1
  22. package/dist/generators/csproj.js +1 -0
  23. package/dist/generators/csproj.js.map +1 -1
  24. package/dist/generators/gitattributes.js +1 -0
  25. package/dist/generators/gitattributes.js.map +1 -1
  26. package/dist/generators/gitignore.js +1 -0
  27. package/dist/generators/gitignore.js.map +1 -1
  28. package/dist/generators/inputhandler.custom.d.ts +3 -0
  29. package/dist/generators/inputhandler.custom.d.ts.map +1 -0
  30. package/dist/generators/inputhandler.custom.js +33 -0
  31. package/dist/generators/inputhandler.custom.js.map +1 -0
  32. package/dist/generators/nuspec.js +1 -0
  33. package/dist/generators/nuspec.js.map +1 -1
  34. package/dist/generators/psm1.custom.js +1 -0
  35. package/dist/generators/psm1.custom.js.map +1 -1
  36. package/dist/generators/psm1.internal.js +1 -0
  37. package/dist/generators/psm1.internal.js.map +1 -1
  38. package/dist/generators/psm1.js +2 -1
  39. package/dist/generators/psm1.js.map +1 -1
  40. package/dist/generators/readme.js +1 -0
  41. package/dist/generators/readme.js.map +1 -1
  42. package/dist/generators/script-cmdlet.js +1 -0
  43. package/dist/generators/script-cmdlet.js.map +1 -1
  44. package/dist/internal/name-inferrer.js +1 -0
  45. package/dist/internal/name-inferrer.js.map +1 -1
  46. package/dist/internal/powershell-declarations.d.ts +2 -0
  47. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  48. package/dist/internal/powershell-declarations.js +2 -0
  49. package/dist/internal/powershell-declarations.js.map +1 -1
  50. package/dist/internal/project.d.ts +11 -9
  51. package/dist/internal/project.d.ts.map +1 -1
  52. package/dist/internal/project.js +6 -2
  53. package/dist/internal/project.js.map +1 -1
  54. package/dist/internal/state.js +1 -0
  55. package/dist/internal/state.js.map +1 -1
  56. package/dist/internal/verbs.js +1 -0
  57. package/dist/internal/verbs.js.map +1 -1
  58. package/dist/llcsharp/clientruntime.d.ts +3 -0
  59. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  60. package/dist/llcsharp/clientruntime.js +4 -0
  61. package/dist/llcsharp/clientruntime.js.map +1 -1
  62. package/dist/llcsharp/csharp-declarations.js +1 -0
  63. package/dist/llcsharp/csharp-declarations.js.map +1 -1
  64. package/dist/llcsharp/enums/enum.js +2 -1
  65. package/dist/llcsharp/enums/enum.js.map +1 -1
  66. package/dist/llcsharp/enums/namespace.js +1 -0
  67. package/dist/llcsharp/enums/namespace.js.map +1 -1
  68. package/dist/llcsharp/exports.js +23 -13
  69. package/dist/llcsharp/exports.js.map +1 -1
  70. package/dist/llcsharp/generator.js +1 -0
  71. package/dist/llcsharp/generator.js.map +1 -1
  72. package/dist/llcsharp/messages.js +1 -0
  73. package/dist/llcsharp/messages.js.map +1 -1
  74. package/dist/llcsharp/model/idictionary.js +1 -0
  75. package/dist/llcsharp/model/idictionary.js.map +1 -1
  76. package/dist/llcsharp/model/interface.d.ts.map +1 -1
  77. package/dist/llcsharp/model/interface.js +2 -1
  78. package/dist/llcsharp/model/interface.js.map +1 -1
  79. package/dist/llcsharp/model/model-class-dictionary.js +1 -0
  80. package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
  81. package/dist/llcsharp/model/model-class-json.js +1 -0
  82. package/dist/llcsharp/model/model-class-json.js.map +1 -1
  83. package/dist/llcsharp/model/model-class-serializer.js +1 -0
  84. package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
  85. package/dist/llcsharp/model/model-class.js +10 -9
  86. package/dist/llcsharp/model/model-class.js.map +1 -1
  87. package/dist/llcsharp/model/namespace.js +1 -0
  88. package/dist/llcsharp/model/namespace.js.map +1 -1
  89. package/dist/llcsharp/model/property.js +1 -0
  90. package/dist/llcsharp/model/property.js.map +1 -1
  91. package/dist/llcsharp/operation/api-class.js +1 -0
  92. package/dist/llcsharp/operation/api-class.js.map +1 -1
  93. package/dist/llcsharp/operation/method.d.ts.map +1 -1
  94. package/dist/llcsharp/operation/method.js +20 -27
  95. package/dist/llcsharp/operation/method.js.map +1 -1
  96. package/dist/llcsharp/operation/namespace.js +1 -0
  97. package/dist/llcsharp/operation/namespace.js.map +1 -1
  98. package/dist/llcsharp/operation/parameter.js +1 -0
  99. package/dist/llcsharp/operation/parameter.js.map +1 -1
  100. package/dist/llcsharp/project.d.ts.map +1 -1
  101. package/dist/llcsharp/project.js +3 -1
  102. package/dist/llcsharp/project.js.map +1 -1
  103. package/dist/llcsharp/schema/Uuid.js +1 -0
  104. package/dist/llcsharp/schema/Uuid.js.map +1 -1
  105. package/dist/llcsharp/schema/array.js +1 -0
  106. package/dist/llcsharp/schema/array.js.map +1 -1
  107. package/dist/llcsharp/schema/binary.js +1 -0
  108. package/dist/llcsharp/schema/binary.js.map +1 -1
  109. package/dist/llcsharp/schema/boolean.js +1 -0
  110. package/dist/llcsharp/schema/boolean.js.map +1 -1
  111. package/dist/llcsharp/schema/byte-array.js +1 -0
  112. package/dist/llcsharp/schema/byte-array.js.map +1 -1
  113. package/dist/llcsharp/schema/char.js +1 -0
  114. package/dist/llcsharp/schema/char.js.map +1 -1
  115. package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
  116. package/dist/llcsharp/schema/date-time.js +1 -0
  117. package/dist/llcsharp/schema/date-time.js.map +1 -1
  118. package/dist/llcsharp/schema/date.js +1 -0
  119. package/dist/llcsharp/schema/date.js.map +1 -1
  120. package/dist/llcsharp/schema/duration.js +1 -0
  121. package/dist/llcsharp/schema/duration.js.map +1 -1
  122. package/dist/llcsharp/schema/enum.js +1 -0
  123. package/dist/llcsharp/schema/enum.js.map +1 -1
  124. package/dist/llcsharp/schema/integer.js +1 -0
  125. package/dist/llcsharp/schema/integer.js.map +1 -1
  126. package/dist/llcsharp/schema/object.js +1 -0
  127. package/dist/llcsharp/schema/object.js.map +1 -1
  128. package/dist/llcsharp/schema/password.js +2 -1
  129. package/dist/llcsharp/schema/password.js.map +1 -1
  130. package/dist/llcsharp/schema/primitive.js +1 -0
  131. package/dist/llcsharp/schema/primitive.js.map +1 -1
  132. package/dist/llcsharp/schema/schema-resolver.d.ts +2 -3
  133. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  134. package/dist/llcsharp/schema/schema-resolver.js +4 -0
  135. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  136. package/dist/llcsharp/schema/string.d.ts.map +1 -1
  137. package/dist/llcsharp/schema/string.js +1 -0
  138. package/dist/llcsharp/schema/string.js.map +1 -1
  139. package/dist/llcsharp/schema/uri.d.ts +10 -0
  140. package/dist/llcsharp/schema/uri.d.ts.map +1 -0
  141. package/dist/llcsharp/schema/uri.js +25 -0
  142. package/dist/llcsharp/schema/uri.js.map +1 -0
  143. package/dist/llcsharp/validations.js +1 -0
  144. package/dist/llcsharp/validations.js.map +1 -1
  145. package/dist/main.d.ts.map +1 -1
  146. package/dist/main.js +7 -0
  147. package/dist/main.js.map +1 -1
  148. package/dist/models/model-extensions.js +7 -6
  149. package/dist/models/model-extensions.js.map +1 -1
  150. package/dist/module/module-class.js +1 -0
  151. package/dist/module/module-class.js.map +1 -1
  152. package/dist/module/module-namespace.js +1 -0
  153. package/dist/module/module-namespace.js.map +1 -1
  154. package/dist/plugins/add-azure-completers-v2.js +1 -0
  155. package/dist/plugins/add-azure-completers-v2.js.map +1 -1
  156. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  157. package/dist/plugins/create-commands-v2.js +4 -2
  158. package/dist/plugins/create-commands-v2.js.map +1 -1
  159. package/dist/plugins/cs-namer-v2.js +4 -3
  160. package/dist/plugins/cs-namer-v2.js.map +1 -1
  161. package/dist/plugins/llcsharp-v2.js +1 -0
  162. package/dist/plugins/llcsharp-v2.js.map +1 -1
  163. package/dist/plugins/modifiers-v2.d.ts +4 -0
  164. package/dist/plugins/modifiers-v2.d.ts.map +1 -1
  165. package/dist/plugins/modifiers-v2.js +69 -13
  166. package/dist/plugins/modifiers-v2.js.map +1 -1
  167. package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
  168. package/dist/plugins/plugin-create-inline-properties.js +16 -1
  169. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  170. package/dist/plugins/plugin-tweak-m4-model.js +4 -3
  171. package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
  172. package/dist/plugins/plugin-tweak-model-azure-v2.js +4 -3
  173. package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
  174. package/dist/plugins/plugin-tweak-model.js +15 -14
  175. package/dist/plugins/plugin-tweak-model.js.map +1 -1
  176. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  177. package/dist/plugins/powershell-v2.js +11 -0
  178. package/dist/plugins/powershell-v2.js.map +1 -1
  179. package/dist/plugins/ps-namer-v2.js +1 -0
  180. package/dist/plugins/ps-namer-v2.js.map +1 -1
  181. package/dist/plugins/sdk-cs-namer.d.ts +3 -0
  182. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -0
  183. package/dist/plugins/sdk-cs-namer.js +213 -0
  184. package/dist/plugins/sdk-cs-namer.js.map +1 -0
  185. package/dist/plugins/sdk-generate.d.ts +3 -0
  186. package/dist/plugins/sdk-generate.d.ts.map +1 -0
  187. package/dist/plugins/sdk-generate.js +60 -0
  188. package/dist/plugins/sdk-generate.js.map +1 -0
  189. package/dist/plugins/sdk-tweak-model.d.ts +3 -0
  190. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -0
  191. package/dist/plugins/sdk-tweak-model.js +198 -0
  192. package/dist/plugins/sdk-tweak-model.js.map +1 -0
  193. package/dist/sdk/project.d.ts +44 -0
  194. package/dist/sdk/project.d.ts.map +1 -0
  195. package/dist/sdk/project.js +45 -0
  196. package/dist/sdk/project.js.map +1 -0
  197. package/dist/sdk/state.d.ts +23 -0
  198. package/dist/sdk/state.d.ts.map +1 -0
  199. package/dist/sdk/state.js +28 -0
  200. package/dist/sdk/state.js.map +1 -0
  201. package/dist/sdk/utility.d.ts +5 -0
  202. package/dist/sdk/utility.d.ts.map +1 -0
  203. package/dist/sdk/utility.js +17 -0
  204. package/dist/sdk/utility.js.map +1 -0
  205. package/dist/utils/PwshModel.js +1 -0
  206. package/dist/utils/PwshModel.js.map +1 -1
  207. package/dist/utils/SdkModel.d.ts +7 -0
  208. package/dist/utils/SdkModel.d.ts.map +1 -0
  209. package/dist/utils/SdkModel.js +17 -0
  210. package/dist/utils/SdkModel.js.map +1 -0
  211. package/dist/utils/command-operation.d.ts +1 -0
  212. package/dist/utils/command-operation.d.ts.map +1 -1
  213. package/dist/utils/command-operation.js +2 -2
  214. package/dist/utils/command-operation.js.map +1 -1
  215. package/dist/utils/components.d.ts +2 -0
  216. package/dist/utils/components.d.ts.map +1 -1
  217. package/dist/utils/components.js +1 -0
  218. package/dist/utils/components.js.map +1 -1
  219. package/dist/utils/extensions.js +1 -0
  220. package/dist/utils/extensions.js.map +1 -1
  221. package/dist/utils/http-definitions.js +1 -0
  222. package/dist/utils/http-definitions.js.map +1 -1
  223. package/dist/utils/http-operation.js +1 -0
  224. package/dist/utils/http-operation.js.map +1 -1
  225. package/dist/utils/info.js +1 -0
  226. package/dist/utils/info.js.map +1 -1
  227. package/dist/utils/model-state.js +1 -0
  228. package/dist/utils/model-state.js.map +1 -1
  229. package/dist/utils/powershell-comment.js +11 -10
  230. package/dist/utils/powershell-comment.js.map +1 -1
  231. package/dist/utils/programatic-operation.js +2 -2
  232. package/dist/utils/programatic-operation.js.map +1 -1
  233. package/dist/utils/resolve-conflicts.js +1 -0
  234. package/dist/utils/resolve-conflicts.js.map +1 -1
  235. package/dist/utils/schema.js +1 -0
  236. package/dist/utils/schema.js.map +1 -1
  237. package/dist/utils/security-scheme.js +1 -0
  238. package/dist/utils/security-scheme.js.map +1 -1
  239. package/dist/utils/uid.js +1 -0
  240. package/dist/utils/uid.js.map +1 -1
  241. package/package.json +6 -5
  242. package/readme.md +5 -1
  243. package/resources/psruntime/Attributes/ExternalDocsAttribute.cs +30 -0
  244. package/resources/psruntime/BuildTime/Models/PsMarkdownTypes.cs +39 -4
  245. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +8 -2
  246. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +6 -0
  247. package/resources/runtime/csharp/client/Context.cs +33 -0
  248. package/resources/runtime/csharp/client/InfoAttribute.cs +1 -0
  249. package/resources/runtime/csharp/client/InputHandler.cs +22 -0
  250. package/resources/runtime/csharp/pipeline/Events.cs +2 -2
  251. package/resources/templates/azureMethod.ejs +4 -0
  252. package/resources/templates/azureMethodGroup.ejs +45 -0
  253. package/resources/templates/azureServiceClient.ejs +71 -0
  254. package/resources/templates/extensionMethod.ejs +57 -0
  255. package/resources/templates/extensions.ejs +19 -0
  256. package/resources/templates/method.ejs +46 -0
  257. package/resources/templates/methodBodyRestCall.ejs +183 -0
  258. package/resources/templates/methodGroup.ejs +7 -0
  259. package/resources/templates/methodGroupInterface.ejs +53 -0
  260. package/resources/templates/model.ejs +71 -0
  261. package/resources/templates/serviceClientBody.ejs +305 -0
  262. package/resources/templates/serviceClientInterface.ejs +54 -0
@@ -4,6 +4,8 @@
4
4
  * Licensed under the MIT License. See License.txt in the project root for license information.
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.CmdletClass = exports.NewAddInfoAttribute = exports.addInfoAttribute = exports.addDefaultInfo = exports.addPreviewMessage = exports.addParameterBreakingChange = exports.NewAddCompleterInfo = exports.addCompleterInfo = exports.createStepper = void 0;
8
+ let ejs = require('ejs');
7
9
  const codemodel_1 = require("@azure-tools/codemodel");
8
10
  const codemodel_v3_1 = require("@azure-tools/codemodel-v3");
9
11
  const command_operation_1 = require("../utils/command-operation");
@@ -160,7 +162,7 @@ function NewAddCompleterInfo(targetProperty, parameter) {
160
162
  exports.NewAddCompleterInfo = NewAddCompleterInfo;
161
163
  function addParameterBreakingChange(targetProperty, parameter) {
162
164
  if (parameter.breakingChange) {
163
- var parameters = [];
165
+ const parameters = [];
164
166
  parameters.push(`"${parameter.breakingChange.parameterName}"`);
165
167
  if (parameter.breakingChange.deprecateByVersion) {
166
168
  parameters.push(`"${parameter.breakingChange.deprecateByVersion}"`);
@@ -180,7 +182,7 @@ function addParameterBreakingChange(targetProperty, parameter) {
180
182
  }
181
183
  else {
182
184
  // for primitive types, should use name, otherwise use fullname which contains namespace
183
- parameters.push(`OldParamaterType="${parameter.schema.language.csharp.fullname.startsWith("<") ? parameter.schema.language.csharp.name : parameter.schema.language.csharp.fullname}"`);
185
+ parameters.push(`OldParamaterType="${parameter.schema.language.csharp.fullname.startsWith('<') ? parameter.schema.language.csharp.name : parameter.schema.language.csharp.fullname}"`);
184
186
  }
185
187
  parameters.push(`NewParameterType="${parameter.breakingChange.newParameterType}"`);
186
188
  }
@@ -202,7 +204,8 @@ function addDefaultInfo(targetProperty, parameter) {
202
204
  parameters: [
203
205
  new codegen_csharp_1.LiteralExpression(`\nName = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.name || '').value}`),
204
206
  new codegen_csharp_1.LiteralExpression(`\nDescription =${new codegen_csharp_1.StringExpression(parameter.defaultInfo.description || '').value}`),
205
- new codegen_csharp_1.LiteralExpression(`\nScript = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.script).value}`)
207
+ new codegen_csharp_1.LiteralExpression(`\nScript = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo.script).value}`),
208
+ new codegen_csharp_1.LiteralExpression(`\nSetCondition = ${new codegen_csharp_1.StringExpression(parameter.defaultInfo['set-condition'] || '').value}`)
206
209
  ]
207
210
  }));
208
211
  }
@@ -322,6 +325,7 @@ class CmdletClass extends codegen_csharp_1.Class {
322
325
  this.variantName = variantName;
323
326
  this.hasStreamOutput = false;
324
327
  this.interfaces.push(exports_1.ClientRuntime.IEventListener);
328
+ this.interfaces.push(exports_1.ClientRuntime.IContext);
325
329
  this.eventListener = new exports_1.EventListener(new codegen_csharp_1.LiteralExpression(`((${exports_1.ClientRuntime.IEventListener})this)`), true);
326
330
  this.isViaIdentity = variantName.indexOf('ViaIdentity') > 0;
327
331
  this.clientsidePagination = !!operation.details.csharp.clientsidePagination && !!((_a = operation.callGraph[0].language.csharp) === null || _a === void 0 ? void 0 : _a.pageable);
@@ -338,7 +342,7 @@ class CmdletClass extends codegen_csharp_1.Class {
338
342
  *body() {
339
343
  if ($this.state.project.azure) {
340
344
  yield `var telemetryId = ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.GetTelemetryId.Invoke();`;
341
- yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', "__correlationId = telemetryId;");
345
+ yield codegen_csharp_1.If('telemetryId != "" && telemetryId != "internal"', '__correlationId = telemetryId;');
342
346
  }
343
347
  yield 'Module.Instance.SetProxyConfiguration(Proxy, ProxyCredential, ProxyUseDefaultCredentials);';
344
348
  yield codegen_csharp_1.If($this.$('Break'), `${exports_1.ClientRuntime.AttachDebugger}.Break();`);
@@ -356,6 +360,8 @@ class CmdletClass extends codegen_csharp_1.Class {
356
360
  this.NewAddPowershellParameters(this.operation);
357
361
  // implement IEventListener
358
362
  this.implementIEventListener();
363
+ // implement part of the IContext
364
+ this.implementIContext();
359
365
  // add constructors
360
366
  this.implementConstructors();
361
367
  // processRecord
@@ -380,8 +386,8 @@ class CmdletClass extends codegen_csharp_1.Class {
380
386
  if (!request) {
381
387
  continue;
382
388
  }
383
- const httpMethod = (_c = (_b = request.protocol.http) === null || _b === void 0 ? void 0 : _b.method, (_c !== null && _c !== void 0 ? _c : ''));
384
- const httpPath = (_e = (_d = request.protocol.http) === null || _d === void 0 ? void 0 : _d.path, (_e !== null && _e !== void 0 ? _e : ''));
389
+ const httpMethod = (_c = (_b = request.protocol.http) === null || _b === void 0 ? void 0 : _b.method) !== null && _c !== void 0 ? _c : '';
390
+ const httpPath = (_e = (_d = request.protocol.http) === null || _d === void 0 ? void 0 : _d.path) !== null && _e !== void 0 ? _e : '';
385
391
  ops = `${ops}\n[OpenAPI] ${httpOperation.language.default.name}=>${httpMethod.toUpperCase()}:"${httpPath}"`;
386
392
  if (this.debugMode) {
387
393
  // x-ms-metadata seems no longer exists
@@ -411,7 +417,7 @@ class CmdletClass extends codegen_csharp_1.Class {
411
417
  this.processRecordId = this.add(new codegen_csharp_1.Field('__processRecordId', codegen_csharp_1.dotnet.String, { description: 'A unique id generatd for the this cmdlet when ProcessRecord() is called.', access: codegen_csharp_1.Access.Private }));
412
418
  }
413
419
  // pipeline property
414
- this.add(new codegen_csharp_1.Property('Pipeline', exports_1.ClientRuntime.HttpPipeline, { getAccess: codegen_csharp_1.Access.Private, setAccess: codegen_csharp_1.Access.Private, description: `The instance of the <see cref="${exports_1.ClientRuntime.HttpPipeline}" /> that the remote call will use.` }));
420
+ this.add(new codegen_csharp_1.Property('Pipeline', exports_1.ClientRuntime.HttpPipeline, { getAccess: codegen_csharp_1.Access.Public, setAccess: codegen_csharp_1.Access.Public, description: `The instance of the <see cref="${exports_1.ClientRuntime.HttpPipeline}" /> that the remote call will use.` }));
415
421
  // client API property (gs01: fill this in correctly)
416
422
  const clientAPI = new codegen_csharp_1.ClassType((_a = this.state.model.language.csharp) === null || _a === void 0 ? void 0 : _a.namespace, ((_b = this.state.model.language.csharp) === null || _b === void 0 ? void 0 : _b.name) || '');
417
423
  this.add(new codegen_csharp_1.LambdaProperty('Client', clientAPI, new codegen_csharp_1.LiteralExpression(`${this.state.project.serviceNamespace.moduleClass.declaration}.Instance.ClientAPI`), { description: 'The reference to the client API class.' }));
@@ -563,14 +569,37 @@ class CmdletClass extends codegen_csharp_1.Class {
563
569
  yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletGetPipeline);
564
570
  const pipeline = $this.$('Pipeline');
565
571
  if ($this.state.project.azure) {
566
- yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName)`));
572
+ yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, ${$this.correlationId}, ${$this.processRecordId}, this.ParameterSetName, this.ExtensibleParameters)`));
567
573
  }
568
574
  else {
569
- yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName)`));
575
+ yield pipeline.assign(new codegen_csharp_1.LiteralExpression(`${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.CreatePipeline(${$this.invocationInfo}, this.ParameterSetName, this.ExtensibleParameters)`));
570
576
  }
571
577
  yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelinePrepend')), pipeline.invokeMethod('Prepend', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelinePrepend')}) ?? ${$this.$('HttpPipelinePrepend')}`)));
572
578
  yield codegen_csharp_1.If(codegen_csharp_1.IsNotNull($this.$('HttpPipelineAppend')), pipeline.invokeMethod('Append', codegen_csharp_1.toExpression(`(this.CommandRuntime as Microsoft.Rest.ClientRuntime.PowerShell.IAsyncCommandRuntimeExtensions)?.Wrap(${$this.$('HttpPipelineAppend')}) ?? ${$this.$('HttpPipelineAppend')}`)));
573
579
  yield '// get the client instance';
580
+ // Add input pipeline if it is configured by developers.
581
+ if ($this.operation.extensions.inputPipe) {
582
+ const handlers = $this.operation.extensions.inputPipe;
583
+ // default priority is 100
584
+ handlers.sort((a, b) => { return (a.priority || 100) - (b.priority || 100); });
585
+ for (const { index, handler } of handlers.map((handler, index) => ({ index, handler }))) {
586
+ yield `var handler_${index} = new ${handler.name}();`;
587
+ if (index > 0) {
588
+ yield `handler_${index - 1}.SetNextHandler(handler_${index});`;
589
+ }
590
+ }
591
+ yield 'handler_0.Process(this);';
592
+ }
593
+ const vps = $this.operation.details.csharp.virtualParameters || {
594
+ body: [],
595
+ operation: [],
596
+ };
597
+ for (const vParam of [...vps.body, ...vps.operation]) {
598
+ if (vParam.hidden) {
599
+ const td = $this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vParam.schema, true, $this.state);
600
+ yield codegen_csharp_1.If(`true == this.MyInvocation?.BoundParameters?.ContainsKey("${vParam.name}")`, `${vParam.name} = (${td.declaration})this.MyInvocation.BoundParameters["${vParam.name}"];`);
601
+ }
602
+ }
574
603
  const apiCall = operation.callGraph[0];
575
604
  // find each parameter to the method, and find out where the value is going to come from.
576
605
  const operationParameters = linq_1.values(apiCall.parameters).
@@ -626,7 +655,7 @@ class CmdletClass extends codegen_csharp_1.Class {
626
655
  parameters.push(new codegen_csharp_1.Parameter('headers', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: each.language.csharp.headerType }), { description: `the header result as a <see cref="${each.language.csharp.headerType}" /> from the remote call` }));
627
656
  }
628
657
  if (isBinary) {
629
- parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description: `the body result as a <see cref="global::System.IO.Stream" /> from the remote call` }));
658
+ parameters.push(new codegen_csharp_1.Parameter('response', codegen_csharp_1.System.Threading.Tasks.Task({ declaration: 'global::System.IO.Stream' }), { description: 'the body result as a <see cref="global::System.IO.Stream" /> from the remote call' }));
630
659
  }
631
660
  const override = `override${codegen_1.pascalCase(((_f = each.language.csharp) === null || _f === void 0 ? void 0 : _f.name) || '')}`;
632
661
  const returnNow = new codegen_csharp_1.Parameter('returnNow', codegen_csharp_1.System.Threading.Tasks.Task(codegen_csharp_1.dotnet.Bool), { modifier: codegen_csharp_2.ParameterModifier.Ref, description: `/// Determines if the rest of the ${(_g = each.language.csharp) === null || _g === void 0 ? void 0 : _g.name} method should be processed, or if the method should return immediately (set to true to skip further processing )` });
@@ -728,15 +757,15 @@ class CmdletClass extends codegen_csharp_1.Class {
728
757
  const vp = schema_1.getVirtualPropertyFromPropertyName((_m = schema.language.csharp) === null || _m === void 0 ? void 0 : _m.virtualProperties, valueProperty.serializedName);
729
758
  if (vp) {
730
759
  if ($this.clientsidePagination) {
731
- yield (codegen_csharp_1.If(`(ulong)result.Value.Length <= this.PagingParameters.Skip`, function* () {
732
- yield (`this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Length;`);
760
+ yield (codegen_csharp_1.If('(ulong)result.Value.Length <= this.PagingParameters.Skip', function* () {
761
+ yield ('this.PagingParameters.Skip = this.PagingParameters.Skip - (ulong)result.Value.Length;');
733
762
  }));
734
763
  yield codegen_csharp_1.Else(function* () {
735
- yield (`ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Length - this.PagingParameters.Skip);`);
736
- yield (`var requiredResult = result.Value.SubArray((int)this.PagingParameters.Skip, (int)toRead);`);
737
- yield (`WriteObject(requiredResult, true);`);
738
- yield (`this.PagingParameters.Skip = 0;`);
739
- yield (`this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;`);
764
+ yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Length - this.PagingParameters.Skip);');
765
+ yield ('var requiredResult = result.Value.SubArray((int)this.PagingParameters.Skip, (int)toRead);');
766
+ yield ('WriteObject(requiredResult, true);');
767
+ yield ('this.PagingParameters.Skip = 0;');
768
+ yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
740
769
  });
741
770
  }
742
771
  else {
@@ -747,18 +776,18 @@ class CmdletClass extends codegen_csharp_1.Class {
747
776
  if (nl) {
748
777
  $this.add(new codegen_csharp_1.Field('_isFirst', codegen_csharp_1.dotnet.Bool, {
749
778
  access: codegen_csharp_1.Access.Private,
750
- initialValue: new codegen_csharp_1.LiteralExpression(`true`),
751
- description: `A flag to tell whether it is the first onOK call.`
779
+ initialValue: new codegen_csharp_1.LiteralExpression('true'),
780
+ description: 'A flag to tell whether it is the first onOK call.'
752
781
  }));
753
782
  $this.add(new codegen_csharp_1.Field('_nextLink', codegen_csharp_1.dotnet.String, {
754
783
  access: codegen_csharp_1.Access.Private,
755
- description: `Link to retrieve next page.`
784
+ description: 'Link to retrieve next page.'
756
785
  }));
757
786
  const nextLinkName = `${result.value}.${nl.name}`;
758
787
  yield `_nextLink = ${nextLinkName};`;
759
- var nextLinkCondition = $this.clientsidePagination ? `_nextLink != null && this.PagingParameters.First > 0` : `_nextLink != null`;
760
- yield (codegen_csharp_1.If(`_isFirst`, function* () {
761
- yield `_isFirst = false;`;
788
+ const nextLinkCondition = $this.clientsidePagination ? '_nextLink != null && this.PagingParameters.First > 0' : '_nextLink != null';
789
+ yield (codegen_csharp_1.If('_isFirst', function* () {
790
+ yield '_isFirst = false;';
762
791
  yield (codegen_csharp_1.While(nextLinkCondition, codegen_csharp_1.If('responseMessage.RequestMessage is System.Net.Http.HttpRequestMessage requestMessage ', function* () {
763
792
  var _a;
764
793
  yield `requestMessage = requestMessage.Clone(new global::System.Uri( _nextLink ),${exports_1.ClientRuntime.Method.Get} );`;
@@ -824,21 +853,21 @@ class CmdletClass extends codegen_csharp_1.Class {
824
853
  }
825
854
  // in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
826
855
  if ('binary' in each) {
827
- yield `// (await response) // should be global::System.IO.Stream`;
856
+ yield '// (await response) // should be global::System.IO.Stream';
828
857
  if ($this.hasStreamOutput && $this.outFileParameter) {
829
858
  const outfile = $this.outFileParameter;
830
859
  const provider = codegen_csharp_2.Local('provider');
831
860
  provider.initializer = undefined;
832
- const paths = codegen_csharp_2.Local('paths', `new global::System.Collections.ObjectModel.Collection<global::System.String>()`);
861
+ const paths = codegen_csharp_2.Local('paths', 'new global::System.Collections.ObjectModel.Collection<global::System.String>()');
833
862
  yield paths.declarationStatement;
834
863
  yield codegen_csharp_1.Try(function* () {
835
864
  yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
836
865
  yield codegen_csharp_1.If(`${provider.value}.Name != "FileSystem" || ${paths.value}.Count == 0`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Invalid output path."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
837
866
  yield codegen_csharp_1.If(`${paths.value}.Count > 1`, `ThrowTerminatingError( new System.Management.Automation.ErrorRecord(new global::System.Exception("Multiple output paths not allowed."),string.Empty, global::System.Management.Automation.ErrorCategory.InvalidArgument, ${outfile.value}) );`);
838
867
  });
839
- const notfound = new codegen_csharp_1.Parameter('', { declaration: `global::System.Management.Automation.ItemNotFoundException` });
868
+ const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
840
869
  yield codegen_csharp_1.Catch(notfound, function* () {
841
- yield `// If the file does not exist, we will try to create it`;
870
+ yield '// If the file does not exist, we will try to create it';
842
871
  yield `${paths.value}.Add(${outfile.value});`;
843
872
  });
844
873
  // this is a stream output. write to outfile
@@ -868,7 +897,7 @@ class CmdletClass extends codegen_csharp_1.Class {
868
897
  yield $this.eventListener.signal(powershell_declarations_1.Events.CmdletBeforeAPICall);
869
898
  const idOpParams = operationParameters.filter(each => !each.isPathParam);
870
899
  const idschema = linq_1.values($this.state.project.model.schemas.objects).first(each => each.language.default.uid === 'universal-parameter-type');
871
- var serializationMode = null;
900
+ let serializationMode = null;
872
901
  if ($this.bodyParameter) {
873
902
  if ($this.operation.operationType === command_operation_1.OperationType.Create) {
874
903
  serializationMode = exports_1.ClientRuntime.SerializationMode.IncludeCreate;
@@ -905,10 +934,10 @@ class CmdletClass extends codegen_csharp_1.Class {
905
934
  };
906
935
  }
907
936
  // fall back!
908
- console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${codegen_1.pascalCase((_b = (_a = match.language.csharp) === null || _a === void 0 ? void 0 : _a.name, (_b !== null && _b !== void 0 ? _b : '')))}').`);
937
+ console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${codegen_1.pascalCase((_b = (_a = match.language.csharp) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '')}').`);
909
938
  return {
910
- name: `InputObject.${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name, (_d !== null && _d !== void 0 ? _d : '')))}`,
911
- value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name, (_f !== null && _f !== void 0 ? _f : '')))} ?? ${defaultOfType}`
939
+ name: `InputObject.${codegen_1.pascalCase((_d = (_c = match.language.csharp) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : '')}`,
940
+ value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')} ?? ${defaultOfType}`
912
941
  };
913
942
  }
914
943
  console.error(`Unable to match idenity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
@@ -926,8 +955,8 @@ class CmdletClass extends codegen_csharp_1.Class {
926
955
  }
927
956
  };
928
957
  if (idschema && linq_1.values(idschema.properties).first(each => { var _a; return ((_a = each.language.csharp) === null || _a === void 0 ? void 0 : _a.uid) === 'universal-parameter:resource identity'; })) {
929
- var parameters = [codegen_csharp_1.toExpression('InputObject.Id'), ...idOpParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
930
- if (!!serializationMode) {
958
+ const parameters = [codegen_csharp_1.toExpression('InputObject.Id'), ...idOpParams.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
959
+ if (serializationMode) {
931
960
  parameters.push(serializationMode);
932
961
  }
933
962
  yield codegen_csharp_1.If('InputObject?.Id != null', `await this.${$this.$('Client').invokeMethod(`${(_a = apiCall.language.csharp) === null || _a === void 0 ? void 0 : _a.name}ViaIdentity`, ...parameters).implementation}`);
@@ -938,8 +967,8 @@ class CmdletClass extends codegen_csharp_1.Class {
938
967
  }
939
968
  }
940
969
  else {
941
- var parameters = [...operationParameters.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
942
- if (!!serializationMode) {
970
+ const parameters = [...operationParameters.map(each => each.expression), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline];
971
+ if (serializationMode) {
943
972
  parameters.push(serializationMode);
944
973
  }
945
974
  yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...parameters).implementation}`;
@@ -1002,6 +1031,16 @@ class CmdletClass extends codegen_csharp_1.Class {
1002
1031
  // default constructor
1003
1032
  this.add(new codegen_csharp_1.Constructor(this, { description: `Intializes a new instance of the <see cref="${this.name}" /> cmdlet class.` }));
1004
1033
  }
1034
+ implementIContext() {
1035
+ const extensibleParameters = this.add(new codegen_csharp_1.Field('_extensibleParameters', codegen_csharp_1.System.Collections.Generic.Dictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), {
1036
+ access: codegen_csharp_1.Access.Private,
1037
+ initialValue: new codegen_csharp_1.LiteralExpression('new System.Collections.Generic.Dictionary<string, object>()'),
1038
+ description: 'A dictionary to carry over additional data for pipeline.'
1039
+ }));
1040
+ const extensibleParametersProp = new codegen_csharp_1.Property('ExtensibleParameters', codegen_csharp_1.System.Collections.Generic.IDictionary(codegen_csharp_1.System.String, codegen_csharp_1.System.Object), { description: 'Accessor for extensibleParameters.' });
1041
+ extensibleParametersProp.get = codegen_csharp_1.toExpression(`${extensibleParameters.value} `);
1042
+ this.add(extensibleParametersProp);
1043
+ }
1005
1044
  implementIEventListener() {
1006
1045
  const $this = this;
1007
1046
  const cts = this.add(new codegen_csharp_1.Field('_cancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, {
@@ -1009,6 +1048,10 @@ class CmdletClass extends codegen_csharp_1.Class {
1009
1048
  initialValue: new codegen_csharp_1.LiteralExpression(`new ${codegen_csharp_1.System.Threading.CancellationTokenSource.declaration}()`),
1010
1049
  description: `The <see cref="${codegen_csharp_1.System.Threading.CancellationTokenSource}" /> for this operation.`
1011
1050
  }));
1051
+ const cancellationTokenSource = new codegen_csharp_1.Property('CancellationTokenSource', codegen_csharp_1.System.Threading.CancellationTokenSource, { description: 'Accessor for cancellationTokenSource.' });
1052
+ cancellationTokenSource.get = codegen_csharp_1.toExpression(`${cts.value} `);
1053
+ cancellationTokenSource.set = new codegen_csharp_1.Statements(cts.assign('value'));
1054
+ this.add(cancellationTokenSource);
1012
1055
  this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Token`, codegen_csharp_1.System.Threading.CancellationToken, new codegen_csharp_1.LiteralExpression(`${cts.value}.Token`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation token.` }));
1013
1056
  this.cancellationToken = codegen_csharp_1.toExpression(`((${exports_1.ClientRuntime.IEventListener})this).Token`);
1014
1057
  this.add(new codegen_csharp_1.LambdaProperty(`${exports_1.ClientRuntime.IEventListener}.Cancel`, codegen_csharp_1.System.Action(), new codegen_csharp_1.LiteralExpression(`${cts.value}.Cancel`), { getAccess: codegen_csharp_1.Access.Default, setAccess: codegen_csharp_1.Access.Default, description: `<see cref="${exports_1.ClientRuntime}.IEventListener" /> cancellation delegate. Stops the cmdlet when called.` }));
@@ -1055,12 +1098,20 @@ class CmdletClass extends codegen_csharp_1.Class {
1055
1098
  yield 'WriteError(new global::System.Management.Automation.ErrorRecord( new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null ) );';
1056
1099
  yield codegen_csharp_1.Return();
1057
1100
  }),
1101
+ codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Progress.value, function* () {
1102
+ // hardcode id = 1 because there is no need for nested progress bar
1103
+ yield `WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")`;
1104
+ yield '{';
1105
+ yield ' PercentComplete = 0'; // hardcode 0 because polling has not started
1106
+ yield '});';
1107
+ yield codegen_csharp_1.Return();
1108
+ }),
1058
1109
  ]);
1059
1110
  if ($this.operation.asjob) {
1060
1111
  // if we support -AsJob, we support -NoWait
1061
1112
  sw.add(codegen_csharp_1.Case(powershell_declarations_1.Events.DelayBeforePolling.value, function* () {
1113
+ yield 'var data = messageData();';
1062
1114
  yield codegen_csharp_1.If('true == MyInvocation?.BoundParameters?.ContainsKey("NoWait")', function* () {
1063
- yield 'var data = messageData();';
1064
1115
  yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
1065
1116
  yield '{';
1066
1117
  yield ' var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation");';
@@ -1072,6 +1123,22 @@ class CmdletClass extends codegen_csharp_1.Class {
1072
1123
  yield ' return;';
1073
1124
  yield '}';
1074
1125
  });
1126
+ yield codegen_csharp_1.Else(function* () {
1127
+ yield 'if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)';
1128
+ yield '{';
1129
+ yield ' int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);';
1130
+ yield ' WriteDebug($"Delaying {delay} seconds before polling.");';
1131
+ yield ' for (var now = 0; now < delay; ++now)';
1132
+ yield ' {';
1133
+ // hardcode id = 1 because there is no need for nested progress bar
1134
+ yield ` WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")`;
1135
+ yield ' {';
1136
+ yield ' PercentComplete = now * 100 / delay';
1137
+ yield ' });';
1138
+ yield ` await global::System.Threading.Tasks.Task.Delay(1000, ${token.use});`;
1139
+ yield ' }';
1140
+ yield '}';
1141
+ });
1075
1142
  }));
1076
1143
  }
1077
1144
  // the whole switch statement
@@ -1142,7 +1209,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1142
1209
  }
1143
1210
  if (this.dropBodyParameter && parameter.details.csharp.isBodyParameter) {
1144
1211
  // we're supposed to use parameters for the body parameter instead of a big object
1145
- const expandedBodyParameter = this.add(new codegen_csharp_1.Field("_" + codegen_1.camelCase(parameter.details.csharp.name), td, {
1212
+ const expandedBodyParameter = this.add(new codegen_csharp_1.Field('_' + codegen_1.camelCase(parameter.details.csharp.name), td, {
1146
1213
  description: parameter.details.csharp.description,
1147
1214
  initialValue: (parameter.schema.type === codemodel_1.SchemaType.Array) ? codegen_csharp_1.dotnet.Null : `new ${(_a = parameter.schema.language.csharp) === null || _a === void 0 ? void 0 : _a.fullname}()`,
1148
1215
  access: codegen_csharp_1.Access.Private
@@ -1228,7 +1295,6 @@ class CmdletClass extends codegen_csharp_1.Class {
1228
1295
  this.addDoNotExport(cmdletParameter, vParam);
1229
1296
  }
1230
1297
  const isEnum = propertyType instanceof exports_1.EnumImplementation;
1231
- ;
1232
1298
  const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
1233
1299
  if (isEnum || hasEnum) {
1234
1300
  cmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
@@ -1286,52 +1352,65 @@ class CmdletClass extends codegen_csharp_1.Class {
1286
1352
  // skip 'Host'
1287
1353
  continue;
1288
1354
  }
1289
- const vSchema = vParam.schema;
1290
- const propertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state);
1291
- const origin = vParam.origin;
1292
- const regularCmdletParameter = (this.state.project.azure && vParam.name === 'SubscriptionId' && operation.details.csharp.verb.toLowerCase() === 'get') ?
1293
- // special case for subscription id
1294
- this.add(new codegen_csharp_1.BackedProperty(vParam.name, codegen_csharp_1.dotnet.StringArray, {
1295
- metadata: {
1296
- parameterDefinition: origin.details.csharp.httpParameter
1297
- },
1298
- description: vParam.description
1299
- })) :
1300
- // everything else
1301
- this.add(new codegen_csharp_1.BackedProperty(vParam.name, propertyType, {
1302
- metadata: {
1303
- parameterDefinition: origin.details.csharp.httpParameter
1304
- },
1355
+ let regularCmdletParameter;
1356
+ let origin = null;
1357
+ let propertyType = null;
1358
+ if (vParam.type) {
1359
+ // Handle parameters added through directives
1360
+ regularCmdletParameter = this.add(new codegen_csharp_1.BackedProperty(vParam.name, new codegen_csharp_1.ClassType('', vParam.type), {
1305
1361
  description: vParam.description
1306
1362
  }));
1307
- const dictSchema = vSchema.type === codemodel_1.SchemaType.Dictionary ? vSchema :
1308
- vSchema.type === codemodel_1.SchemaType.Object ? (_j = (_h = vSchema.parents) === null || _h === void 0 ? void 0 : _h.immediate) === null || _j === void 0 ? void 0 : _j.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
1309
- undefined;
1310
- if (dictSchema) {
1311
- // we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
1312
- // if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
1313
- // if it's a standalone dictionary, we can just use hashtable instead
1314
- if (linq_1.length(vSchema.properties) === 0) {
1315
- // it's a pure dictionary
1316
- // change the property type to hashtable.
1317
- // add an attribute to change the exported type.
1318
- regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
1319
- }
1320
- else {
1321
- // it's a hybrid. We need to add an additional property that puts its items into the target container
1363
+ }
1364
+ else {
1365
+ const vSchema = vParam.schema;
1366
+ propertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state);
1367
+ origin = vParam.origin;
1368
+ regularCmdletParameter = (this.state.project.azure && vParam.name === 'SubscriptionId' && operation.details.csharp.verb.toLowerCase() === 'get') ?
1369
+ // special case for subscription id
1370
+ this.add(new codegen_csharp_1.BackedProperty(vParam.name, codegen_csharp_1.dotnet.StringArray, {
1371
+ metadata: {
1372
+ parameterDefinition: origin.details.csharp.httpParameter
1373
+ },
1374
+ description: vParam.description
1375
+ })) :
1376
+ // everything else
1377
+ this.add(new codegen_csharp_1.BackedProperty(vParam.name, propertyType, {
1378
+ metadata: {
1379
+ parameterDefinition: origin.details.csharp.httpParameter
1380
+ },
1381
+ description: vParam.description
1382
+ }));
1383
+ const dictSchema = vSchema.type === codemodel_1.SchemaType.Dictionary ? vSchema :
1384
+ vSchema.type === codemodel_1.SchemaType.Object ? (_j = (_h = vSchema.parents) === null || _h === void 0 ? void 0 : _h.immediate) === null || _j === void 0 ? void 0 : _j.find((s) => s.type === codemodel_1.SchemaType.Dictionary) :
1385
+ undefined;
1386
+ if (dictSchema) {
1387
+ // we have to figure out if this is a standalone dictionary or a hybrid object/dictionary.
1388
+ // if it's a hybrid, we have to create another parameter like -<XXX>AdditionalProperties and have that dump the contents into the dictionary
1389
+ // if it's a standalone dictionary, we can just use hashtable instead
1390
+ if (linq_1.length(vSchema.properties) === 0) {
1391
+ // it's a pure dictionary
1392
+ // change the property type to hashtable.
1393
+ // add an attribute to change the exported type.
1394
+ regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExportAsAttribute, { parameters: [`typeof(${codegen_csharp_1.System.Collections.Hashtable})`] }));
1395
+ }
1396
+ else {
1397
+ // it's a hybrid. We need to add an additional property that puts its items into the target container
1398
+ }
1322
1399
  }
1323
1400
  }
1324
1401
  this.thingsToSerialize.push(regularCmdletParameter);
1325
1402
  const parameters = [new codegen_csharp_1.LiteralExpression(`Mandatory = ${vParam.required ? 'true' : 'false'}`), new codegen_csharp_1.LiteralExpression(`HelpMessage = "${codegen_1.escapeString(vParam.description) || '.'}"`)];
1326
- if (origin.details.csharp.isBodyParameter) {
1403
+ if (!!origin && origin.details.csharp.isBodyParameter) {
1327
1404
  parameters.push(new codegen_csharp_1.LiteralExpression('ValueFromPipeline = true'));
1328
1405
  this.bodyParameter = regularCmdletParameter;
1329
1406
  }
1330
1407
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ParameterAttribute, { parameters }));
1331
- if (vParam.schema.type === codemodel_1.SchemaType.Array) {
1408
+ if (!vParam.type && vParam.schema.type === codemodel_1.SchemaType.Array) {
1332
1409
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.AllowEmptyCollectionAttribute));
1333
1410
  }
1334
- NewAddInfoAttribute(regularCmdletParameter, propertyType, (_k = vParam.required, (_k !== null && _k !== void 0 ? _k : false)), false, vParam.description, origin.name);
1411
+ if (!!origin && !!propertyType) {
1412
+ NewAddInfoAttribute(regularCmdletParameter, propertyType, (_k = vParam.required) !== null && _k !== void 0 ? _k : false, false, vParam.description, origin.name);
1413
+ }
1335
1414
  NewAddCompleterInfo(regularCmdletParameter, vParam);
1336
1415
  addParameterBreakingChange(regularCmdletParameter, vParam);
1337
1416
  addPreviewMessage(regularCmdletParameter, vParam);
@@ -1341,7 +1420,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1341
1420
  if (linq_1.length(vParam.alias) > 0) {
1342
1421
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.Alias, { parameters: vParam.alias.map(x => '"' + x + '"') }));
1343
1422
  }
1344
- const httpParam = origin.details.csharp.httpParameter;
1423
+ const httpParam = origin ? origin.details.csharp.httpParameter : null;
1345
1424
  //const uid = httpParam ? httpParam.details.csharp.uid : 'no-parameter';
1346
1425
  if (httpParam) {
1347
1426
  // xichen: Is it safe to compare by csharp serializedName? Because we no longer have uid
@@ -1350,13 +1429,9 @@ class CmdletClass extends codegen_csharp_1.Class {
1350
1429
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.${codegen_1.pascalCase(((_m = cat.protocol.http) === null || _m === void 0 ? void 0 : _m.in))}`] }));
1351
1430
  }
1352
1431
  }
1353
- if (origin.details.csharp.completer) {
1354
- // add the completer to this class and tag this parameter with the completer.
1355
- // regularCmdletParameter.add(new Attribute(ArgumentCompleterAttribute, { parameters: [`typeof(${this.declaration})`] }));
1356
- }
1357
1432
  const isEnum = propertyType instanceof exports_1.EnumImplementation;
1358
1433
  const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
1359
- if (isEnum || hasEnum) {
1434
+ if (propertyType && (isEnum || hasEnum)) {
1360
1435
  regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ArgumentCompleterAttribute, { parameters: [`typeof(${hasEnum ? propertyType.elementType.declaration : propertyType.declaration})`] }));
1361
1436
  }
1362
1437
  }
@@ -1381,7 +1456,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1381
1456
  }
1382
1457
  }
1383
1458
  NewAddClassAttributes(operation, variantName) {
1384
- var _a, _b, _c, _d;
1459
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1385
1460
  const cmdletAttribParams = [
1386
1461
  category[operation.details.csharp.verb] ? powershell_declarations_1.verbEnum(category[operation.details.csharp.verb], operation.details.csharp.verb) : `"${operation.details.csharp.verb}"`,
1387
1462
  new codegen_csharp_1.StringExpression(variantName)
@@ -1473,9 +1548,9 @@ class CmdletClass extends codegen_csharp_1.Class {
1473
1548
  }
1474
1549
  //add breaking change attributes for cmdlet, variant, output type
1475
1550
  if (operation.details.csharp.breakingChange) {
1476
- var breakingChange = operation.details.csharp.breakingChange;
1551
+ const breakingChange = operation.details.csharp.breakingChange;
1477
1552
  if (breakingChange.cmdlet) {
1478
- var parameters = [];
1553
+ const parameters = [];
1479
1554
  if (breakingChange.cmdlet.deprecateByVersion) {
1480
1555
  parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
1481
1556
  if (breakingChange.cmdlet.changeInEfectByDate)
@@ -1488,7 +1563,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1488
1563
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.CmdletBreakingChangeAttribute, { parameters: parameters }));
1489
1564
  }
1490
1565
  if (breakingChange.variant) {
1491
- var parameters = [];
1566
+ const parameters = [];
1492
1567
  parameters.push(`new string[] {"${breakingChange.variant.name}"}`);
1493
1568
  if (breakingChange.variant.deprecateByVersion) {
1494
1569
  parameters.push(`"${breakingChange.variant.deprecateByVersion}"`);
@@ -1500,13 +1575,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1500
1575
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
1501
1576
  }
1502
1577
  if (breakingChange.output) {
1503
- var parameters = [];
1578
+ const parameters = [];
1504
1579
  // if deprecated output types are set in directive, use it
1505
1580
  if (breakingChange.output.deprecatedCmdLetOutputType) {
1506
1581
  parameters.push(`"${breakingChange.output.deprecatedCmdLetOutputType}"`);
1507
1582
  }
1508
1583
  else {
1509
- parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, "$1")}"`);
1584
+ parameters.push(`"${outputTypes.values().next().value.replace(/typeof\((.*)\)/, '$1')}"`);
1510
1585
  }
1511
1586
  if (breakingChange.output.deprecateByVersion) {
1512
1587
  parameters.push(`"${breakingChange.output.deprecateByVersion}"`);
@@ -1516,12 +1591,12 @@ class CmdletClass extends codegen_csharp_1.Class {
1516
1591
  if (breakingChange.output.replacement)
1517
1592
  parameters.push(`ReplacementCmdletOutputType="${breakingChange.output.replacement}"`);
1518
1593
  if (breakingChange.output.deprecatedOutputProperties) {
1519
- var properties = Object.assign([], breakingChange.output.deprecatedOutputProperties);
1594
+ const properties = Object.assign([], breakingChange.output.deprecatedOutputProperties);
1520
1595
  properties.forEach((element, index) => properties[index] = '"' + element + '"');
1521
1596
  parameters.push(`DeprecatedOutputProperties=new string[] {${properties.join(',')}}`);
1522
1597
  }
1523
1598
  if (breakingChange.output.newOutputProperties) {
1524
- var properties = Object.assign([], breakingChange.output.newOutputProperties);
1599
+ const properties = Object.assign([], breakingChange.output.newOutputProperties);
1525
1600
  properties.forEach((element, index) => properties[index] = '"' + element + '"');
1526
1601
  parameters.push(`NewOutputProperties=new string[] {${properties.join(',')}}`);
1527
1602
  }
@@ -1541,6 +1616,13 @@ class CmdletClass extends codegen_csharp_1.Class {
1541
1616
  passThru.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, { parameters: [`${powershell_declarations_1.ParameterCategory}.Runtime`] }));
1542
1617
  }
1543
1618
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.DescriptionAttribute, { parameters: [new codegen_csharp_1.StringExpression(this.description)] }));
1619
+ // If defines externalDocs for operation
1620
+ if (operation.details.default.externalDocs) {
1621
+ this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ExternalDocsAttribute, {
1622
+ parameters: [`${new codegen_csharp_1.StringExpression((_f = (_e = this.operation.details.default.externalDocs) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : "")}`,
1623
+ `${new codegen_csharp_1.StringExpression((_h = (_g = this.operation.details.default.externalDocs) === null || _g === void 0 ? void 0 : _g.description) !== null && _h !== void 0 ? _h : "")}`]
1624
+ }));
1625
+ }
1544
1626
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.GeneratedAttribute));
1545
1627
  if (operation.extensions && operation.extensions['x-ms-metadata'] && operation.extensions['x-ms-metadata'].profiles) {
1546
1628
  const profileNames = Object.keys(operation.extensions && operation.extensions['x-ms-metadata'].profiles);