@autorest/powershell 4.0.0-dev.6 → 4.0.0-dev.8

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 (138) hide show
  1. package/.rush/temp/package-deps_build.json +70 -60
  2. package/.rush/temp/shrinkwrap-deps.json +2 -2
  3. package/autorest-configuration-for-sdk.md +14 -2
  4. package/autorest-configuration.md +2 -1
  5. package/dist/cmdlets/class.d.ts +3 -0
  6. package/dist/cmdlets/class.d.ts.map +1 -1
  7. package/dist/cmdlets/class.js +157 -33
  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 +1 -0
  11. package/dist/cmdlets/namespace.js.map +1 -1
  12. package/dist/generators/psm1.js +1 -1
  13. package/dist/generators/script-cmdlet.js +1 -1
  14. package/dist/internal/powershell-declarations.d.ts +1 -0
  15. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  16. package/dist/internal/powershell-declarations.js +2 -1
  17. package/dist/internal/powershell-declarations.js.map +1 -1
  18. package/dist/internal/project.d.ts +10 -2
  19. package/dist/internal/project.d.ts.map +1 -1
  20. package/dist/internal/project.js +31 -14
  21. package/dist/internal/project.js.map +1 -1
  22. package/dist/llcsharp/clientruntime.d.ts +1 -0
  23. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  24. package/dist/llcsharp/clientruntime.js +1 -0
  25. package/dist/llcsharp/clientruntime.js.map +1 -1
  26. package/dist/llcsharp/code-model.d.ts +1 -0
  27. package/dist/llcsharp/code-model.d.ts.map +1 -1
  28. package/dist/llcsharp/csharp-declarations.d.ts +1 -0
  29. package/dist/llcsharp/csharp-declarations.d.ts.map +1 -1
  30. package/dist/llcsharp/csharp-declarations.js +2 -1
  31. package/dist/llcsharp/csharp-declarations.js.map +1 -1
  32. package/dist/llcsharp/model/model-class.d.ts.map +1 -1
  33. package/dist/llcsharp/model/model-class.js +27 -11
  34. package/dist/llcsharp/model/model-class.js.map +1 -1
  35. package/dist/llcsharp/operation/method.js +2 -1
  36. package/dist/llcsharp/operation/method.js.map +1 -1
  37. package/dist/llcsharp/schema/array.js +7 -7
  38. package/dist/llcsharp/schema/array.js.map +1 -1
  39. package/dist/llcsharp/schema/fixed-array.d.ts +42 -0
  40. package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -0
  41. package/dist/llcsharp/schema/fixed-array.js +251 -0
  42. package/dist/llcsharp/schema/fixed-array.js.map +1 -0
  43. package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
  44. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  45. package/dist/llcsharp/schema/schema-resolver.js +9 -2
  46. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  47. package/dist/main.d.ts.map +1 -1
  48. package/dist/main.js +4 -0
  49. package/dist/main.js.map +1 -1
  50. package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
  51. package/dist/plugins/cs-namer-v2.js +10 -7
  52. package/dist/plugins/cs-namer-v2.js.map +1 -1
  53. package/dist/plugins/plugin-create-inline-properties.js +1 -1
  54. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  55. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  56. package/dist/plugins/powershell-v2.js +5 -10
  57. package/dist/plugins/powershell-v2.js.map +1 -1
  58. package/dist/plugins/sdk-create-inline-properties.d.ts +4 -0
  59. package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -0
  60. package/dist/plugins/sdk-create-inline-properties.js +552 -0
  61. package/dist/plugins/sdk-create-inline-properties.js.map +1 -0
  62. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
  63. package/dist/plugins/sdk-cs-namer.js +186 -14
  64. package/dist/plugins/sdk-cs-namer.js.map +1 -1
  65. package/dist/plugins/sdk-cs-simplifier.d.ts +3 -0
  66. package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -0
  67. package/dist/plugins/sdk-cs-simplifier.js +154 -0
  68. package/dist/plugins/sdk-cs-simplifier.js.map +1 -0
  69. package/dist/plugins/sdk-generate.d.ts.map +1 -1
  70. package/dist/plugins/sdk-generate.js +49 -3
  71. package/dist/plugins/sdk-generate.js.map +1 -1
  72. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
  73. package/dist/plugins/sdk-tweak-model.js +196 -37
  74. package/dist/plugins/sdk-tweak-model.js.map +1 -1
  75. package/dist/sdk/project.d.ts +1 -0
  76. package/dist/sdk/project.d.ts.map +1 -1
  77. package/dist/sdk/project.js +11 -0
  78. package/dist/sdk/project.js.map +1 -1
  79. package/dist/sdk/utility.d.ts +27 -0
  80. package/dist/sdk/utility.d.ts.map +1 -1
  81. package/dist/sdk/utility.js +402 -5
  82. package/dist/sdk/utility.js.map +1 -1
  83. package/dist/utils/SdkModel.d.ts.map +1 -1
  84. package/dist/utils/SdkModel.js.map +1 -1
  85. package/dist/utils/TrieNode.d.ts +10 -0
  86. package/dist/utils/TrieNode.d.ts.map +1 -0
  87. package/dist/utils/TrieNode.js +45 -0
  88. package/dist/utils/TrieNode.js.map +1 -0
  89. package/dist/utils/WrapComments.d.ts +2 -0
  90. package/dist/utils/WrapComments.d.ts.map +1 -0
  91. package/dist/utils/WrapComments.js +46 -0
  92. package/dist/utils/WrapComments.js.map +1 -0
  93. package/dist/utils/code-namer.d.ts +3 -0
  94. package/dist/utils/code-namer.d.ts.map +1 -0
  95. package/dist/utils/code-namer.js +38 -0
  96. package/dist/utils/code-namer.js.map +1 -0
  97. package/dist/utils/schema.d.ts +4 -0
  98. package/dist/utils/schema.d.ts.map +1 -1
  99. package/dist/utils/schema.js +28 -1
  100. package/dist/utils/schema.js.map +1 -1
  101. package/package.json +1 -1
  102. package/resources/assets/build-module.ps1 +10 -2
  103. package/resources/assets/create-model-cmdlets.ps1 +51 -10
  104. package/resources/assets/custom/README.md +1 -1
  105. package/resources/assets/docs/README.md +1 -1
  106. package/resources/assets/exports/README.md +1 -1
  107. package/resources/assets/generate-portal-ux.ps1 +379 -0
  108. package/resources/assets/how-to.md +1 -1
  109. package/resources/assets/internal/README.md +1 -1
  110. package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +1 -1
  111. package/resources/assets/tools/Resources/docs/README.md +1 -1
  112. package/resources/assets/tools/Resources/how-to.md +1 -1
  113. package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.nuspec +1 -1
  114. package/resources/modules/Az.Accounts/2.7.5/Az.Accounts.psd1 +1 -1
  115. package/resources/modules/Az.Accounts/2.7.5/Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +34 -34
  116. package/resources/modules/Az.Accounts/2.7.5/en-US/about_az.help.txt +1 -1
  117. package/resources/modules/Az.Accounts/2.7.5/package/services/metadata/core-properties/1aa0749a068a4238881858013f1a5b7f.psmdcp +1 -1
  118. package/resources/psruntime/BuildTime/Cmdlets/ExportFormatPs1xml.cs +3 -1
  119. package/resources/psruntime/BuildTime/PsAttributes.cs +12 -0
  120. package/resources/psruntime/BuildTime/PsExtensions.cs +7 -0
  121. package/resources/psruntime/TypeConverterExtensions.cs +50 -0
  122. package/resources/runtime/csharp/json/Nodes/Collections/XNodeArray.cs +5 -0
  123. package/resources/templates/azureMethod.ejs +3 -2
  124. package/resources/templates/azureMethodGroup.ejs +2 -1
  125. package/resources/templates/azureServiceClient.ejs +13 -4
  126. package/resources/templates/enum.ejs +73 -0
  127. package/resources/templates/exception.ejs +52 -0
  128. package/resources/templates/extensionMethod.ejs +22 -11
  129. package/resources/templates/extensions.ejs +4 -4
  130. package/resources/templates/longRunningOperationMethod.ejs +43 -0
  131. package/resources/templates/method.ejs +21 -2
  132. package/resources/templates/methodBodyRestCall.ejs +154 -20
  133. package/resources/templates/methodGroupInterface.ejs +28 -4
  134. package/resources/templates/model.ejs +133 -20
  135. package/resources/templates/page.ejs +40 -0
  136. package/resources/templates/serviceClientBody.ejs +12 -14
  137. package/resources/templates/serviceClientInterface.ejs +4 -3
  138. package/resources/templates/methodGroup.ejs +0 -7
@@ -5,7 +5,7 @@
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
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');
8
+ const ejs = require('ejs');
9
9
  const codemodel_1 = require("@azure-tools/codemodel");
10
10
  const codemodel_v3_1 = require("@azure-tools/codemodel-v3");
11
11
  const command_operation_1 = require("../utils/command-operation");
@@ -404,6 +404,77 @@ class CmdletClass extends codegen_csharp_1.Class {
404
404
  }
405
405
  return ops ? `${header}\n${codegen_1.docComment(codegen_csharp_1.xmlize('remarks', ops))}` : header;
406
406
  }
407
+ AddSwitchViewProperty(responseType = codegen_csharp_1.dotnet.Object) {
408
+ var fieldNames = this.fields.map(f => f.name);
409
+ if (!fieldNames.includes('_responseSize')) {
410
+ this.add(new codegen_csharp_1.Field('_responseSize', codegen_csharp_1.dotnet.Int, {
411
+ initialValue: '0', description: 'A flag to tell whether it is the first returned object in a call. Zero means no response yet. One means 1 returned object. Two means multiple returned objects in response.', access: codegen_csharp_1.Access.Private
412
+ }));
413
+ }
414
+ if (!fieldNames.includes('_firstResponse')) {
415
+ this.add(new codegen_csharp_1.Field('_firstResponse', responseType, {
416
+ initialValue: codegen_csharp_1.dotnet.Null, description: 'A buffer to record first returned object in response.', access: codegen_csharp_1.Access.Private
417
+ }));
418
+ }
419
+ }
420
+ FlushResponse(singleFlush = true) {
421
+ var fieldNames = this.fields.map(f => f.name);
422
+ return fieldNames.includes('_responseSize') ?
423
+ codegen_csharp_1.If(`1 ==_responseSize`, function* () {
424
+ yield '// Flush buffer';
425
+ if (singleFlush) {
426
+ yield 'WriteObject(_firstResponse);';
427
+ }
428
+ else {
429
+ yield 'WriteObject(_firstResponse.AddMultipleTypeNameIntoPSObject());';
430
+ }
431
+ }) : '';
432
+ }
433
+ ;
434
+ WriteObjectWithViewControl(valueName, isEnumerable = false) {
435
+ const $this = this;
436
+ if ($this.state.project.autoSwitchView) {
437
+ if (isEnumerable) {
438
+ return function* () {
439
+ yield `var outputObjects = ${valueName};`;
440
+ yield codegen_csharp_1.If(`null != outputObjects`, function* () {
441
+ yield codegen_csharp_1.If(`0 == _responseSize && 1 == outputObjects.Count`, function* () {
442
+ yield `_firstResponse = outputObjects[0];`;
443
+ yield `_responseSize = 1;`;
444
+ });
445
+ yield codegen_csharp_1.Else(function* () {
446
+ yield $this.FlushResponse(false);
447
+ yield 'var values = new System.Collections.Generic.List<System.Management.Automation.PSObject>();';
448
+ yield codegen_csharp_1.ForEach(`value`, `outputObjects`, function* () {
449
+ yield `values.Add(value.AddMultipleTypeNameIntoPSObject());`;
450
+ });
451
+ yield 'WriteObject(values, true); ';
452
+ yield `_responseSize = 2;`;
453
+ });
454
+ });
455
+ };
456
+ }
457
+ else {
458
+ return function* () {
459
+ yield `var outputObject = ${valueName};`;
460
+ yield codegen_csharp_1.If(`null != outputObject`, function* () {
461
+ yield codegen_csharp_1.If(`0 == _responseSize`, function* () {
462
+ yield `_firstResponse = outputObject;`;
463
+ yield `_responseSize = 1;`;
464
+ });
465
+ yield codegen_csharp_1.Else(function* () {
466
+ yield $this.FlushResponse(false);
467
+ yield `WriteObject(outputObject.AddMultipleTypeNameIntoPSObject());`;
468
+ yield `_responseSize = 2;`;
469
+ });
470
+ });
471
+ };
472
+ }
473
+ }
474
+ else {
475
+ return `WriteObject(${valueName}, ${isEnumerable})`;
476
+ }
477
+ }
407
478
  addCommonStuff() {
408
479
  var _a, _b;
409
480
  // add a private copy of invocation information for our own uses.
@@ -416,6 +487,10 @@ class CmdletClass extends codegen_csharp_1.Class {
416
487
  this.correlationId = this.add(new codegen_csharp_1.Field('__correlationId', codegen_csharp_1.dotnet.String, { initialValue: 'System.Guid.NewGuid().ToString()', description: 'A unique id generatd for the this cmdlet when it is instantiated.', access: codegen_csharp_1.Access.Private }));
417
488
  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 }));
418
489
  }
490
+ // switch view property
491
+ if (this.state.project.autoSwitchView) {
492
+ this.AddSwitchViewProperty(codegen_csharp_1.dotnet.Object);
493
+ }
419
494
  // pipeline property
420
495
  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.` }));
421
496
  // client API property (gs01: fill this in correctly)
@@ -428,7 +503,9 @@ class CmdletClass extends codegen_csharp_1.Class {
428
503
  const $this = this;
429
504
  this.add(new codegen_csharp_1.Method('EndProcessing', codegen_csharp_1.dotnet.Void, { access: codegen_csharp_1.Access.Protected, override: codegen_csharp_1.Modifier.Override, description: 'Performs clean-up after the command execution' })).add(function* () {
430
505
  // gs01: remember what you were doing here to make it so these can be parallelized...
431
- yield '';
506
+ if ($this.state.project.autoSwitchView) {
507
+ yield $this.FlushResponse();
508
+ }
432
509
  });
433
510
  // debugging
434
511
  const brk = this.add(new codegen_csharp_1.Property('Break', powershell_declarations_1.SwitchParameter, { attributes: [], description: 'Wait for .NET debugger to attach' }));
@@ -763,13 +840,13 @@ class CmdletClass extends codegen_csharp_1.Class {
763
840
  yield codegen_csharp_1.Else(function* () {
764
841
  yield ('ulong toRead = Math.Min(this.PagingParameters.First, (ulong)result.Value.Length - this.PagingParameters.Skip);');
765
842
  yield ('var requiredResult = result.Value.SubArray((int)this.PagingParameters.Skip, (int)toRead);');
766
- yield ('WriteObject(requiredResult, true);');
843
+ yield $this.WriteObjectWithViewControl(`requiredResult`, true);
767
844
  yield ('this.PagingParameters.Skip = 0;');
768
845
  yield ('this.PagingParameters.First = this.PagingParameters.First <= toRead ? 0 : this.PagingParameters.First - toRead;');
769
846
  });
770
847
  }
771
848
  else {
772
- yield `WriteObject(${result.value}.${vp.name},true);`;
849
+ yield $this.WriteObjectWithViewControl(`${result.value}.${vp.name}`, true);
773
850
  }
774
851
  }
775
852
  const nl = schema_1.getVirtualPropertyFromPropertyName((_o = schema.language.csharp) === null || _o === void 0 ? void 0 : _o.virtualProperties, nextLinkProperty.serializedName);
@@ -802,7 +879,7 @@ class CmdletClass extends codegen_csharp_1.Class {
802
879
  // it's just a nested array
803
880
  const p = codemodel_v3_1.getVirtualPropertyFromPropertyName((_p = schema.language.csharp) === null || _p === void 0 ? void 0 : _p.virtualProperties, valueProperty.serializedName);
804
881
  if (p) {
805
- yield `WriteObject((await response).${p.name}, true);`;
882
+ yield $this.WriteObjectWithViewControl(`(await response).${p.name}`, true);
806
883
  }
807
884
  return;
808
885
  }
@@ -811,7 +888,7 @@ class CmdletClass extends codegen_csharp_1.Class {
811
888
  // it's just an array,
812
889
  case 'array':
813
890
  // just write-object(enumerate) with the output
814
- yield 'WriteObject(await response, true);';
891
+ yield $this.WriteObjectWithViewControl('(await response)', true);
815
892
  return;
816
893
  }
817
894
  // ok, let's see if the response type
@@ -848,7 +925,7 @@ class CmdletClass extends codegen_csharp_1.Class {
848
925
  return;
849
926
  }
850
927
  // let's just return the result object (or unwrapped result object)
851
- yield `WriteObject(${outValue});`;
928
+ yield $this.WriteObjectWithViewControl(`${outValue}`);
852
929
  return;
853
930
  }
854
931
  // in m4, there will be no schema deinfed for the binary response, instead, we will have a field called binary with value true.
@@ -862,8 +939,8 @@ class CmdletClass extends codegen_csharp_1.Class {
862
939
  yield paths.declarationStatement;
863
940
  yield codegen_csharp_1.Try(function* () {
864
941
  yield `${paths.value} = this.SessionState.Path.GetResolvedProviderPathFromPSPath(${outfile.value}, out ${provider.declarationExpression});`;
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}) );`);
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}) );`);
942
+ 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}));`);
943
+ 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}));`);
867
944
  });
868
945
  const notfound = new codegen_csharp_1.Parameter('', { declaration: 'global::System.Management.Automation.ItemNotFoundException' });
869
946
  yield codegen_csharp_1.Catch(notfound, function* () {
@@ -940,7 +1017,7 @@ class CmdletClass extends codegen_csharp_1.Class {
940
1017
  value: `InputObject.${codegen_1.pascalCase((_f = (_e = match.language.csharp) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : '')} ?? ${defaultOfType}`
941
1018
  };
942
1019
  }
943
- console.error(`Unable to match idenity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
1020
+ console.error(`Unable to match identity parameter '${each.name}' member to appropriate virtual parameter. (Guessing '${pascalName}')`);
944
1021
  return {
945
1022
  name: `InputObject.${pascalName}`,
946
1023
  value: `InputObject.${pascalName}`
@@ -948,7 +1025,7 @@ class CmdletClass extends codegen_csharp_1.Class {
948
1025
  });
949
1026
  for (const opParam of idOpParams) {
950
1027
  if (opParam.name) {
951
- yield codegen_csharp_1.If(codegen_csharp_1.IsNull(opParam.name), `ThrowTerminatingError( new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("InputObject has null value for ${opParam.name}"),string.Empty, ${powershell_declarations_1.ErrorCategory('InvalidArgument')}, InputObject) );`);
1028
+ yield codegen_csharp_1.If(codegen_csharp_1.IsNull(opParam.name), `ThrowTerminatingError(new ${powershell_declarations_1.ErrorRecord}(new global::System.Exception("InputObject has null value for ${opParam.name}"),string.Empty, ${powershell_declarations_1.ErrorCategory('InvalidArgument')}, InputObject));`);
952
1029
  }
953
1030
  }
954
1031
  yield `await this.${$this.$('Client').invokeMethod(`${(_b = apiCall.language.csharp) === null || _b === void 0 ? void 0 : _b.name}`, ...[...idOpParams.map(each => codegen_csharp_1.toExpression(each.value)), ...callbackMethods, codegen_csharp_1.dotnet.This, pipeline]).implementation}`;
@@ -985,7 +1062,7 @@ class CmdletClass extends codegen_csharp_1.Class {
985
1062
  });
986
1063
  const ure = new codegen_csharp_1.Parameter('urexception', { declaration: `${exports_1.ClientRuntime.fullName}.UndeclaredResponseException` });
987
1064
  yield codegen_csharp_1.Catch(ure, function* () {
988
- yield `WriteError(new global::System.Management.Automation.ErrorRecord(${ure.value}, ${ure.value}.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => codegen_csharp_1.valueOf(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(',')}})
1065
+ yield `WriteError(new global::System.Management.Automation.ErrorRecord(${ure.value}, ${ure.value}.StatusCode.ToString(), global::System.Management.Automation.ErrorCategory.InvalidOperation, new { ${operationParameters.filter(e => codegen_csharp_1.valueOf(e.expression) !== 'null').map(each => `${each.name}=${each.expression}`).join(',')}})
989
1066
  {
990
1067
  ErrorDetails = new global::System.Management.Automation.ErrorDetails(${ure.value}.Message) { RecommendedAction = ${ure.value}.Action }
991
1068
  });`;
@@ -1029,7 +1106,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1029
1106
  }
1030
1107
  implementConstructors() {
1031
1108
  // default constructor
1032
- this.add(new codegen_csharp_1.Constructor(this, { description: `Intializes a new instance of the <see cref="${this.name}" /> cmdlet class.` }));
1109
+ this.add(new codegen_csharp_1.Constructor(this, { description: `Initializes a new instance of the <see cref="${this.name}" /> cmdlet class.` }));
1033
1110
  }
1034
1111
  implementIContext() {
1035
1112
  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), {
@@ -1099,10 +1176,27 @@ class CmdletClass extends codegen_csharp_1.Class {
1099
1176
  yield codegen_csharp_1.Return();
1100
1177
  }),
1101
1178
  codegen_csharp_1.TerminalCase(powershell_declarations_1.Events.Progress.value, function* () {
1179
+ yield 'var data = messageData();';
1180
+ yield 'int progress = (int)data.Value;';
1181
+ yield 'string activityMessage, statusDescription;';
1182
+ yield 'global::System.Management.Automation.ProgressRecordType recordType;';
1183
+ yield 'if (progress < 100)';
1184
+ yield '{';
1185
+ yield ' activityMessage = "In progress";';
1186
+ yield ' statusDescription = "Checking operation status";';
1187
+ yield ' recordType = System.Management.Automation.ProgressRecordType.Processing;';
1188
+ yield '}';
1189
+ yield 'else';
1190
+ yield '{';
1191
+ yield ' activityMessage = "Completed";';
1192
+ yield ' statusDescription = "Completed";';
1193
+ yield ' recordType = System.Management.Automation.ProgressRecordType.Completed;';
1194
+ yield '}';
1102
1195
  // 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")`;
1196
+ yield 'WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription)';
1104
1197
  yield '{';
1105
- yield ' PercentComplete = 0'; // hardcode 0 because polling has not started
1198
+ yield ' PercentComplete = progress,';
1199
+ yield 'RecordType = recordType';
1106
1200
  yield '});';
1107
1201
  yield codegen_csharp_1.Return();
1108
1202
  }),
@@ -1131,7 +1225,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1131
1225
  yield ' for (var now = 0; now < delay; ++now)';
1132
1226
  yield ' {';
1133
1227
  // 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")`;
1228
+ yield ' WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")';
1135
1229
  yield ' {';
1136
1230
  yield ' PercentComplete = now * 100 / delay';
1137
1231
  yield ' });';
@@ -1145,12 +1239,12 @@ class CmdletClass extends codegen_csharp_1.Class {
1145
1239
  yield sw;
1146
1240
  if ($this.state.project.azure) {
1147
1241
  // in azure mode, we signal the AzAccount module with every event that makes it here.
1148
- yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i,t,m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i,t,()=> ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom( m() ) as ${exports_1.ClientRuntime.EventData} ), ${$this.invocationInfo.value}, this.ParameterSetName, ${$this.correlationId.value}, ${$this.processRecordId.value}, null );`;
1242
+ yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i, t, m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i, t, () => ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom(m()) as ${exports_1.ClientRuntime.EventData}), ${$this.invocationInfo.value}, this.ParameterSetName, ${$this.correlationId.value}, ${$this.processRecordId.value}, null );`;
1149
1243
  yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
1150
1244
  }
1151
1245
  else {
1152
1246
  // In Non-Azure Modes, emit the Signal method without coorelation and processrecordid
1153
- yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i,t,m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i,t,()=> ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom( m() ) as ${exports_1.ClientRuntime.EventData} ), ${$this.invocationInfo.value}, this.ParameterSetName, null );`;
1247
+ yield `await ${$this.state.project.serviceNamespace.moduleClass.declaration}.Instance.Signal(${id.value}, ${token.value}, ${messageData.value}, (i, t, m) => ((${exports_1.ClientRuntime.IEventListener})this).Signal(i, t, () => ${exports_1.ClientRuntime.EventDataConverter}.ConvertFrom(m()) as ${exports_1.ClientRuntime.EventData}), ${$this.invocationInfo.value}, this.ParameterSetName, null ); `;
1154
1248
  yield codegen_csharp_1.If(`${token.value}.IsCancellationRequested`, codegen_csharp_1.Return());
1155
1249
  }
1156
1250
  yield `WriteDebug($"{id}: {(messageData().Message ?? ${codegen_csharp_1.System.String.Empty})}");`;
@@ -1221,12 +1315,23 @@ class CmdletClass extends codegen_csharp_1.Class {
1221
1315
  const propertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state);
1222
1316
  // we need to know if the actual underlying property is actually nullable.
1223
1317
  const nullable = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, !!vParam.origin.required, this.state).isNullable;
1224
- const cmdletParameter = new codegen_csharp_1.Property(vParam.name, propertyType, {
1225
- get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}${!nullable ? '' : ` ?? ${propertyType.defaultOfType}`}`),
1226
- // get: toExpression(`null == ${expandedBodyParameter.value}.${vParam.origin.name} ? ${propertyType.defaultOfType} : (${propertyType.declaration}) ${expandedBodyParameter.value}.${vParam.origin.name}`),
1227
- set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = value`),
1228
- new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1229
- });
1318
+ let cmdletParameter;
1319
+ if (propertyType.schema.type !== codemodel_1.SchemaType.Array) {
1320
+ cmdletParameter = new codegen_csharp_1.Property(vParam.name, propertyType, {
1321
+ get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}${!nullable ? '' : ` ?? ${propertyType.defaultOfType}`}`),
1322
+ // get: toExpression(`null == ${expandedBodyParameter.value}.${vParam.origin.name} ? ${propertyType.defaultOfType} : (${propertyType.declaration}) ${expandedBodyParameter.value}.${vParam.origin.name}`),
1323
+ set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = value`),
1324
+ new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1325
+ });
1326
+ }
1327
+ else {
1328
+ const fixedArrayPropertyType = this.state.project.schemaDefinitionResolver.resolveTypeDeclaration(vSchema, true, this.state, true);
1329
+ cmdletParameter = new codegen_csharp_1.Property(vParam.name, fixedArrayPropertyType, {
1330
+ get: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name}?.ToArray()${` ?? ${fixedArrayPropertyType.defaultOfType}`}`),
1331
+ set: codegen_csharp_1.toExpression(`${expandedBodyParameter.value}.${model_class_1.getVirtualPropertyName(vParam.origin) || vParam.origin.name} = (value != null ? new ${propertyType.declaration}(value) : null)`),
1332
+ new: PropertiesRequiringNew.has(vParam.name) ? codegen_csharp_1.Modifier.New : codegen_csharp_1.Modifier.None
1333
+ });
1334
+ }
1230
1335
  if ((_b = vParam.schema.language.csharp) === null || _b === void 0 ? void 0 : _b.byReference) {
1231
1336
  // this parameter's schema is marked as 'by-reference' which means we should
1232
1337
  // tag it with an ExportAs attribute for the I*Reference type.
@@ -1429,6 +1534,14 @@ class CmdletClass extends codegen_csharp_1.Class {
1429
1534
  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))}`] }));
1430
1535
  }
1431
1536
  }
1537
+ else {
1538
+ const isBodyParameter = origin ? origin.details.csharp.isBodyParameter : false;
1539
+ if (isBodyParameter) {
1540
+ regularCmdletParameter.add(new codegen_csharp_1.Attribute(powershell_declarations_1.CategoryAttribute, {
1541
+ parameters: [`${powershell_declarations_1.ParameterCategory}.Body`],
1542
+ }));
1543
+ }
1544
+ }
1432
1545
  const isEnum = propertyType instanceof exports_1.EnumImplementation;
1433
1546
  const hasEnum = propertyType instanceof exports_1.ArrayOf && propertyType.elementType instanceof exports_1.EnumImplementation;
1434
1547
  if (propertyType && (isEnum || hasEnum)) {
@@ -1557,9 +1670,9 @@ class CmdletClass extends codegen_csharp_1.Class {
1557
1670
  parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
1558
1671
  }
1559
1672
  if (breakingChange.cmdlet.replacement)
1560
- parameters.push(`ReplacementCmdletName="${breakingChange.cmdlet.replacement}"`);
1673
+ parameters.push(`ReplacementCmdletName = "${breakingChange.cmdlet.replacement}"`);
1561
1674
  if (breakingChange.cmdlet.changeDescription)
1562
- parameters.push(`ChangeDescription="${breakingChange.cmdlet.changeDescription}"`);
1675
+ parameters.push(`ChangeDescription = "${breakingChange.cmdlet.changeDescription}"`);
1563
1676
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.CmdletBreakingChangeAttribute, { parameters: parameters }));
1564
1677
  }
1565
1678
  if (breakingChange.variant) {
@@ -1571,7 +1684,7 @@ class CmdletClass extends codegen_csharp_1.Class {
1571
1684
  parameters.push(`"${breakingChange.variant.changeInEfectByDate}"`);
1572
1685
  }
1573
1686
  if (breakingChange.variant.changeDescription)
1574
- parameters.push(`ChangeDescription="${breakingChange.variant.changeDescription}"`);
1687
+ parameters.push(`ChangeDescription = "${breakingChange.variant.changeDescription}"`);
1575
1688
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.ParameterSetBreakingChangeAttribute, { parameters: parameters }));
1576
1689
  }
1577
1690
  if (breakingChange.output) {
@@ -1589,19 +1702,19 @@ class CmdletClass extends codegen_csharp_1.Class {
1589
1702
  parameters.push(`"${breakingChange.output.changeInEfectByDate}"`);
1590
1703
  }
1591
1704
  if (breakingChange.output.replacement)
1592
- parameters.push(`ReplacementCmdletOutputType="${breakingChange.output.replacement}"`);
1705
+ parameters.push(`ReplacementCmdletOutputType = "${breakingChange.output.replacement}"`);
1593
1706
  if (breakingChange.output.deprecatedOutputProperties) {
1594
1707
  const properties = Object.assign([], breakingChange.output.deprecatedOutputProperties);
1595
1708
  properties.forEach((element, index) => properties[index] = '"' + element + '"');
1596
- parameters.push(`DeprecatedOutputProperties=new string[] {${properties.join(',')}}`);
1709
+ parameters.push(`DeprecatedOutputProperties = new string[] {${properties.join(',')}}`);
1597
1710
  }
1598
1711
  if (breakingChange.output.newOutputProperties) {
1599
1712
  const properties = Object.assign([], breakingChange.output.newOutputProperties);
1600
1713
  properties.forEach((element, index) => properties[index] = '"' + element + '"');
1601
- parameters.push(`NewOutputProperties=new string[] {${properties.join(',')}}`);
1714
+ parameters.push(`NewOutputProperties = new string[] {${properties.join(',')} } `);
1602
1715
  }
1603
1716
  if (breakingChange.output.changeDescription)
1604
- parameters.push(`ChangeDescription="${breakingChange.output.changeDescription}"`);
1717
+ parameters.push(`ChangeDescription = "${breakingChange.output.changeDescription}"`);
1605
1718
  this.add(new codegen_csharp_1.Attribute(exports_1.ClientRuntime.OutputBreakingChangeAttribute, { parameters: parameters }));
1606
1719
  }
1607
1720
  }
@@ -1619,8 +1732,8 @@ class CmdletClass extends codegen_csharp_1.Class {
1619
1732
  // If defines externalDocs for operation
1620
1733
  if (operation.details.default.externalDocs) {
1621
1734
  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 : "")}`]
1735
+ 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 : '')}`,
1736
+ `${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
1737
  }));
1625
1738
  }
1626
1739
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.GeneratedAttribute));
@@ -1632,6 +1745,17 @@ class CmdletClass extends codegen_csharp_1.Class {
1632
1745
  });
1633
1746
  this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.ProfileAttribute, { parameters: [...profileNames] }));
1634
1747
  }
1748
+ this.operation.callGraph.forEach((operationInfo) => {
1749
+ var _a;
1750
+ let apiVersion = 'null';
1751
+ if (operationInfo.apiVersions) {
1752
+ apiVersion = operationInfo.apiVersions[0].version;
1753
+ }
1754
+ (_a = operationInfo.requests) === null || _a === void 0 ? void 0 : _a.forEach((request) => {
1755
+ var _a, _b;
1756
+ this.add(new codegen_csharp_1.Attribute(powershell_declarations_1.HttpPathAttribute, { parameters: [`Path = "${(_b = (_a = request.protocol) === null || _a === void 0 ? void 0 : _a.http) === null || _b === void 0 ? void 0 : _b.path}"`, `ApiVersion = "${apiVersion}"`] }));
1757
+ });
1758
+ });
1635
1759
  }
1636
1760
  }
1637
1761
  exports.CmdletClass = CmdletClass;