@autorest/powershell 4.0.0-dev.9 → 4.0.617

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 (303) hide show
  1. package/.rush/temp/operation/build/state.json +3 -0
  2. package/.rush/temp/package-deps_build.json +98 -98
  3. package/.rush/temp/shrinkwrap-deps.json +182 -234
  4. package/dist/cmdlets/class.d.ts +9 -2
  5. package/dist/cmdlets/class.d.ts.map +1 -1
  6. package/dist/cmdlets/class.js +663 -581
  7. package/dist/cmdlets/class.js.map +1 -1
  8. package/dist/cmdlets/namespace.d.ts.map +1 -1
  9. package/dist/cmdlets/namespace.js +38 -5
  10. package/dist/cmdlets/namespace.js.map +1 -1
  11. package/dist/enums/namespace.js +5 -5
  12. package/dist/enums/namespace.js.map +1 -1
  13. package/dist/generators/psm1.custom.js +2 -2
  14. package/dist/generators/psm1.custom.js.map +1 -1
  15. package/dist/generators/psm1.internal.js +2 -2
  16. package/dist/generators/psm1.internal.js.map +1 -1
  17. package/dist/generators/psm1.js +1 -1
  18. package/dist/generators/psm1.js.map +1 -1
  19. package/dist/generators/script-cmdlet.js +18 -18
  20. package/dist/generators/script-cmdlet.js.map +1 -1
  21. package/dist/internal/name-inferrer.d.ts +1 -1
  22. package/dist/internal/name-inferrer.d.ts.map +1 -1
  23. package/dist/internal/name-inferrer.js +12 -12
  24. package/dist/internal/name-inferrer.js.map +1 -1
  25. package/dist/internal/powershell-declarations.d.ts +1 -0
  26. package/dist/internal/powershell-declarations.d.ts.map +1 -1
  27. package/dist/internal/powershell-declarations.js +3 -2
  28. package/dist/internal/powershell-declarations.js.map +1 -1
  29. package/dist/internal/project.d.ts +3 -3
  30. package/dist/internal/project.d.ts.map +1 -1
  31. package/dist/internal/project.js +11 -11
  32. package/dist/internal/project.js.map +1 -1
  33. package/dist/internal/state.d.ts +1 -1
  34. package/dist/internal/state.d.ts.map +1 -1
  35. package/dist/llcsharp/clientruntime.d.ts +1 -0
  36. package/dist/llcsharp/clientruntime.d.ts.map +1 -1
  37. package/dist/llcsharp/clientruntime.js +12 -11
  38. package/dist/llcsharp/clientruntime.js.map +1 -1
  39. package/dist/llcsharp/code-model.d.ts +7 -7
  40. package/dist/llcsharp/code-model.d.ts.map +1 -1
  41. package/dist/llcsharp/enums/enum.d.ts +1 -1
  42. package/dist/llcsharp/enums/enum.d.ts.map +1 -1
  43. package/dist/llcsharp/enums/enum.js +42 -42
  44. package/dist/llcsharp/enums/enum.js.map +1 -1
  45. package/dist/llcsharp/exports.js +5 -1
  46. package/dist/llcsharp/exports.js.map +1 -1
  47. package/dist/llcsharp/generator.d.ts +1 -1
  48. package/dist/llcsharp/generator.d.ts.map +1 -1
  49. package/dist/llcsharp/model/idictionary.js +16 -16
  50. package/dist/llcsharp/model/idictionary.js.map +1 -1
  51. package/dist/llcsharp/model/interface.d.ts +1 -1
  52. package/dist/llcsharp/model/interface.d.ts.map +1 -1
  53. package/dist/llcsharp/model/interface.js +19 -19
  54. package/dist/llcsharp/model/interface.js.map +1 -1
  55. package/dist/llcsharp/model/model-class-dictionary.js +18 -18
  56. package/dist/llcsharp/model/model-class-dictionary.js.map +1 -1
  57. package/dist/llcsharp/model/model-class-json.js +19 -19
  58. package/dist/llcsharp/model/model-class-json.js.map +1 -1
  59. package/dist/llcsharp/model/model-class-serializer.d.ts +1 -1
  60. package/dist/llcsharp/model/model-class-serializer.d.ts.map +1 -1
  61. package/dist/llcsharp/model/model-class-serializer.js +6 -6
  62. package/dist/llcsharp/model/model-class-serializer.js.map +1 -1
  63. package/dist/llcsharp/model/model-class.d.ts +1 -1
  64. package/dist/llcsharp/model/model-class.d.ts.map +1 -1
  65. package/dist/llcsharp/model/model-class.js +97 -89
  66. package/dist/llcsharp/model/model-class.js.map +1 -1
  67. package/dist/llcsharp/model/namespace.d.ts +1 -1
  68. package/dist/llcsharp/model/namespace.d.ts.map +1 -1
  69. package/dist/llcsharp/model/namespace.js +2 -2
  70. package/dist/llcsharp/model/namespace.js.map +1 -1
  71. package/dist/llcsharp/model/property.d.ts +1 -1
  72. package/dist/llcsharp/model/property.d.ts.map +1 -1
  73. package/dist/llcsharp/model/property.js +20 -20
  74. package/dist/llcsharp/model/property.js.map +1 -1
  75. package/dist/llcsharp/operation/api-class.d.ts.map +1 -1
  76. package/dist/llcsharp/operation/api-class.js +26 -1
  77. package/dist/llcsharp/operation/api-class.js.map +1 -1
  78. package/dist/llcsharp/operation/method.d.ts +10 -5
  79. package/dist/llcsharp/operation/method.d.ts.map +1 -1
  80. package/dist/llcsharp/operation/method.js +276 -134
  81. package/dist/llcsharp/operation/method.js.map +1 -1
  82. package/dist/llcsharp/operation/parameter.d.ts +1 -1
  83. package/dist/llcsharp/operation/parameter.d.ts.map +1 -1
  84. package/dist/llcsharp/operation/parameter.js +10 -10
  85. package/dist/llcsharp/operation/parameter.js.map +1 -1
  86. package/dist/llcsharp/project.d.ts +2 -1
  87. package/dist/llcsharp/project.d.ts.map +1 -1
  88. package/dist/llcsharp/project.js +6 -0
  89. package/dist/llcsharp/project.js.map +1 -1
  90. package/dist/llcsharp/schema/Uuid.d.ts +1 -1
  91. package/dist/llcsharp/schema/Uuid.d.ts.map +1 -1
  92. package/dist/llcsharp/schema/Uuid.js +2 -2
  93. package/dist/llcsharp/schema/Uuid.js.map +1 -1
  94. package/dist/llcsharp/schema/array.d.ts +1 -1
  95. package/dist/llcsharp/schema/array.d.ts.map +1 -1
  96. package/dist/llcsharp/schema/array.js +45 -43
  97. package/dist/llcsharp/schema/array.js.map +1 -1
  98. package/dist/llcsharp/schema/binary.d.ts +1 -1
  99. package/dist/llcsharp/schema/binary.d.ts.map +1 -1
  100. package/dist/llcsharp/schema/binary.js +9 -9
  101. package/dist/llcsharp/schema/binary.js.map +1 -1
  102. package/dist/llcsharp/schema/boolean.d.ts +1 -1
  103. package/dist/llcsharp/schema/boolean.d.ts.map +1 -1
  104. package/dist/llcsharp/schema/byte-array.d.ts +1 -1
  105. package/dist/llcsharp/schema/byte-array.d.ts.map +1 -1
  106. package/dist/llcsharp/schema/byte-array.js +24 -24
  107. package/dist/llcsharp/schema/byte-array.js.map +1 -1
  108. package/dist/llcsharp/schema/char.d.ts +1 -1
  109. package/dist/llcsharp/schema/char.d.ts.map +1 -1
  110. package/dist/llcsharp/schema/char.js +1 -1
  111. package/dist/llcsharp/schema/char.js.map +1 -1
  112. package/dist/llcsharp/schema/date-time.d.ts +1 -1
  113. package/dist/llcsharp/schema/date-time.d.ts.map +1 -1
  114. package/dist/llcsharp/schema/date-time.js +45 -41
  115. package/dist/llcsharp/schema/date-time.js.map +1 -1
  116. package/dist/llcsharp/schema/date.d.ts +1 -1
  117. package/dist/llcsharp/schema/date.d.ts.map +1 -1
  118. package/dist/llcsharp/schema/duration.d.ts +1 -1
  119. package/dist/llcsharp/schema/duration.d.ts.map +1 -1
  120. package/dist/llcsharp/schema/duration.js +9 -7
  121. package/dist/llcsharp/schema/duration.js.map +1 -1
  122. package/dist/llcsharp/schema/enum.d.ts +6 -2
  123. package/dist/llcsharp/schema/enum.d.ts.map +1 -1
  124. package/dist/llcsharp/schema/enum.js +13 -4
  125. package/dist/llcsharp/schema/enum.js.map +1 -1
  126. package/dist/llcsharp/schema/extended-type-declaration.d.ts +1 -1
  127. package/dist/llcsharp/schema/extended-type-declaration.d.ts.map +1 -1
  128. package/dist/llcsharp/schema/fixed-array.d.ts +1 -1
  129. package/dist/llcsharp/schema/fixed-array.d.ts.map +1 -1
  130. package/dist/llcsharp/schema/fixed-array.js +44 -42
  131. package/dist/llcsharp/schema/fixed-array.js.map +1 -1
  132. package/dist/llcsharp/schema/integer.d.ts +1 -1
  133. package/dist/llcsharp/schema/integer.d.ts.map +1 -1
  134. package/dist/llcsharp/schema/integer.js +5 -5
  135. package/dist/llcsharp/schema/integer.js.map +1 -1
  136. package/dist/llcsharp/schema/object.d.ts +1 -1
  137. package/dist/llcsharp/schema/object.d.ts.map +1 -1
  138. package/dist/llcsharp/schema/object.js +28 -28
  139. package/dist/llcsharp/schema/object.js.map +1 -1
  140. package/dist/llcsharp/schema/password.d.ts +1 -1
  141. package/dist/llcsharp/schema/password.d.ts.map +1 -1
  142. package/dist/llcsharp/schema/password.js +13 -13
  143. package/dist/llcsharp/schema/password.js.map +1 -1
  144. package/dist/llcsharp/schema/primitive.d.ts +1 -1
  145. package/dist/llcsharp/schema/primitive.d.ts.map +1 -1
  146. package/dist/llcsharp/schema/primitive.js +40 -37
  147. package/dist/llcsharp/schema/primitive.js.map +1 -1
  148. package/dist/llcsharp/schema/schema-resolver.d.ts +1 -1
  149. package/dist/llcsharp/schema/schema-resolver.d.ts.map +1 -1
  150. package/dist/llcsharp/schema/schema-resolver.js +1 -1
  151. package/dist/llcsharp/schema/schema-resolver.js.map +1 -1
  152. package/dist/llcsharp/schema/string.d.ts +1 -1
  153. package/dist/llcsharp/schema/string.d.ts.map +1 -1
  154. package/dist/llcsharp/schema/string.js +48 -44
  155. package/dist/llcsharp/schema/string.js.map +1 -1
  156. package/dist/llcsharp/schema/uri.d.ts +1 -1
  157. package/dist/llcsharp/schema/uri.d.ts.map +1 -1
  158. package/dist/llcsharp/schema/uri.js +2 -2
  159. package/dist/llcsharp/schema/uri.js.map +1 -1
  160. package/dist/llcsharp/validations.js +2 -2
  161. package/dist/llcsharp/validations.js.map +1 -1
  162. package/dist/main.js +2 -2
  163. package/dist/main.js.map +1 -1
  164. package/dist/models/model-extensions.d.ts +1 -1
  165. package/dist/models/model-extensions.d.ts.map +1 -1
  166. package/dist/models/model-extensions.js +39 -39
  167. package/dist/models/model-extensions.js.map +1 -1
  168. package/dist/module/module-class.js +8 -8
  169. package/dist/module/module-class.js.map +1 -1
  170. package/dist/module/module-namespace.js +3 -3
  171. package/dist/module/module-namespace.js.map +1 -1
  172. package/dist/plugins/add-azure-completers-v2.d.ts +1 -1
  173. package/dist/plugins/add-azure-completers-v2.d.ts.map +1 -1
  174. package/dist/plugins/add-azure-completers-v2.js +3 -3
  175. package/dist/plugins/add-azure-completers-v2.js.map +1 -1
  176. package/dist/plugins/create-commands-v2.d.ts +8 -7
  177. package/dist/plugins/create-commands-v2.d.ts.map +1 -1
  178. package/dist/plugins/create-commands-v2.js +199 -61
  179. package/dist/plugins/create-commands-v2.js.map +1 -1
  180. package/dist/plugins/cs-namer-v2.d.ts +1 -1
  181. package/dist/plugins/cs-namer-v2.d.ts.map +1 -1
  182. package/dist/plugins/cs-namer-v2.js +40 -40
  183. package/dist/plugins/cs-namer-v2.js.map +1 -1
  184. package/dist/plugins/llcsharp-v2.d.ts +1 -1
  185. package/dist/plugins/llcsharp-v2.d.ts.map +1 -1
  186. package/dist/plugins/llcsharp-v2.js +9 -7
  187. package/dist/plugins/llcsharp-v2.js.map +1 -1
  188. package/dist/plugins/modifiers-v2.d.ts +1 -1
  189. package/dist/plugins/modifiers-v2.d.ts.map +1 -1
  190. package/dist/plugins/modifiers-v2.js +94 -82
  191. package/dist/plugins/modifiers-v2.js.map +1 -1
  192. package/dist/plugins/plugin-create-inline-properties.d.ts +1 -1
  193. package/dist/plugins/plugin-create-inline-properties.d.ts.map +1 -1
  194. package/dist/plugins/plugin-create-inline-properties.js +42 -31
  195. package/dist/plugins/plugin-create-inline-properties.js.map +1 -1
  196. package/dist/plugins/plugin-tweak-m4-model.d.ts +1 -1
  197. package/dist/plugins/plugin-tweak-m4-model.d.ts.map +1 -1
  198. package/dist/plugins/plugin-tweak-m4-model.js +8 -8
  199. package/dist/plugins/plugin-tweak-m4-model.js.map +1 -1
  200. package/dist/plugins/plugin-tweak-model-azure-v2.d.ts +1 -1
  201. package/dist/plugins/plugin-tweak-model-azure-v2.d.ts.map +1 -1
  202. package/dist/plugins/plugin-tweak-model-azure-v2.js +17 -17
  203. package/dist/plugins/plugin-tweak-model-azure-v2.js.map +1 -1
  204. package/dist/plugins/plugin-tweak-model.d.ts +1 -1
  205. package/dist/plugins/plugin-tweak-model.d.ts.map +1 -1
  206. package/dist/plugins/plugin-tweak-model.js +31 -31
  207. package/dist/plugins/plugin-tweak-model.js.map +1 -1
  208. package/dist/plugins/powershell-v2.d.ts +1 -1
  209. package/dist/plugins/powershell-v2.d.ts.map +1 -1
  210. package/dist/plugins/powershell-v2.js +26 -26
  211. package/dist/plugins/powershell-v2.js.map +1 -1
  212. package/dist/plugins/ps-namer-v2.d.ts +1 -1
  213. package/dist/plugins/ps-namer-v2.d.ts.map +1 -1
  214. package/dist/plugins/ps-namer-v2.js +31 -31
  215. package/dist/plugins/ps-namer-v2.js.map +1 -1
  216. package/dist/plugins/sdk-create-inline-properties.d.ts +1 -1
  217. package/dist/plugins/sdk-create-inline-properties.d.ts.map +1 -1
  218. package/dist/plugins/sdk-create-inline-properties.js +37 -37
  219. package/dist/plugins/sdk-create-inline-properties.js.map +1 -1
  220. package/dist/plugins/sdk-cs-namer.d.ts +1 -1
  221. package/dist/plugins/sdk-cs-namer.d.ts.map +1 -1
  222. package/dist/plugins/sdk-cs-namer.js +21 -21
  223. package/dist/plugins/sdk-cs-namer.js.map +1 -1
  224. package/dist/plugins/sdk-cs-simplifier.d.ts +1 -1
  225. package/dist/plugins/sdk-cs-simplifier.d.ts.map +1 -1
  226. package/dist/plugins/sdk-cs-simplifier.js +3 -3
  227. package/dist/plugins/sdk-cs-simplifier.js.map +1 -1
  228. package/dist/plugins/sdk-generate.d.ts +1 -1
  229. package/dist/plugins/sdk-generate.d.ts.map +1 -1
  230. package/dist/plugins/sdk-generate.js +14 -14
  231. package/dist/plugins/sdk-generate.js.map +1 -1
  232. package/dist/plugins/sdk-tweak-model.d.ts +1 -1
  233. package/dist/plugins/sdk-tweak-model.d.ts.map +1 -1
  234. package/dist/plugins/sdk-tweak-model.js +23 -23
  235. package/dist/plugins/sdk-tweak-model.js.map +1 -1
  236. package/dist/sdk/project.d.ts +2 -2
  237. package/dist/sdk/project.d.ts.map +1 -1
  238. package/dist/sdk/project.js +8 -8
  239. package/dist/sdk/project.js.map +1 -1
  240. package/dist/sdk/state.d.ts +2 -2
  241. package/dist/sdk/state.d.ts.map +1 -1
  242. package/dist/sdk/utility.d.ts +1 -1
  243. package/dist/sdk/utility.d.ts.map +1 -1
  244. package/dist/sdk/utility.js +17 -16
  245. package/dist/sdk/utility.js.map +1 -1
  246. package/dist/utils/PwshModel.d.ts +1 -1
  247. package/dist/utils/PwshModel.d.ts.map +1 -1
  248. package/dist/utils/PwshModel.js +1 -1
  249. package/dist/utils/PwshModel.js.map +1 -1
  250. package/dist/utils/SdkModel.d.ts +1 -1
  251. package/dist/utils/SdkModel.d.ts.map +1 -1
  252. package/dist/utils/SdkModel.js +1 -1
  253. package/dist/utils/SdkModel.js.map +1 -1
  254. package/dist/utils/command-operation.d.ts +9 -3
  255. package/dist/utils/command-operation.d.ts.map +1 -1
  256. package/dist/utils/command-operation.js +24 -4
  257. package/dist/utils/command-operation.js.map +1 -1
  258. package/dist/utils/components.d.ts +1 -1
  259. package/dist/utils/components.d.ts.map +1 -1
  260. package/dist/utils/components.js +2 -2
  261. package/dist/utils/components.js.map +1 -1
  262. package/dist/utils/http-operation.d.ts +2 -0
  263. package/dist/utils/http-operation.d.ts.map +1 -1
  264. package/dist/utils/http-operation.js +16 -12
  265. package/dist/utils/http-operation.js.map +1 -1
  266. package/dist/utils/model-state.d.ts +1 -1
  267. package/dist/utils/model-state.d.ts.map +1 -1
  268. package/dist/utils/model-state.js +20 -20
  269. package/dist/utils/model-state.js.map +1 -1
  270. package/dist/utils/programatic-operation.d.ts +1 -1
  271. package/dist/utils/programatic-operation.d.ts.map +1 -1
  272. package/dist/utils/programatic-operation.js +1 -1
  273. package/dist/utils/programatic-operation.js.map +1 -1
  274. package/dist/utils/resolve-conflicts.js +8 -8
  275. package/dist/utils/resolve-conflicts.js.map +1 -1
  276. package/dist/utils/schema.d.ts +1 -1
  277. package/dist/utils/schema.d.ts.map +1 -1
  278. package/dist/utils/schema.js +11 -11
  279. package/dist/utils/schema.js.map +1 -1
  280. package/dist/utils/security-scheme.d.ts +2 -2
  281. package/dist/utils/security-scheme.d.ts.map +1 -1
  282. package/dist/utils/security-scheme.js +2 -2
  283. package/dist/utils/security-scheme.js.map +1 -1
  284. package/dist/utils/sort-parameters.d.ts +1 -1
  285. package/dist/utils/sort-parameters.d.ts.map +1 -1
  286. package/package.json +7 -7
  287. package/resources/assets/build-module.ps1 +6 -1
  288. package/resources/assets/generate-help.ps1 +2 -2
  289. package/resources/assets/test-module.ps1 +3 -3
  290. package/resources/assets/tools/Resources/custom/New-AzDeployment.ps1 +2 -2
  291. package/resources/psruntime/BuildTime/Cmdlets/ExportHelpMarkdown.cs +4 -1
  292. package/resources/psruntime/BuildTime/Cmdlets/ExportProxyCmdlet.cs +4 -1
  293. package/resources/psruntime/BuildTime/Cmdlets/ExportPsd1.cs +6 -4
  294. package/resources/psruntime/BuildTime/MarkdownRenderer.cs +16 -8
  295. package/resources/psruntime/BuildTime/Models/PsProxyOutputs.cs +2 -2
  296. package/resources/psruntime/BuildTime/Models/PsProxyTypes.cs +13 -0
  297. package/resources/psruntime/BuildTime/PsAttributes.cs +5 -0
  298. package/resources/psruntime/BuildTime/PsHelpers.cs +4 -3
  299. package/resources/psruntime/MessageAttribute.cs +23 -52
  300. package/resources/psruntime/MessageAttributeHelper.cs +5 -1
  301. package/resources/psruntime/Properties/Resources.Designer.cs +15 -2
  302. package/resources/psruntime/Properties/Resources.resx +4 -1
  303. package/resources/runtime/csharp/pipeline/PipelineMocking.cs +1 -1
@@ -4,9 +4,9 @@
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.ValidationMethod = exports.CallMethod = exports.OperationMethod = exports.EventListener = void 0;
7
+ exports.ValidationMethod = exports.CallMethod = exports.ResolveResponseType = exports.OperationMethod = exports.EventListener = void 0;
8
8
  const codemodel_v3_1 = require("@azure-tools/codemodel-v3");
9
- const codemodel_1 = require("@azure-tools/codemodel");
9
+ const codemodel_1 = require("@autorest/codemodel");
10
10
  const linq_1 = require("@azure-tools/linq");
11
11
  const codegen_1 = require("@azure-tools/codegen");
12
12
  const codegen_csharp_1 = require("@azure-tools/codegen-csharp");
@@ -24,6 +24,7 @@ const codegen_csharp_11 = require("@azure-tools/codegen-csharp");
24
24
  const codegen_csharp_12 = require("@azure-tools/codegen-csharp");
25
25
  const clientruntime_1 = require("../clientruntime");
26
26
  const parameter_1 = require("../operation/parameter");
27
+ const schema_1 = require("../../utils/schema");
27
28
  const codemodel_v3_2 = require("@azure-tools/codemodel-v3");
28
29
  const codegen_csharp_13 = require("@azure-tools/codegen-csharp");
29
30
  const codegen_csharp_14 = require("@azure-tools/codegen-csharp");
@@ -32,26 +33,27 @@ function removeEncoding(pp, paramName, kmt) {
32
33
  return pp.param.extensions && pp.param.extensions['x-ms-skip-url-encoding'] ? up.replace(/global::System.Uri.EscapeDataString|System.Uri.EscapeDataString/g, '') : up;
33
34
  }
34
35
  class EventListener {
35
- constructor(expression, emitSignals) {
36
+ constructor(expression, emitSignals, withResult) {
36
37
  this.expression = expression;
37
38
  this.emitSignals = emitSignals;
39
+ this.withResult = withResult;
38
40
  }
39
41
  *signalNoCheck(eventName, ...additionalParameters) {
40
42
  if (this.emitSignals) {
41
- const params = linq_1.length(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
43
+ const params = (0, linq_1.length)(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
42
44
  yield `await ${this.expression.value}.Signal(${eventName}${params});`;
43
45
  }
44
46
  }
45
47
  *syncSignalNoCheck(eventName, ...additionalParameters) {
46
48
  if (this.emitSignals) {
47
- const params = linq_1.length(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
49
+ const params = (0, linq_1.length)(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
48
50
  yield `${this.expression.value}.Signal(${eventName}${params}).Wait();`;
49
51
  }
50
52
  }
51
53
  *signal(eventName, ...additionalParameters) {
52
54
  if (this.emitSignals) {
53
- const params = linq_1.length(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
54
- yield `await ${this.expression.value}.Signal(${eventName}${params}); if( ${this.expression.value}.Token.IsCancellationRequested ) { return; }`;
55
+ const params = (0, linq_1.length)(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
56
+ yield `await ${this.expression.value}.Signal(${eventName}${params}); if( ${this.expression.value}.Token.IsCancellationRequested ) { return${this.withResult ? ' null' : ''}; }`;
55
57
  }
56
58
  else {
57
59
  yield `if( ${this.expression.value}.CancellationToken.IsCancellationRequested ) { throw ${codegen_csharp_13.System.OperationCanceledException.new()}; }`;
@@ -59,8 +61,8 @@ class EventListener {
59
61
  }
60
62
  *syncSignal(eventName, ...additionalParameters) {
61
63
  if (this.emitSignals) {
62
- const params = linq_1.length(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
63
- yield `${this.expression.value}.Signal(${eventName}${params}).Wait(); if( ${this.expression.value}.Token.IsCancellationRequested ) { return; }`;
64
+ const params = (0, linq_1.length)(additionalParameters) > 0 ? `, ${additionalParameters.joinWith(each => typeof each === 'string' ? each : each.value)}` : '';
65
+ yield `${this.expression.value}.Signal(${eventName}${params}).Wait(); if( ${this.expression.value}.Token.IsCancellationRequested ) { return${this.withResult ? ' null' : ''}; }`;
64
66
  }
65
67
  else {
66
68
  yield `if( ${this.expression.value}.CancellationToken.IsCancellationRequested ) { throw ${codegen_csharp_13.System.OperationCanceledException.new()} }`;
@@ -69,20 +71,25 @@ class EventListener {
69
71
  }
70
72
  exports.EventListener = EventListener;
71
73
  class OperationMethod extends codegen_csharp_3.Method {
72
- constructor(parent, operation, viaIdentity, state, objectInitializer) {
73
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
74
- super(viaIdentity ? `${(_a = operation.language.csharp) === null || _a === void 0 ? void 0 : _a.name}ViaIdentity` : ((_b = operation.language.csharp) === null || _b === void 0 ? void 0 : _b.name) || '', codegen_csharp_13.System.Threading.Tasks.Task());
74
+ constructor(parent, operation, viaIdentity, state, viaJson = false, withResult, objectInitializer) {
75
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
76
+ super(viaJson
77
+ ? `${(_a = operation.language.csharp) === null || _a === void 0 ? void 0 : _a.name}ViaJsonString${withResult ? 'WithResult' : ''}`
78
+ : viaIdentity
79
+ ? `${(_b = operation.language.csharp) === null || _b === void 0 ? void 0 : _b.name}ViaIdentity${withResult ? 'WithResult' : ''}`
80
+ : `${(_c = operation.language.csharp) === null || _c === void 0 ? void 0 : _c.name}${withResult ? 'WithResult' : ''}` || '', withResult ? codegen_csharp_13.System.Threading.Tasks.Task(ResolveResponseType(undefined, operation, state)) : codegen_csharp_13.System.Threading.Tasks.Task());
75
81
  this.parent = parent;
76
82
  this.operation = operation;
77
83
  this.viaIdentity = viaIdentity;
78
84
  this.state = state;
85
+ this.viaJson = viaJson;
79
86
  this.callbacks = new Array();
80
87
  this.apply(objectInitializer);
81
88
  this.async = codegen_csharp_1.Modifier.Async;
82
- this.returnsDescription = `A <see cref="${codegen_csharp_13.System.Threading.Tasks.Task()}" /> that will be complete when handling of the response is completed.`;
89
+ this.returnsDescription = `A <see cref="${withResult ? codegen_csharp_13.System.Threading.Tasks.Task(ResolveResponseType(undefined, operation, state)) : codegen_csharp_13.System.Threading.Tasks.Task()}" /> that will be complete when handling of the response is completed.`;
83
90
  const $this = this;
84
- this.callName = `${(_c = operation.language.csharp) === null || _c === void 0 ? void 0 : _c.name}_Call`;
85
- this.push(codegen_csharp_11.Using('NoSynchronizationContext', ''));
91
+ this.callName = `${(_d = operation.language.csharp) === null || _d === void 0 ? void 0 : _d.name}${withResult ? 'WithResult' : ''}_Call`;
92
+ this.push((0, codegen_csharp_11.Using)('NoSynchronizationContext', ''));
86
93
  // add parameters
87
94
  this.methodParameters = [];
88
95
  const identity = new codegen_csharp_4.Parameter('viaIdentity', codegen_csharp_13.System.String);
@@ -90,20 +97,37 @@ class OperationMethod extends codegen_csharp_3.Method {
90
97
  this.addParameter(identity);
91
98
  }
92
99
  let baseUrl = '';
93
- for (let index = 0; index < linq_1.length(this.operation.parameters) && this.operation.parameters; index++) {
100
+ const paths = [];
101
+ const headers = [];
102
+ const queries = [];
103
+ const others = [];
104
+ for (let index = 0; index < (0, linq_1.length)(this.operation.parameters) && this.operation.parameters; index++) {
94
105
  const value = this.operation.parameters[index];
95
106
  if (value.language.default.name === '$host') {
96
107
  baseUrl = value.clientDefaultValue;
97
108
  continue;
98
109
  }
99
110
  const p = new parameter_1.OperationParameter(this, value, this.state.path('parameters', index));
100
- if ((_d = value.language.csharp) === null || _d === void 0 ? void 0 : _d.constantValue) {
111
+ if ((_e = value.language.csharp) === null || _e === void 0 ? void 0 : _e.constantValue) {
101
112
  const constTd = state.project.modelsNamespace.NewResolveTypeDeclaration(value.schema, true, state);
102
- p.defaultInitializer = constTd.deserializeFromString(codemodel_v3_2.KnownMediaType.UriParameter, new codegen_csharp_2.StringExpression(`${value.language.csharp.constantValue}`), codegen_csharp_2.toExpression(constTd.defaultOfType));
113
+ p.defaultInitializer = constTd.deserializeFromString(codemodel_v3_2.KnownMediaType.UriParameter, new codegen_csharp_2.StringExpression(`${value.language.csharp.constantValue}`), (0, codegen_csharp_2.toExpression)(constTd.defaultOfType));
103
114
  }
104
115
  // don't add path parameters when we're in identity mode
105
- if (!this.viaIdentity || ((_e = value.protocol.http) === null || _e === void 0 ? void 0 : _e.in) !== codemodel_v3_1.ParameterLocation.Path) {
106
- this.addParameter(p);
116
+ if (!this.viaIdentity || ((_f = value.protocol.http) === null || _f === void 0 ? void 0 : _f.in) !== codemodel_v3_1.ParameterLocation.Path) {
117
+ switch ((_g = value.protocol.http) === null || _g === void 0 ? void 0 : _g.in) {
118
+ case codemodel_v3_1.ParameterLocation.Path:
119
+ paths.push(p);
120
+ break;
121
+ case codemodel_v3_1.ParameterLocation.Header:
122
+ headers.push(p);
123
+ break;
124
+ case codemodel_v3_1.ParameterLocation.Query:
125
+ queries.push(p);
126
+ break;
127
+ default:
128
+ others.push(p);
129
+ break;
130
+ }
107
131
  }
108
132
  else {
109
133
  this.add(function* () {
@@ -112,43 +136,55 @@ class OperationMethod extends codegen_csharp_3.Method {
112
136
  }
113
137
  this.methodParameters.push(p);
114
138
  }
139
+ [...paths, ...headers, ...queries, ...others].forEach(p => this.addParameter(p));
115
140
  if (baseUrl === '') {
116
141
  // Some services will make the host as an input parameter
117
- baseUrl = this.operation.requests ? (_f = this.operation.requests[0].protocol.http) === null || _f === void 0 ? void 0 : _f.uri : '';
142
+ baseUrl = this.operation.requests ? (_h = this.operation.requests[0].protocol.http) === null || _h === void 0 ? void 0 : _h.uri : '';
118
143
  }
119
- this.description = ((_g = this.operation.language.csharp) === null || _g === void 0 ? void 0 : _g.description) || '';
144
+ this.description = ((_j = this.operation.language.csharp) === null || _j === void 0 ? void 0 : _j.description) || '';
120
145
  // add body paramter if there should be one.
121
146
  if (this.operation.requests && this.operation.requests.length && this.operation.requests[0].parameters && this.operation.requests[0].parameters.length) {
122
147
  // this request does have a request body.
123
148
  const param = this.operation.requests[0].parameters.find((p) => !p.origin || p.origin.indexOf('modelerfour:synthesized') < 0);
124
149
  if (param) {
125
- this.bodyParameter = new parameter_1.OperationBodyParameter(this, 'body', param.language.default.description, param.schema, (_h = param.required) !== null && _h !== void 0 ? _h : false, this.state, {
126
- // TODO: temp solution. We need a class like NewKnowMediaType
127
- mediaType: codemodel_v3_2.knownMediaType(codemodel_v3_2.KnownMediaType.Json),
128
- contentType: codemodel_v3_2.KnownMediaType.Json
129
- });
130
- this.addParameter(this.bodyParameter);
150
+ if (!viaJson) {
151
+ this.bodyParameter = new parameter_1.OperationBodyParameter(this, 'body', param.language.default.description, param.schema, (_k = param.required) !== null && _k !== void 0 ? _k : false, this.state, {
152
+ // TODO: temp solution. We need a class like NewKnowMediaType
153
+ mediaType: (0, codemodel_v3_2.knownMediaType)(codemodel_v3_2.KnownMediaType.Json),
154
+ contentType: codemodel_v3_2.KnownMediaType.Json
155
+ });
156
+ this.addParameter(this.bodyParameter);
157
+ }
158
+ else {
159
+ this.addParameter(new codegen_csharp_4.Parameter('jsonString', codegen_csharp_13.System.String, {
160
+ description: `Json string supplied to the ${(_l = operation.language.csharp) === null || _l === void 0 ? void 0 : _l.name} operation`,
161
+ }));
162
+ }
131
163
  }
132
164
  }
133
- for (const response of [...linq_1.values(this.operation.responses), ...linq_1.values(this.operation.exceptions)]) {
165
+ for (const response of [...(0, linq_1.values)(this.operation.responses), ...(0, linq_1.values)(this.operation.exceptions)]) {
134
166
  const responseType = response.binary ? new binary_1.Binary(new codemodel_1.BinarySchema(''), true) : (response.schema ? state.project.modelsNamespace.NewResolveTypeDeclaration((response.schema), true, state) : null);
135
167
  const headerType = response.language.default.headerSchema ? state.project.modelsNamespace.NewResolveTypeDeclaration(response.language.default.headerSchema, true, state) : null;
136
- const newCallbackParameter = new parameter_1.CallbackParameter(((_j = response.language.csharp) === null || _j === void 0 ? void 0 : _j.name) || '', responseType, headerType, this.state, { description: (_k = response.language.csharp) === null || _k === void 0 ? void 0 : _k.description });
137
- this.addParameter(newCallbackParameter);
168
+ const newCallbackParameter = new parameter_1.CallbackParameter(((_m = response.language.csharp) === null || _m === void 0 ? void 0 : _m.name) || '', responseType, headerType, this.state, { description: (_o = response.language.csharp) === null || _o === void 0 ? void 0 : _o.description });
169
+ if (!withResult) {
170
+ this.addParameter(newCallbackParameter);
171
+ }
138
172
  this.callbacks.push(newCallbackParameter);
139
173
  }
140
174
  // add eventhandler parameter
141
175
  this.contextParameter = this.addParameter(new codegen_csharp_4.Parameter('eventListener', clientruntime_1.ClientRuntime.IEventListener, { description: `an <see cref="${clientruntime_1.ClientRuntime.IEventListener}" /> instance that will receive events.` }));
142
176
  // add optional parameter for sender
143
177
  this.senderParameter = this.addParameter(new codegen_csharp_4.Parameter('sender', clientruntime_1.ClientRuntime.ISendAsync, { description: `an instance of an ${clientruntime_1.ClientRuntime.ISendAsync} pipeline to use to make the request.` }));
144
- let rx = this.operation.requests ? (_l = this.operation.requests[0].protocol.http) === null || _l === void 0 ? void 0 : _l.path : '';
178
+ let rx = this.operation.requests ? (_p = this.operation.requests[0].protocol.http) === null || _p === void 0 ? void 0 : _p.path : '';
145
179
  const path = rx;
180
+ let pathWithoutOperation = path;
146
181
  // For post API, Some URI may contain an action string .e.x '/start' at the end
147
182
  // of the URI, for such cases, we will drop the action string if identityCorrection
148
183
  // is set in the configuration
149
- if (this.operation.requests && this.operation.requests.length && ((_m = this.operation.requests[0].protocol.http) === null || _m === void 0 ? void 0 : _m.method) === 'post' && this.state.project.identityCorrection) {
184
+ if (this.operation.requests && this.operation.requests.length && ((_q = this.operation.requests[0].protocol.http) === null || _q === void 0 ? void 0 : _q.method) === 'post' && this.state.project.identityCorrection) {
150
185
  const idx = rx.lastIndexOf('/');
151
186
  rx = rx.substr(0, idx);
187
+ pathWithoutOperation = rx;
152
188
  }
153
189
  let url = `/${path.startsWith('/') ? path.substr(1) : path}`;
154
190
  const serverParams = this.methodParameters.filter(each => { var _a; return ((_a = each.param.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === codemodel_v3_1.ParameterLocation.Uri; });
@@ -189,14 +225,14 @@ class OperationMethod extends codegen_csharp_3.Method {
189
225
  // add method implementation...
190
226
  this.add(function* () {
191
227
  var _a;
192
- const eventListener = new EventListener($this.contextParameter, $this.state.project.emitSignals);
228
+ const eventListener = new EventListener($this.contextParameter, $this.state.project.emitSignals, withResult);
193
229
  yield codegen_1.EOL;
194
230
  if ($this.viaIdentity) {
195
231
  yield '// verify that Identity format is an exact match for uri';
196
232
  yield codegen_1.EOL;
197
- const match = codegen_csharp_12.Local('_match', `${codegen_csharp_13.System.Text.RegularExpressions.Regex.new(rx, 'global::System.Text.RegularExpressions.RegexOptions.IgnoreCase').value}.Match(${identity.value})`);
233
+ const match = (0, codegen_csharp_12.Local)('_match', `${codegen_csharp_13.System.Text.RegularExpressions.Regex.new(rx, 'global::System.Text.RegularExpressions.RegexOptions.IgnoreCase').value}.Match(${identity.value})`);
198
234
  yield match.declarationStatement;
199
- yield codegen_csharp_7.If(`!${match}.Success`, `throw new global::System.Exception("Invalid identity for URI '${path}'");`);
235
+ yield (0, codegen_csharp_7.If)(`!${match}.Success`, `throw new global::System.Exception("Invalid identity for URI '${pathWithoutOperation}'");`);
200
236
  yield codegen_1.EOL;
201
237
  yield '// replace URI parameters with values from identity';
202
238
  for (const pp of pathParams) {
@@ -204,7 +240,7 @@ class OperationMethod extends codegen_csharp_3.Method {
204
240
  }
205
241
  }
206
242
  yield '// construct URL';
207
- const pathAndQueryV = codegen_csharp_12.Local('pathAndQuery', `${codegen_csharp_13.System.Text.RegularExpressions.Regex.declaration}.Replace(
243
+ const pathAndQueryV = (0, codegen_csharp_12.Local)('pathAndQuery', `${codegen_csharp_13.System.Text.RegularExpressions.Regex.declaration}.Replace(
208
244
  "${url}"
209
245
  ${queryParams.length > 0 ? '+ "?"' : ''}${queryParams.joinWith(pp => `
210
246
  + ${removeEncoding(pp, pp.param.language.default.serializedName, codemodel_v3_2.KnownMediaType.QueryParameter)}`, `
@@ -223,7 +259,7 @@ class OperationMethod extends codegen_csharp_3.Method {
223
259
  yield `var request = ${codegen_csharp_13.System.Net.Http.HttpRequestMessage.new(`${clientruntime_1.ClientRuntime.fullName}.Method.${method.capitalize()}, ${urlV.value}`)};`;
224
260
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.RequestCreated, 'request.RequestUri.PathAndQuery');
225
261
  yield codegen_1.EOL;
226
- if (linq_1.length(headerParams) > 0) {
262
+ if ((0, linq_1.length)(headerParams) > 0) {
227
263
  yield '// add headers parameters';
228
264
  for (const hp of headerParams) {
229
265
  if (hp.param.language.default.name === 'Content-Length') {
@@ -241,18 +277,24 @@ class OperationMethod extends codegen_csharp_3.Method {
241
277
  yield `request.Content.Headers.ContentType = ${codegen_csharp_13.System.Net.Http.Headers.MediaTypeHeaderValue.Parse(bp.contentType)};`;
242
278
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.BodyContentSet);
243
279
  }
280
+ if (viaJson) {
281
+ yield '// set body content';
282
+ yield 'request.Content = new global::System.Net.Http.StringContent(jsonString, global::System.Text.Encoding.UTF8);';
283
+ yield 'request.Content.Headers.ContentType = global::System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");';
284
+ yield eventListener.signal(clientruntime_1.ClientRuntime.Events.BodyContentSet);
285
+ }
244
286
  yield '// make the call ';
245
287
  });
246
288
  }
247
- emitCall(returnFromCall) {
289
+ emitCall(returnFromCall, withResult) {
248
290
  // storage will return from the call for download, etc.
249
291
  if (returnFromCall) {
250
292
  this.returnType = codegen_csharp_13.System.Threading.Tasks.Task(codegen_csharp_13.System.Net.Http.HttpResponseMessage);
251
293
  }
252
- this.add(`await this.${this.callName}(request,${this.callbacks.joinWith(each => each.use, ',')},${this.contextParameter.use},${this.senderParameter.use});`);
294
+ this.add(`${withResult ? 'return ' : ''}await this.${this.callName} (request, ${withResult ? '' : `${this.callbacks.joinWith(each => each.use, ',')},`}${this.contextParameter.use},${this.senderParameter.use}); `);
253
295
  // remove constant parameters and make them locals instead.
254
296
  this.insert('// Constant Parameters');
255
- for (let i = linq_1.length(this.parameters); i--; i < 0) {
297
+ for (let i = (0, linq_1.length)(this.parameters); i--; i < 0) {
256
298
  const p = this.parameters[i];
257
299
  if (p && p.defaultInitializer && p.name !== 'serializationMode') {
258
300
  this.parameters.splice(i, 1);
@@ -262,77 +304,118 @@ class OperationMethod extends codegen_csharp_3.Method {
262
304
  }
263
305
  }
264
306
  exports.OperationMethod = OperationMethod;
307
+ function ResolveResponseType(opMethod, operation, state) {
308
+ let typeCount = 0;
309
+ let responseType = undefined;
310
+ if (opMethod) {
311
+ opMethod.callbacks.filter(each => each.name !== 'onDefault').forEach(each => {
312
+ if (each.responseType && responseType && each.responseType !== responseType) {
313
+ typeCount++;
314
+ }
315
+ else if (each.responseType && !responseType) {
316
+ responseType = each.responseType;
317
+ typeCount = 1;
318
+ }
319
+ });
320
+ }
321
+ else if (operation && state) {
322
+ for (const response of [...(0, linq_1.values)(operation.responses), ...(0, linq_1.values)(operation.exceptions)].filter(each => { var _a, _b; return ((_b = (_a = each.language) === null || _a === void 0 ? void 0 : _a.csharp) === null || _b === void 0 ? void 0 : _b.name) !== 'onDefault'; })) {
323
+ const eachResponseType = response.binary ? new binary_1.Binary(new codemodel_1.BinarySchema(''), true) : (response.schema ? state.project.modelsNamespace.NewResolveTypeDeclaration((response.schema), true, state) : undefined);
324
+ if (eachResponseType && responseType && eachResponseType !== responseType) {
325
+ typeCount++;
326
+ }
327
+ else if (eachResponseType && !responseType) {
328
+ responseType = eachResponseType;
329
+ typeCount = 1;
330
+ }
331
+ }
332
+ }
333
+ return typeCount === 1 ? responseType : undefined;
334
+ }
335
+ exports.ResolveResponseType = ResolveResponseType;
265
336
  class CallMethod extends codegen_csharp_3.Method {
266
- constructor(parent, opMethod, state, objectInitializer) {
267
- super(`${opMethod.name}_Call`, codegen_csharp_13.System.Threading.Tasks.Task());
337
+ constructor(parent, opMethod, state, objectInitializer, withResult) {
338
+ super(`${opMethod.name}_Call`, withResult && ResolveResponseType(opMethod) ? codegen_csharp_13.System.Threading.Tasks.Task(ResolveResponseType(opMethod)) : codegen_csharp_13.System.Threading.Tasks.Task());
268
339
  this.parent = parent;
269
340
  this.opMethod = opMethod;
270
341
  this.state = state;
271
342
  this.returnNull = false;
272
- this.description = `Actual wire call for <see cref="${opMethod.name}" /> method.`;
343
+ this.description = `Actual wire call for <see cref= "${opMethod.name}" /> method.`;
273
344
  this.returnsDescription = opMethod.returnsDescription;
274
345
  this.apply(objectInitializer);
275
346
  this.access = codegen_csharp_1.Access.Internal;
276
347
  this.async = codegen_csharp_1.Modifier.Async;
277
- this.push(codegen_csharp_11.Using('NoSynchronizationContext', ''));
348
+ this.push((0, codegen_csharp_11.Using)('NoSynchronizationContext', ''));
278
349
  const $this = this;
279
350
  // add parameters
280
351
  // request, listener, sender
281
352
  const reqParameter = this.addParameter(new codegen_csharp_4.Parameter('request', codegen_csharp_13.System.Net.Http.HttpRequestMessage, { description: 'the prepared HttpRequestMessage to send.' }));
282
- opMethod.callbacks.forEach(each => this.addParameter(each));
353
+ if (!withResult) {
354
+ opMethod.callbacks.forEach(each => this.addParameter(each));
355
+ }
283
356
  this.addParameter(opMethod.contextParameter);
284
357
  this.addParameter(opMethod.senderParameter);
285
358
  // add statements to this method
286
359
  this.add(function* () {
287
- const eventListener = new EventListener(opMethod.contextParameter, $this.state.project.emitSignals);
288
- const response = codegen_csharp_12.Local('_response', codegen_csharp_13.dotnet.Null, codegen_csharp_13.System.Net.Http.HttpResponseMessage);
360
+ const eventListener = new EventListener(opMethod.contextParameter, $this.state.project.emitSignals, withResult);
361
+ const response = (0, codegen_csharp_12.Local)('_response', codegen_csharp_13.dotnet.Null, codegen_csharp_13.System.Net.Http.HttpResponseMessage);
289
362
  yield response;
290
- yield codegen_csharp_10.Try(function* () {
363
+ yield (0, codegen_csharp_10.Try)(function* () {
291
364
  var _a, _b, _c, _d, _e;
292
365
  const responder = function* () {
293
366
  // TODO: omit generating _contentType var if it will never be used
294
367
  // const contentType = new LocalVariable('_contentType', dotnet.Var, { initializer: `_response.Content.Headers.ContentType?.MediaType` });
295
- const contentType = codegen_csharp_12.Local('_contentType', `${response}.Content.Headers.ContentType?.MediaType`);
368
+ const contentType = (0, codegen_csharp_12.Local)('_contentType', `${response}.Content.Headers.ContentType?.MediaType`);
296
369
  yield contentType;
297
370
  // add response handlers
298
- yield codegen_csharp_9.Switch(`${response}.StatusCode`, function* () {
299
- var _a, _b;
300
- const responses = [...linq_1.values(opMethod.operation.responses), ...linq_1.values(opMethod.operation.exceptions)].sort(function (a, b) { var _a, _b; return ((_a = a.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]).localeCompare(((_b = b.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0])); });
371
+ yield (0, codegen_csharp_9.Switch)(`${response}.StatusCode`, function* () {
372
+ var _a;
373
+ const responses = [...(0, linq_1.values)(opMethod.operation.responses), ...(0, linq_1.values)(opMethod.operation.exceptions)].sort(function (a, b) { var _a, _b; return ((_a = a.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]).localeCompare(((_b = b.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0])); });
301
374
  for (const resp of responses) {
302
- if (((_a = resp.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]) !== 'default') {
303
- const responseCode = (_b = resp.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0];
375
+ const responseCode = (_a = resp.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0];
376
+ if (responseCode !== 'default' /*TODO: !== not found, handle other exception response */) {
304
377
  const leadNum = parseInt(responseCode[0]);
305
378
  // will use enum when it can, fall back to casting int when it can't
306
- yield codegen_csharp_5.Case(codegen_csharp_13.System.Net.HttpStatusCode[responseCode] ? codegen_csharp_13.System.Net.HttpStatusCode[responseCode].value : `${codegen_csharp_13.System.Net.HttpStatusCode.declaration} n when((int)n >= ${leadNum * 100} && (int)n < ${leadNum * 100 + 100})`, $this.responsesEmitter($this, opMethod, [resp], eventListener));
379
+ if (withResult) {
380
+ yield (0, codegen_csharp_5.TerminalCase)(codegen_csharp_13.System.Net.HttpStatusCode[responseCode] ? codegen_csharp_13.System.Net.HttpStatusCode[responseCode].value : `${codegen_csharp_13.System.Net.HttpStatusCode.declaration} n when((int)n >= ${leadNum * 100} && (int)n < ${leadNum * 100 + 100})`, $this.responsesEmitter($this, opMethod, [resp], response, eventListener, withResult));
381
+ }
382
+ else {
383
+ yield (0, codegen_csharp_5.Case)(codegen_csharp_13.System.Net.HttpStatusCode[responseCode] ? codegen_csharp_13.System.Net.HttpStatusCode[responseCode].value : `${codegen_csharp_13.System.Net.HttpStatusCode.declaration} n when((int)n >= ${leadNum * 100} && (int)n < ${leadNum * 100 + 100})`, $this.responsesEmitter($this, opMethod, [resp], response, eventListener, false));
384
+ }
307
385
  }
308
386
  else {
309
- yield codegen_csharp_5.DefaultCase($this.responsesEmitter($this, opMethod, [resp], eventListener));
387
+ if (withResult) {
388
+ yield (0, codegen_csharp_5.TerminalDefaultCase)($this.responsesEmitter($this, opMethod, [resp], response, eventListener, withResult));
389
+ }
390
+ else {
391
+ yield (0, codegen_csharp_5.DefaultCase)($this.responsesEmitter($this, opMethod, [resp], response, eventListener, false));
392
+ }
310
393
  }
311
394
  }
312
395
  // missing default response?
313
396
  if (!opMethod.operation.exceptions) {
314
397
  // if no default, we need one that handles the rest of the stuff.
315
- yield codegen_csharp_5.TerminalDefaultCase(function* () {
398
+ yield (0, codegen_csharp_5.TerminalDefaultCase)(function* () {
316
399
  yield `throw new ${clientruntime_1.ClientRuntime.fullName}.UndeclaredResponseException(_response);`;
317
400
  });
318
401
  }
319
402
  });
320
403
  };
321
404
  // try statements
322
- const sendTask = codegen_csharp_12.Local('sendTask', new codegen_csharp_2.LiteralExpression(`${opMethod.senderParameter.value}.SendAsync(${reqParameter.use}, ${opMethod.contextParameter.value})`));
405
+ const sendTask = (0, codegen_csharp_12.Local)('sendTask', new codegen_csharp_2.LiteralExpression(`${opMethod.senderParameter.value}.SendAsync(${reqParameter.use}, ${opMethod.contextParameter.value})`));
323
406
  yield sendTask;
324
407
  // delay sending BeforeCall event until URI has been replaced by HTTP pipeline
325
408
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.BeforeCall, reqParameter.use);
326
409
  if ((_a = $this.opMethod.operation.language.csharp) === null || _a === void 0 ? void 0 : _a.lro) {
327
410
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.Progress, new codegen_csharp_2.LiteralExpression('"intentional placeholder"'), new codegen_csharp_2.LiteralExpression('0'));
328
411
  }
329
- yield `${response.value} = await ${sendTask.value};`;
412
+ yield `${response.value} = await ${sendTask.value}; `;
330
413
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.ResponseCreated, response.value);
331
414
  const EOL = 'EOL';
332
415
  // LRO processing (if appropriate)
333
416
  if ((_b = $this.opMethod.operation.language.csharp) === null || _b === void 0 ? void 0 : _b.lro) {
334
417
  yield '// this operation supports x-ms-long-running-operation';
335
- const originalUri = codegen_csharp_12.Local('_originalUri', new codegen_csharp_2.LiteralExpression(`${reqParameter.use}.RequestUri.AbsoluteUri`));
418
+ const originalUri = (0, codegen_csharp_12.Local)('_originalUri', new codegen_csharp_2.LiteralExpression(`${reqParameter.use}.RequestUri.AbsoluteUri`));
336
419
  yield originalUri;
337
420
  yield `// declared final-state-via: ${$this.opMethod.operation.language.csharp.lro['final-state-via']}`;
338
421
  const fsv = $this.opMethod.operation.language.csharp.lro['final-state-via'];
@@ -344,7 +427,7 @@ class CallMethod extends codegen_csharp_3.Method {
344
427
  break;
345
428
  case 'location':
346
429
  // perform a final GET on the uri in Location header
347
- finalUri = codegen_csharp_12.Local('_finalUri', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
430
+ finalUri = (0, codegen_csharp_12.Local)('_finalUri', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
348
431
  yield finalUri;
349
432
  break;
350
433
  case 'azure-asyncoperation':
@@ -353,7 +436,7 @@ class CallMethod extends codegen_csharp_3.Method {
353
436
  switch ((_d = (_c = $this.opMethod.operation.requests) === null || _c === void 0 ? void 0 : _c[0].protocol.http) === null || _d === void 0 ? void 0 : _d.method.toLowerCase()) {
354
437
  case 'post':
355
438
  case 'delete':
356
- finalUri = codegen_csharp_12.Local('_finalUri', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Azure-AsyncOperation')));
439
+ finalUri = (0, codegen_csharp_12.Local)('_finalUri', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Azure-AsyncOperation')));
357
440
  yield finalUri;
358
441
  break;
359
442
  case 'patch':
@@ -369,7 +452,7 @@ class CallMethod extends codegen_csharp_3.Method {
369
452
  switch ((_e = $this.opMethod.operation.requests[0].protocol.http) === null || _e === void 0 ? void 0 : _e.method.toLowerCase()) {
370
453
  case 'post':
371
454
  case 'delete':
372
- finalUri = codegen_csharp_12.Local('_finalUri', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
455
+ finalUri = (0, codegen_csharp_12.Local)('_finalUri', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
373
456
  yield finalUri;
374
457
  break;
375
458
  case 'patch':
@@ -381,11 +464,11 @@ class CallMethod extends codegen_csharp_3.Method {
381
464
  }
382
465
  break;
383
466
  }
384
- const asyncOperation = codegen_csharp_12.Local('asyncOperation', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Azure-AsyncOperation')));
467
+ const asyncOperation = (0, codegen_csharp_12.Local)('asyncOperation', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Azure-AsyncOperation')));
385
468
  yield asyncOperation;
386
- const location = codegen_csharp_12.Local('location', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
469
+ const location = (0, codegen_csharp_12.Local)('location', response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
387
470
  yield location;
388
- yield codegen_csharp_7.While(new codegen_csharp_2.LiteralExpression(`${reqParameter.use}.Method == System.Net.Http.HttpMethod.Put && ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[200].value} || ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[201].value} || ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[202].value} `), function* () {
471
+ yield (0, codegen_csharp_7.While)(new codegen_csharp_2.LiteralExpression(`${reqParameter.use}.Method == System.Net.Http.HttpMethod.Put && ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[200].value} || ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[201].value} || ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[202].value} `), function* () {
389
472
  yield '// delay before making the next polling request';
390
473
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.DelayBeforePolling, response.value);
391
474
  yield EOL;
@@ -396,12 +479,12 @@ class CallMethod extends codegen_csharp_3.Method {
396
479
  yield 'if (!global::System.String.IsNullOrEmpty(_response.GetFirstHeader(@"Location"))) {';
397
480
  yield ' ' + location.assign(response.invokeMethod('GetFirstHeader', new codegen_csharp_2.StringExpression('Location')));
398
481
  yield '}';
399
- const uriLocal = codegen_csharp_12.Local('_uri', codegen_csharp_14.Ternery(codegen_csharp_13.System.String.IsNullOrEmpty(asyncOperation), codegen_csharp_14.Ternery(codegen_csharp_13.System.String.IsNullOrEmpty(location), originalUri, location), asyncOperation));
482
+ const uriLocal = (0, codegen_csharp_12.Local)('_uri', (0, codegen_csharp_14.Ternery)(codegen_csharp_13.System.String.IsNullOrEmpty(asyncOperation), (0, codegen_csharp_14.Ternery)(codegen_csharp_13.System.String.IsNullOrEmpty(location), originalUri, location), asyncOperation));
400
483
  yield uriLocal;
401
484
  yield `${reqParameter.use} = ${reqParameter.use}.CloneAndDispose(${codegen_csharp_13.System.Uri.new(uriLocal)}, ${clientruntime_1.ClientRuntime.Method.Get});`;
402
485
  yield EOL;
403
486
  yield '// and let\'s look at the current response body and see if we have some information we can give back to the listener';
404
- const content = codegen_csharp_12.Local('content', new codegen_csharp_2.LiteralExpression(`await ${response.value}.Content.ReadAsStringAsync()`));
487
+ const content = (0, codegen_csharp_12.Local)('content', new codegen_csharp_2.LiteralExpression(`await ${response.value}.Content.ReadAsStringAsync()`));
405
488
  yield content;
406
489
  yield EOL;
407
490
  yield '// drop the old response';
@@ -412,48 +495,48 @@ class CallMethod extends codegen_csharp_3.Method {
412
495
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.Polling, response.value);
413
496
  yield EOL;
414
497
  yield `
415
- // if we got back an OK, take a peek inside and see if it's done
416
- if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode.OK})
417
- {
418
- var error = false;
419
- try {
420
- if( ${clientruntime_1.ClientRuntime.JsonNode.Parse(codegen_csharp_2.toExpression(`await ${response.value}.Content.ReadAsStringAsync()`))} is ${clientruntime_1.ClientRuntime.JsonObject} json)
421
- {
422
- var state = json.Property("properties")?.PropertyT<${clientruntime_1.ClientRuntime.JsonString}>("provisioningState") ?? json.PropertyT<${clientruntime_1.ClientRuntime.JsonString}>("status");
423
- if( state is null )
424
- {
425
- // the body doesn't contain any information that has the state of the LRO
426
- // we're going to just get out, and let the consumer have the result
427
- break;
428
- }
498
+ // if we got back an OK, take a peek inside and see if it's done
499
+ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode.OK})
500
+ {
501
+ var error = false;
502
+ try {
503
+ if( ${clientruntime_1.ClientRuntime.JsonNode.Parse((0, codegen_csharp_2.toExpression)(`await ${response.value}.Content.ReadAsStringAsync()`))} is ${clientruntime_1.ClientRuntime.JsonObject} json)
504
+ {
505
+ var state = json.Property("properties")?.PropertyT<${clientruntime_1.ClientRuntime.JsonString}>("provisioningState") ?? json.PropertyT<${clientruntime_1.ClientRuntime.JsonString}>("status");
506
+ if( state is null )
507
+ {
508
+ // the body doesn't contain any information that has the state of the LRO
509
+ // we're going to just get out, and let the consumer have the result
510
+ break;
511
+ }
429
512
 
430
- switch( state?.ToString()?.ToLower() )
431
- {
432
- case "failed":
433
- error = true;
513
+ switch( state?.ToString()?.ToLower() )
514
+ {
515
+ case "failed":
516
+ error = true;
517
+ break;
518
+ case "succeeded":
519
+ case "canceled":
520
+ // we're done polling.
434
521
  break;
435
- case "succeeded":
436
- case "canceled":
437
- // we're done polling.
438
- break;
439
522
 
440
- default:
441
- // need to keep polling!
442
- ${response.value}.StatusCode = ${codegen_csharp_13.System.Net.HttpStatusCode.Created};
443
- continue;
444
- }
445
- }
446
- } catch {
447
- // if we run into a problem peeking into the result,
448
- // we really don't want to do anything special.
449
- }
450
- if (error) {
451
- throw new ${clientruntime_1.ClientRuntime.fullName}.UndeclaredResponseException(${response.value});
452
- }
453
- }`;
523
+ default:
524
+ // need to keep polling!
525
+ ${response.value}.StatusCode = ${codegen_csharp_13.System.Net.HttpStatusCode.Created};
526
+ continue;
527
+ }
528
+ }
529
+ } catch {
530
+ // if we run into a problem peeking into the result,
531
+ // we really don't want to do anything special.
532
+ }
533
+ if (error) {
534
+ throw new ${clientruntime_1.ClientRuntime.fullName}.UndeclaredResponseException(${response.value});
535
+ }
536
+ }`;
454
537
  yield EOL;
455
538
  yield '// check for terminal status code';
456
- yield codegen_csharp_7.If(new codegen_csharp_2.LiteralExpression(`${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[201].value} || ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[202].value} `), 'continue;');
539
+ yield (0, codegen_csharp_7.If)(new codegen_csharp_2.LiteralExpression(`${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[201].value} || ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCode[202].value} `), 'continue;');
457
540
  yield '// we are done polling, do a request on final target?';
458
541
  switch (fsv) {
459
542
  case 'original-uri':
@@ -464,7 +547,7 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
464
547
  yield $this.finalGet(eventListener, finalUri, reqParameter, response);
465
548
  break;
466
549
  default:
467
- yield codegen_csharp_7.If(`!string.IsNullOrWhiteSpace(${finalUri})`, function* () {
550
+ yield (0, codegen_csharp_7.If)(`!string.IsNullOrWhiteSpace(${finalUri})`, function* () {
468
551
  yield $this.finalGet(eventListener, finalUri, reqParameter, response);
469
552
  });
470
553
  break;
@@ -474,50 +557,50 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
474
557
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.Progress, new codegen_csharp_2.LiteralExpression('"intentional placeholder"'), new codegen_csharp_2.LiteralExpression('100'));
475
558
  yield responder();
476
559
  });
477
- yield codegen_csharp_6.Finally(function* () {
560
+ yield (0, codegen_csharp_6.Finally)(function* () {
478
561
  yield '// finally statements';
479
562
  yield eventListener.signalNoCheck(clientruntime_1.ClientRuntime.Events.Finally, 'request', '_response');
480
563
  yield `${response.value}?.Dispose();`;
481
564
  yield `${reqParameter.use}?.Dispose();`;
482
565
  });
483
566
  if ($this.returnNull) {
484
- yield codegen_csharp_8.Return('result');
567
+ yield (0, codegen_csharp_8.Return)('result');
485
568
  $this.insert(new codegen_csharp_12.LocalVariable('result', codegen_csharp_13.System.Net.Http.HttpResponseMessage, { initializer: codegen_csharp_13.dotnet.Null }));
486
569
  }
487
570
  });
488
- this.opMethod.emitCall($this.returnNull);
571
+ this.opMethod.emitCall($this.returnNull, withResult);
489
572
  }
490
573
  *finalGet(eventListener, finalLocation, reqParameter, response) {
491
574
  yield '// create a new request with the final uri';
492
- yield reqParameter.assign(`${codegen_csharp_2.valueOf(reqParameter)}.CloneAndDispose(${codegen_csharp_13.System.Uri.new(finalLocation)}, ${clientruntime_1.ClientRuntime.Method.Get})`);
575
+ yield reqParameter.assign(`${(0, codegen_csharp_2.valueOf)(reqParameter)}.CloneAndDispose(${codegen_csharp_13.System.Uri.new(finalLocation)}, ${clientruntime_1.ClientRuntime.Method.Get})`);
493
576
  yield codegen_1.EOL;
494
577
  yield '// drop the old response';
495
578
  yield `${response.value}?.Dispose();`;
496
579
  yield codegen_1.EOL;
497
580
  yield '// make the final call';
498
- yield response.assign(`await ${this.opMethod.senderParameter}.SendAsync(${codegen_csharp_2.valueOf(reqParameter)}, ${this.opMethod.contextParameter})`);
581
+ yield response.assign(`await ${this.opMethod.senderParameter}.SendAsync(${(0, codegen_csharp_2.valueOf)(reqParameter)}, ${this.opMethod.contextParameter})`);
499
582
  yield eventListener.signal(clientruntime_1.ClientRuntime.Events.Polling, response.value);
500
583
  // make sure we're not polling anymore.
501
584
  yield 'break;';
502
585
  }
503
- *responsesEmitter($this, opMethod, responses, eventListener) {
586
+ *responsesEmitter($this, opMethod, responses, responseVariable, eventListener, withResult) {
504
587
  var _a;
505
- if (linq_1.length(responses) > 1) {
506
- yield codegen_csharp_9.Switch('_contentType', function* () {
588
+ if ((0, linq_1.length)(responses) > 1) {
589
+ yield (0, codegen_csharp_9.Switch)('_contentType', function* () {
507
590
  var _a, _b, _c, _d;
508
- for (const eachResponse of linq_1.values(responses)) {
509
- const mimetype = linq_1.length((_a = eachResponse.protocol.http) === null || _a === void 0 ? void 0 : _a.mediaTypes) > 0 ? (_b = eachResponse.protocol.http) === null || _b === void 0 ? void 0 : _b.mimeTypes[0] : '';
510
- const callbackParameter = linq_1.values(opMethod.callbacks).first(each => { var _a; return each.name === ((_a = eachResponse.language.csharp) === null || _a === void 0 ? void 0 : _a.name); });
511
- let count = linq_1.length((_c = eachResponse.protocol.http) === null || _c === void 0 ? void 0 : _c.mediaTypes);
512
- for (const mt of linq_1.values((_d = eachResponse.protocol.http) === null || _d === void 0 ? void 0 : _d.mediaTypes)) {
591
+ for (const eachResponse of (0, linq_1.values)(responses)) {
592
+ const mimetype = (0, linq_1.length)((_a = eachResponse.protocol.http) === null || _a === void 0 ? void 0 : _a.mediaTypes) > 0 ? (_b = eachResponse.protocol.http) === null || _b === void 0 ? void 0 : _b.mimeTypes[0] : '';
593
+ const callbackParameter = (0, linq_1.values)(opMethod.callbacks).first(each => { var _a; return each.name === ((_a = eachResponse.language.csharp) === null || _a === void 0 ? void 0 : _a.name); });
594
+ let count = (0, linq_1.length)((_c = eachResponse.protocol.http) === null || _c === void 0 ? void 0 : _c.mediaTypes);
595
+ for (const mt of (0, linq_1.values)((_d = eachResponse.protocol.http) === null || _d === void 0 ? void 0 : _d.mediaTypes)) {
513
596
  count--;
514
- const mediaType = codemodel_v3_2.normalizeMediaType(mt);
597
+ const mediaType = (0, codemodel_v3_2.normalizeMediaType)(mt);
515
598
  if (mediaType) {
516
599
  if (count === 0) {
517
- yield codegen_csharp_5.Case(new codegen_csharp_2.StringExpression(mediaType).toString(), $this.NewResponseHandler(mimetype, eachResponse, callbackParameter));
600
+ yield (0, codegen_csharp_5.Case)(new codegen_csharp_2.StringExpression(mediaType).toString(), $this.NewResponseHandler(mimetype, eachResponse, callbackParameter, responseVariable, withResult));
518
601
  }
519
602
  else {
520
- yield codegen_csharp_5.TerminalCase(new codegen_csharp_2.StringExpression(mediaType).toString(), '');
603
+ yield (0, codegen_csharp_5.TerminalCase)(new codegen_csharp_2.StringExpression(mediaType).toString(), '');
521
604
  }
522
605
  }
523
606
  }
@@ -526,17 +609,17 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
526
609
  }
527
610
  else {
528
611
  const response = responses[0];
529
- const callbackParameter = linq_1.values(opMethod.callbacks).first(each => { var _a; return each.name === ((_a = response.language.csharp) === null || _a === void 0 ? void 0 : _a.name); });
612
+ const callbackParameter = (0, linq_1.values)(opMethod.callbacks).first(each => { var _a; return each.name === ((_a = response.language.csharp) === null || _a === void 0 ? void 0 : _a.name); });
530
613
  // all mimeTypes per for this response code.
531
- yield eventListener.signal(clientruntime_1.ClientRuntime.Events.BeforeResponseDispatch, '_response');
532
- yield $this.NewResponseHandler(linq_1.values((_a = response.protocol.http) === null || _a === void 0 ? void 0 : _a.mediaTypes).first() || '', response, callbackParameter);
614
+ yield eventListener.signal(clientruntime_1.ClientRuntime.Events.BeforeResponseDispatch, responseVariable.value);
615
+ yield $this.NewResponseHandler((0, linq_1.values)((_a = response.protocol.http) === null || _a === void 0 ? void 0 : _a.mediaTypes).first() || '', response, callbackParameter, responseVariable, withResult);
533
616
  }
534
617
  }
535
618
  *responseHandlerForNormalPipeline(mimetype, eachResponse, callbackParameter) {
536
619
  const callbackParameters = new Array();
537
620
  if (callbackParameter.responseType) {
538
621
  // hande the body response
539
- const r = callbackParameter.responseType.deserializeFromResponse(codemodel_v3_2.knownMediaType(mimetype), codegen_csharp_2.toExpression('_response'), codegen_csharp_2.toExpression('null'));
622
+ const r = callbackParameter.responseType.deserializeFromResponse((0, codemodel_v3_2.knownMediaType)(mimetype), (0, codegen_csharp_2.toExpression)('_response'), (0, codegen_csharp_2.toExpression)('null'));
540
623
  if (r) {
541
624
  callbackParameters.push(r);
542
625
  }
@@ -547,7 +630,7 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
547
630
  }
548
631
  if (callbackParameter.headerType) {
549
632
  // header model deserialization...
550
- const r = callbackParameter.headerType.deserializeFromResponse(codemodel_v3_2.KnownMediaType.Header, codegen_csharp_2.toExpression('_response'), codegen_csharp_2.toExpression('null'));
633
+ const r = callbackParameter.headerType.deserializeFromResponse(codemodel_v3_2.KnownMediaType.Header, (0, codegen_csharp_2.toExpression)('_response'), (0, codegen_csharp_2.toExpression)('null'));
551
634
  if (r) {
552
635
  callbackParameters.push(r);
553
636
  }
@@ -555,12 +638,12 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
555
638
  // make the callback with the appropriate parameters
556
639
  yield `await ${eachResponse.details.csharp.name}(_response${callbackParameters.length === 0 ? '' : ','}${callbackParameters.joinWith(codegen_csharp_2.valueOf)});`;
557
640
  }
558
- *NewResponseHandlerForNormalPipeline(mimetype, eachResponse, callbackParameter) {
641
+ *NewResponseHandlerForNormalPipeline(mimetype, eachResponse, callbackParameter, responseVariable) {
559
642
  var _a;
560
643
  const callbackParameters = new Array();
561
644
  if (callbackParameter.responseType) {
562
645
  // hande the body response
563
- const r = callbackParameter.responseType.deserializeFromResponse(codemodel_v3_2.knownMediaType(mimetype), codegen_csharp_2.toExpression('_response'), codegen_csharp_2.toExpression('null'));
646
+ const r = callbackParameter.responseType.deserializeFromResponse((0, codemodel_v3_2.knownMediaType)(mimetype), (0, codegen_csharp_2.toExpression)(responseVariable.value), (0, codegen_csharp_2.toExpression)('null'));
564
647
  if (r) {
565
648
  callbackParameters.push(r);
566
649
  }
@@ -571,7 +654,7 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
571
654
  }
572
655
  if (callbackParameter.headerType) {
573
656
  // header model deserialization...
574
- const r = callbackParameter.headerType.deserializeFromResponse(codemodel_v3_2.KnownMediaType.Header, codegen_csharp_2.toExpression('_response'), codegen_csharp_2.toExpression('null'));
657
+ const r = callbackParameter.headerType.deserializeFromResponse(codemodel_v3_2.KnownMediaType.Header, (0, codegen_csharp_2.toExpression)(responseVariable.value), (0, codegen_csharp_2.toExpression)('null'));
575
658
  if (r) {
576
659
  callbackParameters.push(r);
577
660
  }
@@ -579,11 +662,70 @@ if( ${response.value}.StatusCode == ${codegen_csharp_13.System.Net.HttpStatusCod
579
662
  // make the callback with the appropriate parameters
580
663
  yield `await ${(_a = eachResponse.language.csharp) === null || _a === void 0 ? void 0 : _a.name}(_response${callbackParameters.length === 0 ? '' : ','}${callbackParameters.joinWith(codegen_csharp_2.valueOf)});`;
581
664
  }
665
+ *NewResponseHandlerWithResult(mimetype, response, callbackParameter, responseVariable) {
666
+ var _a, _b, _c, _d;
667
+ const responseType = callbackParameter.responseType;
668
+ if (!responseType) {
669
+ yield `throw new ${clientruntime_1.ClientRuntime.fullName}.UndeclaredResponseException(${responseVariable.value});`;
670
+ return;
671
+ }
672
+ const deserializeResponseAsync = responseType.deserializeFromResponse((0, codemodel_v3_2.knownMediaType)(mimetype), (0, codegen_csharp_2.toExpression)(responseVariable.value), (0, codegen_csharp_2.toExpression)('null'));
673
+ yield `var _result = ${deserializeResponseAsync};`;
674
+ switch ((_a = response.protocol.http) === null || _a === void 0 ? void 0 : _a.statusCodes[0]) {
675
+ case 'default': {
676
+ // this should write an error to the error channel.
677
+ yield `// Error Response : ${(_b = response.protocol.http) === null || _b === void 0 ? void 0 : _b.statusCodes[0]}`;
678
+ const unexpected = function* () {
679
+ yield '// Unrecognized Response. Create an error record based on what we have.';
680
+ const ex = responseType ?
681
+ (0, codegen_csharp_12.Local)('ex', `new ${clientruntime_1.ClientRuntime.name}.RestException<${responseType}>(${responseVariable.value}, await _result)`) :
682
+ (0, codegen_csharp_12.Local)('ex', `new ${clientruntime_1.ClientRuntime.name}.RestException(responseMessage)`);
683
+ yield ex.declarationStatement;
684
+ yield `throw ${ex};`;
685
+ };
686
+ if (response.schema !== undefined) {
687
+ // the schema should be the error information.
688
+ // this supports both { error { message, code} } and { message, code}
689
+ let props = (0, schema_1.getAllPublicVirtualProperties)((_c = response.schema.language.csharp) === null || _c === void 0 ? void 0 : _c.virtualProperties);
690
+ const errorProperty = (0, linq_1.values)(props).first(p => p.property.serializedName === 'error');
691
+ let ep = '';
692
+ if (errorProperty) {
693
+ props = (0, schema_1.getAllPublicVirtualProperties)((_d = errorProperty.property.schema.language.csharp) === null || _d === void 0 ? void 0 : _d.virtualProperties);
694
+ ep = `${errorProperty.name}?.`;
695
+ }
696
+ const codeProp = props.find(p => p.name.toLowerCase().indexOf('code') > -1); // first property with 'code'
697
+ const messageProp = props.find(p => p.name.toLowerCase().indexOf('message') > -1); // first property with 'message'
698
+ const actionProp = props.find(p => p.name.toLowerCase().indexOf('action') > -1); // first property with 'action'
699
+ if (codeProp && messageProp) {
700
+ const lcode = new codegen_csharp_12.LocalVariable('code', codegen_csharp_13.dotnet.Var, { initializer: `(await _result)?.${ep}${codeProp.name}` });
701
+ const lmessage = new codegen_csharp_12.LocalVariable('message', codegen_csharp_13.dotnet.Var, { initializer: `(await _result)?.${ep}${messageProp.name}` });
702
+ const laction = actionProp ? new codegen_csharp_12.LocalVariable('action', codegen_csharp_13.dotnet.Var, { initializer: `(await _result)?.${ep}${actionProp.name} ?? ${codegen_csharp_13.System.String.Empty}` }) : undefined;
703
+ yield lcode;
704
+ yield lmessage;
705
+ yield laction;
706
+ yield (0, codegen_csharp_7.If)((0, codegen_csharp_1.Or)((0, codegen_csharp_1.IsNull)(lcode), ((0, codegen_csharp_1.IsNull)(lmessage))), unexpected);
707
+ yield (0, codegen_csharp_1.Else)(`throw new global::System.Exception($"[{${lcode}}] : {${lmessage}}");`);
708
+ }
709
+ else {
710
+ yield unexpected;
711
+ }
712
+ }
713
+ else {
714
+ yield unexpected;
715
+ }
716
+ break;
717
+ }
718
+ default: {
719
+ yield 'return await _result;';
720
+ break;
721
+ }
722
+ }
723
+ }
582
724
  responseHandler(mimetype, eachResponse, callbackParameter) {
583
725
  return this.responseHandlerForNormalPipeline(mimetype, eachResponse, callbackParameter);
584
726
  }
585
- NewResponseHandler(mimetype, eachResponse, callbackParameter) {
586
- return this.NewResponseHandlerForNormalPipeline(mimetype, eachResponse, callbackParameter);
727
+ NewResponseHandler(mimetype, eachResponse, callbackParameter, responseVariable, withResult) {
728
+ return withResult ? this.NewResponseHandlerWithResult(mimetype, eachResponse, callbackParameter, responseVariable) : this.NewResponseHandlerForNormalPipeline(mimetype, eachResponse, callbackParameter, responseVariable);
587
729
  }
588
730
  }
589
731
  exports.CallMethod = CallMethod;
@@ -598,7 +740,7 @@ class ValidationMethod extends codegen_csharp_3.Method {
598
740
  this.returnsDescription = opMethod.returnsDescription;
599
741
  this.access = codegen_csharp_1.Access.Internal;
600
742
  this.async = codegen_csharp_1.Modifier.Async;
601
- this.push(codegen_csharp_11.Using('NoSynchronizationContext', ''));
743
+ this.push((0, codegen_csharp_11.Using)('NoSynchronizationContext', ''));
602
744
  // add the method parameters
603
745
  for (const parameter of opMethod.methodParameters) {
604
746
  if (!parameter.defaultInitializer) {