@alloy-js/csharp 0.20.0-dev.1 → 0.20.0-dev.10

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 (391) hide show
  1. package/dist/src/components/Declaration.d.ts +2 -2
  2. package/dist/src/components/Declaration.d.ts.map +1 -1
  3. package/dist/src/components/Declaration.js +5 -14
  4. package/dist/src/components/Declaration.js.map +1 -0
  5. package/dist/src/components/Name.js +2 -1
  6. package/dist/src/components/Name.js.map +1 -0
  7. package/dist/src/components/ProjectDirectory.js +2 -1
  8. package/dist/src/components/ProjectDirectory.js.map +1 -0
  9. package/dist/src/components/Reference.d.ts.map +1 -1
  10. package/dist/src/components/Reference.js +7 -2
  11. package/dist/src/components/Reference.js.map +1 -0
  12. package/dist/src/components/UsingDirective.d.ts +5 -1
  13. package/dist/src/components/UsingDirective.d.ts.map +1 -1
  14. package/dist/src/components/UsingDirective.js +5 -2
  15. package/dist/src/components/UsingDirective.js.map +1 -0
  16. package/dist/src/components/access-expression/access-expression.d.ts +54 -0
  17. package/dist/src/components/access-expression/access-expression.d.ts.map +1 -0
  18. package/dist/src/components/access-expression/access-expression.js +277 -0
  19. package/dist/src/components/access-expression/access-expression.js.map +1 -0
  20. package/dist/src/components/access-expression/access-expression.test.d.ts +2 -0
  21. package/dist/src/components/access-expression/access-expression.test.d.ts.map +1 -0
  22. package/dist/src/components/access-expression/access-expression.test.js +336 -0
  23. package/dist/src/components/access-expression/access-expression.test.js.map +1 -0
  24. package/dist/src/components/access-expression/part-descriptors.d.ts +32 -0
  25. package/dist/src/components/access-expression/part-descriptors.d.ts.map +1 -0
  26. package/dist/src/components/access-expression/part-descriptors.js +99 -0
  27. package/dist/src/components/access-expression/part-descriptors.js.map +1 -0
  28. package/dist/src/components/attributes/attributes.js +2 -1
  29. package/dist/src/components/attributes/attributes.js.map +1 -0
  30. package/dist/src/components/attributes/attributes.test.js +2 -1
  31. package/dist/src/components/attributes/attributes.test.js.map +1 -0
  32. package/dist/src/components/class/declaration.d.ts +2 -2
  33. package/dist/src/components/class/declaration.d.ts.map +1 -1
  34. package/dist/src/components/class/declaration.js +21 -34
  35. package/dist/src/components/class/declaration.js.map +1 -0
  36. package/dist/src/components/class/declaration.test.js +199 -200
  37. package/dist/src/components/class/declaration.test.js.map +1 -0
  38. package/dist/src/components/constructor/constructor.d.ts.map +1 -1
  39. package/dist/src/components/constructor/constructor.js +13 -20
  40. package/dist/src/components/constructor/constructor.js.map +1 -0
  41. package/dist/src/components/constructor/constructor.test.js +12 -20
  42. package/dist/src/components/constructor/constructor.test.js.map +1 -0
  43. package/dist/src/components/doc/comment.js +2 -1
  44. package/dist/src/components/doc/comment.js.map +1 -0
  45. package/dist/src/components/doc/comment.test.js +2 -1
  46. package/dist/src/components/doc/comment.test.js.map +1 -0
  47. package/dist/src/components/doc/from-markdown.js +2 -1
  48. package/dist/src/components/doc/from-markdown.js.map +1 -0
  49. package/dist/src/components/doc/from-markdown.test.js +2 -1
  50. package/dist/src/components/doc/from-markdown.test.js.map +1 -0
  51. package/dist/src/components/{EnumDeclaration.d.ts → enum/declaration.d.ts} +6 -11
  52. package/dist/src/components/enum/declaration.d.ts.map +1 -0
  53. package/dist/src/components/enum/declaration.js +55 -0
  54. package/dist/src/components/enum/declaration.js.map +1 -0
  55. package/dist/src/components/enum/declaration.ref.test.d.ts +2 -0
  56. package/dist/src/components/enum/declaration.ref.test.d.ts.map +1 -0
  57. package/dist/src/components/enum/declaration.ref.test.js +121 -0
  58. package/dist/src/components/enum/declaration.ref.test.js.map +1 -0
  59. package/dist/src/components/enum/declaration.test.d.ts +2 -0
  60. package/dist/src/components/enum/declaration.test.d.ts.map +1 -0
  61. package/dist/src/components/enum/declaration.test.js +40 -0
  62. package/dist/src/components/enum/declaration.test.js.map +1 -0
  63. package/dist/src/components/enum/member.d.ts +7 -0
  64. package/dist/src/components/enum/member.d.ts.map +1 -0
  65. package/dist/src/components/enum/member.js +30 -0
  66. package/dist/src/components/enum/member.js.map +1 -0
  67. package/dist/src/components/enum/member.test.d.ts +2 -0
  68. package/dist/src/components/enum/member.test.d.ts.map +1 -0
  69. package/dist/src/components/enum/member.test.js +29 -0
  70. package/dist/src/components/enum/member.test.js.map +1 -0
  71. package/dist/src/components/field/field.d.ts.map +1 -1
  72. package/dist/src/components/field/field.js +11 -18
  73. package/dist/src/components/field/field.js.map +1 -0
  74. package/dist/src/components/field/field.test.js +9 -8
  75. package/dist/src/components/field/field.test.js.map +1 -0
  76. package/dist/src/components/index.d.ts +7 -3
  77. package/dist/src/components/index.d.ts.map +1 -1
  78. package/dist/src/components/index.js +9 -4
  79. package/dist/src/components/index.js.map +1 -0
  80. package/dist/src/components/interface/declaration.d.ts.map +1 -1
  81. package/dist/src/components/interface/declaration.js +21 -22
  82. package/dist/src/components/interface/declaration.js.map +1 -0
  83. package/dist/src/components/interface/declaration.test.js +28 -36
  84. package/dist/src/components/interface/declaration.test.js.map +1 -0
  85. package/dist/src/components/interface/method.d.ts.map +1 -1
  86. package/dist/src/components/interface/method.js +9 -19
  87. package/dist/src/components/interface/method.js.map +1 -0
  88. package/dist/src/components/interface/method.test.js +40 -48
  89. package/dist/src/components/interface/method.test.js.map +1 -0
  90. package/dist/src/components/interface/property.d.ts.map +1 -1
  91. package/dist/src/components/interface/property.js +23 -40
  92. package/dist/src/components/interface/property.js.map +1 -0
  93. package/dist/src/components/interface/property.test.js +13 -12
  94. package/dist/src/components/interface/property.test.js.map +1 -0
  95. package/dist/src/components/invocation-expression/invocation-expression.d.ts +29 -0
  96. package/dist/src/components/invocation-expression/invocation-expression.d.ts.map +1 -0
  97. package/dist/src/components/invocation-expression/invocation-expression.js +70 -0
  98. package/dist/src/components/invocation-expression/invocation-expression.js.map +1 -0
  99. package/dist/src/components/invocation-expression/invocation-expression.test.d.ts +2 -0
  100. package/dist/src/components/invocation-expression/invocation-expression.test.d.ts.map +1 -0
  101. package/dist/src/components/invocation-expression/invocation-expression.test.js +105 -0
  102. package/dist/src/components/invocation-expression/invocation-expression.test.js.map +1 -0
  103. package/dist/src/components/lexical-scope.d.ts +8 -0
  104. package/dist/src/components/lexical-scope.d.ts.map +1 -0
  105. package/dist/src/components/lexical-scope.js +25 -0
  106. package/dist/src/components/lexical-scope.js.map +1 -0
  107. package/dist/src/components/method/method.d.ts +5 -2
  108. package/dist/src/components/method/method.d.ts.map +1 -1
  109. package/dist/src/components/method/method.js +9 -17
  110. package/dist/src/components/method/method.js.map +1 -0
  111. package/dist/src/components/method/method.test.js +13 -12
  112. package/dist/src/components/method/method.test.js.map +1 -0
  113. package/dist/src/components/method-scope.d.ts +8 -0
  114. package/dist/src/components/method-scope.d.ts.map +1 -0
  115. package/dist/src/components/method-scope.js +25 -0
  116. package/dist/src/components/method-scope.js.map +1 -0
  117. package/dist/src/components/namespace-scopes.d.ts +13 -0
  118. package/dist/src/components/namespace-scopes.d.ts.map +1 -0
  119. package/dist/src/components/namespace-scopes.js +45 -0
  120. package/dist/src/components/namespace-scopes.js.map +1 -0
  121. package/dist/src/components/namespace.d.ts +7 -0
  122. package/dist/src/components/namespace.d.ts.map +1 -0
  123. package/dist/src/components/namespace.js +47 -0
  124. package/dist/src/components/namespace.js.map +1 -0
  125. package/dist/src/components/namespace.ref.test.d.ts +2 -0
  126. package/dist/src/components/namespace.ref.test.d.ts.map +1 -0
  127. package/dist/src/components/namespace.ref.test.js +182 -0
  128. package/dist/src/components/namespace.ref.test.js.map +1 -0
  129. package/dist/src/components/namespace.test.d.ts.map +1 -0
  130. package/dist/src/components/namespace.test.js +79 -0
  131. package/dist/src/components/namespace.test.js.map +1 -0
  132. package/dist/src/components/parameters/parameters.d.ts +2 -3
  133. package/dist/src/components/parameters/parameters.d.ts.map +1 -1
  134. package/dist/src/components/parameters/parameters.js +15 -15
  135. package/dist/src/components/parameters/parameters.js.map +1 -0
  136. package/dist/src/components/parameters/parameters.test.d.ts +2 -0
  137. package/dist/src/components/parameters/parameters.test.d.ts.map +1 -0
  138. package/dist/src/components/parameters/parameters.test.js +154 -0
  139. package/dist/src/components/parameters/parameters.test.js.map +1 -0
  140. package/dist/src/components/property/property.d.ts +2 -2
  141. package/dist/src/components/property/property.d.ts.map +1 -1
  142. package/dist/src/components/property/property.js +30 -40
  143. package/dist/src/components/property/property.js.map +1 -0
  144. package/dist/src/components/property/property.test.js +16 -15
  145. package/dist/src/components/property/property.test.js.map +1 -0
  146. package/dist/src/components/record/declaration.d.ts +18 -0
  147. package/dist/src/components/record/declaration.d.ts.map +1 -1
  148. package/dist/src/components/record/declaration.js +21 -14
  149. package/dist/src/components/record/declaration.js.map +1 -0
  150. package/dist/src/components/record/declaration.test.js +52 -4
  151. package/dist/src/components/record/declaration.test.js.map +1 -0
  152. package/dist/src/components/source-file/source-file.d.ts +19 -0
  153. package/dist/src/components/source-file/source-file.d.ts.map +1 -0
  154. package/dist/src/components/source-file/source-file.js +59 -0
  155. package/dist/src/components/source-file/source-file.js.map +1 -0
  156. package/dist/src/components/source-file/source-file.test.d.ts +2 -0
  157. package/dist/src/components/source-file/source-file.test.d.ts.map +1 -0
  158. package/dist/src/components/source-file/source-file.test.js +136 -0
  159. package/dist/src/components/source-file/source-file.test.js.map +1 -0
  160. package/dist/src/components/stc/index.js +2 -1
  161. package/dist/src/components/stc/index.js.map +1 -0
  162. package/dist/src/components/struct/declaration.d.ts.map +1 -1
  163. package/dist/src/components/struct/declaration.js +6 -7
  164. package/dist/src/components/struct/declaration.js.map +1 -0
  165. package/dist/src/components/struct/declaration.test.js +32 -40
  166. package/dist/src/components/struct/declaration.test.js.map +1 -0
  167. package/dist/src/components/type-parameters/type-parameter-constraints.js +2 -1
  168. package/dist/src/components/type-parameters/type-parameter-constraints.js.map +1 -0
  169. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +2 -1
  170. package/dist/src/components/type-parameters/type-parameter-constraints.test.js.map +1 -0
  171. package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -1
  172. package/dist/src/components/type-parameters/type-parameter.js +9 -11
  173. package/dist/src/components/type-parameters/type-parameter.js.map +1 -0
  174. package/dist/src/components/type-parameters/type-parameters.js +2 -1
  175. package/dist/src/components/type-parameters/type-parameters.js.map +1 -0
  176. package/dist/src/components/type-parameters/type-parameters.test.js +5 -4
  177. package/dist/src/components/type-parameters/type-parameters.test.js.map +1 -0
  178. package/dist/src/components/var/declaration.d.ts.map +1 -1
  179. package/dist/src/components/var/declaration.js +8 -9
  180. package/dist/src/components/var/declaration.js.map +1 -0
  181. package/dist/src/components/var/declaration.test.js +13 -21
  182. package/dist/src/components/var/declaration.test.js.map +1 -0
  183. package/dist/src/contexts/format-options.d.ts +5 -0
  184. package/dist/src/contexts/format-options.d.ts.map +1 -0
  185. package/dist/src/contexts/format-options.js +9 -0
  186. package/dist/src/contexts/format-options.js.map +1 -0
  187. package/dist/src/contexts/global-namespace.d.ts +5 -0
  188. package/dist/src/contexts/global-namespace.d.ts.map +1 -0
  189. package/dist/src/contexts/global-namespace.js +25 -0
  190. package/dist/src/contexts/global-namespace.js.map +1 -0
  191. package/dist/src/contexts/namespace.d.ts +8 -0
  192. package/dist/src/contexts/namespace.d.ts.map +1 -0
  193. package/dist/src/contexts/namespace.js +6 -0
  194. package/dist/src/contexts/namespace.js.map +1 -0
  195. package/dist/src/index.d.ts +2 -0
  196. package/dist/src/index.d.ts.map +1 -1
  197. package/dist/src/index.js +4 -1
  198. package/dist/src/index.js.map +1 -0
  199. package/dist/src/modifiers.d.ts +11 -0
  200. package/dist/src/modifiers.d.ts.map +1 -1
  201. package/dist/src/modifiers.js +2 -1
  202. package/dist/src/modifiers.js.map +1 -0
  203. package/dist/src/name-policy.js +2 -1
  204. package/dist/src/name-policy.js.map +1 -0
  205. package/dist/src/scopes/class.d.ts +10 -0
  206. package/dist/src/scopes/class.d.ts.map +1 -0
  207. package/dist/src/scopes/class.js +11 -0
  208. package/dist/src/scopes/class.js.map +1 -0
  209. package/dist/src/scopes/contexts.d.ts +9 -0
  210. package/dist/src/scopes/contexts.d.ts.map +1 -0
  211. package/dist/src/scopes/contexts.js +34 -0
  212. package/dist/src/scopes/contexts.js.map +1 -0
  213. package/dist/src/scopes/csharp.d.ts +10 -0
  214. package/dist/src/scopes/csharp.d.ts.map +1 -0
  215. package/dist/src/scopes/csharp.js +15 -0
  216. package/dist/src/scopes/csharp.js.map +1 -0
  217. package/dist/src/scopes/factories.d.ts +9 -0
  218. package/dist/src/scopes/factories.d.ts.map +1 -0
  219. package/dist/src/scopes/factories.js +24 -0
  220. package/dist/src/scopes/factories.js.map +1 -0
  221. package/dist/src/scopes/index.d.ts +10 -0
  222. package/dist/src/scopes/index.d.ts.map +1 -0
  223. package/dist/src/scopes/index.js +10 -0
  224. package/dist/src/scopes/index.js.map +1 -0
  225. package/dist/src/scopes/lexical.d.ts +7 -0
  226. package/dist/src/scopes/lexical.d.ts.map +1 -0
  227. package/dist/src/scopes/lexical.js +8 -0
  228. package/dist/src/scopes/lexical.js.map +1 -0
  229. package/dist/src/scopes/method.d.ts +9 -0
  230. package/dist/src/scopes/method.d.ts.map +1 -0
  231. package/dist/src/scopes/method.js +14 -0
  232. package/dist/src/scopes/method.js.map +1 -0
  233. package/dist/src/scopes/named-type.d.ts +22 -0
  234. package/dist/src/scopes/named-type.d.ts.map +1 -0
  235. package/dist/src/scopes/named-type.js +33 -0
  236. package/dist/src/scopes/named-type.js.map +1 -0
  237. package/dist/src/scopes/namespace.d.ts +11 -0
  238. package/dist/src/scopes/namespace.d.ts.map +1 -0
  239. package/dist/src/scopes/namespace.js +39 -0
  240. package/dist/src/scopes/namespace.js.map +1 -0
  241. package/dist/src/scopes/source-file.d.ts +16 -0
  242. package/dist/src/scopes/source-file.d.ts.map +1 -0
  243. package/dist/src/scopes/source-file.js +44 -0
  244. package/dist/src/scopes/source-file.js.map +1 -0
  245. package/dist/src/symbols/csharp.d.ts +87 -0
  246. package/dist/src/symbols/csharp.d.ts.map +1 -0
  247. package/dist/src/symbols/csharp.js +246 -0
  248. package/dist/src/symbols/csharp.js.map +1 -0
  249. package/dist/src/symbols/factories.d.ts +25 -0
  250. package/dist/src/symbols/factories.d.ts.map +1 -0
  251. package/dist/src/symbols/factories.js +93 -0
  252. package/dist/src/symbols/factories.js.map +1 -0
  253. package/dist/src/symbols/index.d.ts +5 -2
  254. package/dist/src/symbols/index.d.ts.map +1 -1
  255. package/dist/src/symbols/index.js +6 -2
  256. package/dist/src/symbols/index.js.map +1 -0
  257. package/dist/src/symbols/method.d.ts +13 -0
  258. package/dist/src/symbols/method.d.ts.map +1 -0
  259. package/dist/src/symbols/method.js +16 -0
  260. package/dist/src/symbols/method.js.map +1 -0
  261. package/dist/src/symbols/named-type.d.ts +19 -0
  262. package/dist/src/symbols/named-type.d.ts.map +1 -0
  263. package/dist/src/symbols/named-type.js +31 -0
  264. package/dist/src/symbols/named-type.js.map +1 -0
  265. package/dist/src/symbols/namespace.d.ts +22 -0
  266. package/dist/src/symbols/namespace.d.ts.map +1 -0
  267. package/dist/src/symbols/namespace.js +45 -0
  268. package/dist/src/symbols/namespace.js.map +1 -0
  269. package/dist/src/symbols/reference.d.ts +2 -2
  270. package/dist/src/symbols/reference.d.ts.map +1 -1
  271. package/dist/src/symbols/reference.js +50 -44
  272. package/dist/src/symbols/reference.js.map +1 -0
  273. package/dist/test/project-directory.test.js +20 -19
  274. package/dist/test/project-directory.test.js.map +1 -0
  275. package/dist/test/using.test.js +23 -21
  276. package/dist/test/using.test.js.map +1 -0
  277. package/dist/test/utils.d.ts.map +1 -1
  278. package/dist/test/utils.js +7 -4
  279. package/dist/test/utils.js.map +1 -0
  280. package/dist/test/vitest.setup.js +2 -1
  281. package/dist/test/vitest.setup.js.map +1 -0
  282. package/dist/tsconfig.tsbuildinfo +1 -1
  283. package/package.json +12 -6
  284. package/src/components/Declaration.tsx +3 -6
  285. package/src/components/Reference.tsx +3 -1
  286. package/src/components/UsingDirective.tsx +12 -2
  287. package/src/components/access-expression/access-expression.test.tsx +284 -0
  288. package/src/components/access-expression/access-expression.tsx +375 -0
  289. package/src/components/access-expression/part-descriptors.ts +175 -0
  290. package/src/components/class/declaration.test.tsx +142 -150
  291. package/src/components/class/declaration.tsx +20 -32
  292. package/src/components/constructor/constructor.test.tsx +10 -16
  293. package/src/components/constructor/constructor.tsx +13 -32
  294. package/src/components/enum/declaration.ref.test.tsx +93 -0
  295. package/src/components/enum/declaration.test.tsx +34 -0
  296. package/src/components/enum/declaration.tsx +65 -0
  297. package/src/components/enum/member.test.tsx +24 -0
  298. package/src/components/enum/member.tsx +36 -0
  299. package/src/components/field/field.test.tsx +7 -7
  300. package/src/components/field/field.tsx +12 -22
  301. package/src/components/index.ts +7 -3
  302. package/src/components/interface/declaration.test.tsx +26 -32
  303. package/src/components/interface/declaration.tsx +16 -18
  304. package/src/components/interface/method.test.tsx +38 -44
  305. package/src/components/interface/method.tsx +7 -20
  306. package/src/components/interface/property.test.tsx +11 -11
  307. package/src/components/interface/property.tsx +15 -34
  308. package/src/components/invocation-expression/invocation-expression.test.tsx +101 -0
  309. package/src/components/invocation-expression/invocation-expression.tsx +60 -0
  310. package/src/components/lexical-scope.tsx +29 -0
  311. package/src/components/method/method.test.tsx +11 -11
  312. package/src/components/method/method.tsx +12 -23
  313. package/src/components/method-scope.tsx +27 -0
  314. package/src/components/namespace-scopes.tsx +44 -0
  315. package/src/components/namespace.ref.test.tsx +139 -0
  316. package/src/components/namespace.test.tsx +52 -0
  317. package/src/components/namespace.tsx +45 -0
  318. package/src/components/parameters/parameters.test.tsx +117 -0
  319. package/src/components/parameters/parameters.tsx +11 -23
  320. package/src/components/property/property.test.tsx +14 -14
  321. package/src/components/property/property.tsx +23 -41
  322. package/src/components/record/declaration.test.tsx +47 -3
  323. package/src/components/record/declaration.tsx +34 -11
  324. package/src/components/source-file/source-file.test.tsx +96 -0
  325. package/src/components/source-file/source-file.tsx +98 -0
  326. package/src/components/struct/declaration.test.tsx +16 -22
  327. package/src/components/struct/declaration.tsx +4 -6
  328. package/src/components/type-parameters/type-parameter.tsx +14 -11
  329. package/src/components/type-parameters/type-parameters.test.tsx +4 -4
  330. package/src/components/var/declaration.test.tsx +8 -14
  331. package/src/components/var/declaration.tsx +12 -6
  332. package/src/contexts/format-options.ts +14 -0
  333. package/src/contexts/global-namespace.ts +29 -0
  334. package/src/contexts/namespace.ts +13 -0
  335. package/src/index.ts +2 -0
  336. package/src/modifiers.ts +14 -0
  337. package/src/scopes/class.ts +12 -0
  338. package/src/scopes/contexts.ts +45 -0
  339. package/src/scopes/csharp.ts +23 -0
  340. package/src/scopes/factories.ts +45 -0
  341. package/src/scopes/index.ts +9 -0
  342. package/src/scopes/lexical.ts +10 -0
  343. package/src/scopes/method.ts +22 -0
  344. package/src/scopes/named-type.ts +44 -0
  345. package/src/scopes/namespace.ts +59 -0
  346. package/src/scopes/source-file.ts +67 -0
  347. package/src/symbols/csharp.ts +339 -0
  348. package/src/symbols/factories.ts +215 -0
  349. package/src/symbols/index.ts +5 -2
  350. package/src/symbols/method.ts +26 -0
  351. package/src/symbols/named-type.ts +54 -0
  352. package/src/symbols/namespace.ts +62 -0
  353. package/src/symbols/reference.tsx +64 -0
  354. package/temp/api.json +6919 -2532
  355. package/test/project-directory.test.tsx +14 -16
  356. package/test/using.test.tsx +21 -21
  357. package/test/utils.tsx +2 -1
  358. package/tsconfig.json +4 -1
  359. package/tsdoc-metadata.json +1 -1
  360. package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
  361. package/dist/src/components/EnumDeclaration.js +0 -85
  362. package/dist/src/components/Namespace.d.ts +0 -11
  363. package/dist/src/components/Namespace.d.ts.map +0 -1
  364. package/dist/src/components/Namespace.js +0 -33
  365. package/dist/src/components/SourceFile.d.ts +0 -14
  366. package/dist/src/components/SourceFile.d.ts.map +0 -1
  367. package/dist/src/components/SourceFile.js +0 -69
  368. package/dist/src/symbols/csharp-output-symbol.d.ts +0 -8
  369. package/dist/src/symbols/csharp-output-symbol.d.ts.map +0 -1
  370. package/dist/src/symbols/csharp-output-symbol.js +0 -19
  371. package/dist/src/symbols/scopes.d.ts +0 -14
  372. package/dist/src/symbols/scopes.d.ts.map +0 -1
  373. package/dist/src/symbols/scopes.js +0 -31
  374. package/dist/test/enum.test.d.ts +0 -2
  375. package/dist/test/enum.test.d.ts.map +0 -1
  376. package/dist/test/enum.test.js +0 -178
  377. package/dist/test/namespace.test.d.ts.map +0 -1
  378. package/dist/test/namespace.test.js +0 -81
  379. package/dist/test/sourcefile.test.d.ts +0 -2
  380. package/dist/test/sourcefile.test.d.ts.map +0 -1
  381. package/dist/test/sourcefile.test.js +0 -58
  382. package/src/components/EnumDeclaration.tsx +0 -99
  383. package/src/components/Namespace.tsx +0 -35
  384. package/src/components/SourceFile.tsx +0 -78
  385. package/src/symbols/csharp-output-symbol.ts +0 -22
  386. package/src/symbols/reference.ts +0 -65
  387. package/src/symbols/scopes.ts +0 -41
  388. package/test/enum.test.tsx +0 -149
  389. package/test/namespace.test.tsx +0 -55
  390. package/test/sourcefile.test.tsx +0 -47
  391. /package/dist/{test → src/components}/namespace.test.d.ts +0 -0
@@ -0,0 +1,375 @@
1
+ import {
2
+ Children,
3
+ childrenArray,
4
+ ComponentDefinition,
5
+ computed,
6
+ For,
7
+ isComponentCreator,
8
+ Refkey,
9
+ Show,
10
+ takeSymbols,
11
+ } from "@alloy-js/core";
12
+ import { CSharpSymbol } from "../../symbols/csharp.js";
13
+ import {
14
+ childrenToPartDescriptors,
15
+ isArgsPart,
16
+ isIdPart,
17
+ PartDescriptor,
18
+ PartDescriptorWithArgs,
19
+ PartDescriptorWithId,
20
+ PartDescriptorWithIndex,
21
+ } from "./part-descriptors.js";
22
+
23
+ export interface AccessExpressionProps {
24
+ children: Children;
25
+ }
26
+
27
+ export function AccessExpression(props: AccessExpressionProps) {
28
+ const children = flattenAccessExpression(childrenArray(() => props.children));
29
+ const parts = childrenToPartDescriptors(children);
30
+
31
+ // any symbols emitted from the children won't be relevant to parent scopes.
32
+ takeSymbols();
33
+
34
+ if (parts.length === 0) {
35
+ return <></>;
36
+ }
37
+
38
+ const isCallChain = computed(() => {
39
+ let callCount = 0;
40
+ for (const part of parts) {
41
+ if (isArgsPart(part)) callCount++;
42
+ }
43
+
44
+ return callCount > 1;
45
+ });
46
+
47
+ // construct a member expression from the parts. When a part is nullish,
48
+ // and there is a subsequent part, we use `?.` instead of `.`. accessStyle determines
49
+ // whether we use dot or bracket notation.
50
+
51
+ return computed(() => {
52
+ return isCallChain.value ?
53
+ formatCallChain(parts)
54
+ : formatNonCallChain(parts);
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Flattens nested access expressions into a single array of parts.
60
+ */
61
+ function flattenAccessExpression(children: Children[]): Children[] {
62
+ const flattened: Children[] = [];
63
+ for (const child of children) {
64
+ if (isComponentCreator(child, AccessExpression)) {
65
+ flattened.push(
66
+ ...flattenAccessExpression(childrenArray(() => child.props.children)),
67
+ );
68
+ } else {
69
+ flattened.push(child);
70
+ }
71
+ }
72
+ return flattened;
73
+ }
74
+
75
+ export interface AccessExpressionPartProps {
76
+ children?: Children;
77
+ /**
78
+ * Whether this part should use conditional access.
79
+ */
80
+ conditional?: boolean;
81
+ /**
82
+ * Emit a function call.
83
+ */
84
+ args?: boolean | Children[];
85
+
86
+ /**
87
+ * Type arguments to pass to a member access.
88
+ */
89
+ typeArgs?: Children[];
90
+
91
+ /**
92
+ * A refkey for the symbol whose name becomes this part's identifier. When a refkey is provided for the first
93
+ * part, it will be fully resolved. Otherwise, just the symbol's name is used.
94
+ */
95
+ refkey?: Refkey;
96
+
97
+ /**
98
+ * The symbol whose name becomes this part's identifier.
99
+ */
100
+ symbol?: CSharpSymbol;
101
+
102
+ /**
103
+ * The identifier to use for this part.
104
+ */
105
+ id?: string;
106
+
107
+ /**
108
+ * Create an element access part with a single indexer argument. Mutually
109
+ * exclusive with the `indexerArgs` prop.
110
+ */
111
+ index?: Children;
112
+
113
+ /**
114
+ * Create an element access part with multiple indexer arguments. Mutually
115
+ * exclusive with the `index` prop.
116
+ */
117
+ indexerArgs?: Children[];
118
+
119
+ /**
120
+ * Whether this part could possibly be null. Will guard member and element
121
+ * access with a conditional access operator. Passing this is not necessary if
122
+ * you provide a symbol or refkey and the symbol's nullable flag is set.
123
+ */
124
+ nullable?: boolean;
125
+ }
126
+
127
+ AccessExpression.Part = function (props: AccessExpressionPartProps) {
128
+ /** renders nothing, the parent AccessExpression will use these args */
129
+ };
130
+
131
+ /**
132
+ * Formatting of call chains (i.e. member expressions which have more than one
133
+ * call in them). The general approach is that line breaks occur after each
134
+ * call, and there is only one call per line. When there are non-call elements,
135
+ * they occur prior to the call part. The first part of the member expression
136
+ * contains all but the last non-call part.
137
+ *
138
+ * The following is an example of proper formatting:
139
+ *
140
+ * ```ts
141
+ * z.dummy // all but the last non-call part for the first element
142
+ * .object({ // the first call part with line break after
143
+ * a: 1,
144
+ * })
145
+ * .dummy.partial() // the next call part with non-call parts before it
146
+ * ```
147
+ */
148
+ function formatCallChain(parts: PartDescriptor[]): Children {
149
+ return computed(() => {
150
+ const expression: Children[] = [];
151
+
152
+ // break the expression into parts.
153
+ const chunks: PartDescriptor[][] = [];
154
+
155
+ // the first part is all the non-call parts
156
+ let partIndex = 0;
157
+
158
+ function pushPart() {
159
+ const part = parts[partIndex];
160
+ if (!part) throw new Error("No part to push");
161
+ chunks.at(-1)!.push(part);
162
+ partIndex++;
163
+ }
164
+
165
+ function pushChunk() {
166
+ chunks.push([]);
167
+ }
168
+
169
+ // For the first chunk, take all the non-call parts except the last one
170
+ // and put them in a chunk.
171
+ pushChunk();
172
+ while (
173
+ partIndex < parts.length &&
174
+ (partIndex === parts.length - 1 ||
175
+ chunks.at(-1)!.length === 0 ||
176
+ !isArgsPart(parts[partIndex + 1]))
177
+ ) {
178
+ pushPart();
179
+ if (isArgsPart(chunks.at(-1)!.at(-1)!)) {
180
+ // the first segment always ends after we see a call
181
+ // if we happen to take one
182
+ break;
183
+ }
184
+ }
185
+
186
+ // then for all remaining parts, collect all the non-call parts and end with
187
+ // a call chunk
188
+ while (partIndex < parts.length) {
189
+ pushChunk();
190
+ while (partIndex < parts.length && !isArgsPart(parts[partIndex])) {
191
+ pushPart();
192
+ }
193
+ while (partIndex < parts.length && isArgsPart(parts[partIndex])) {
194
+ pushPart();
195
+ }
196
+ }
197
+
198
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
199
+ const chunk = chunks[chunkIndex];
200
+ const chunkExpression = [];
201
+ for (let partIndex = 0; partIndex < chunk.length; partIndex++) {
202
+ if (chunkIndex === 0 && partIndex === 0) {
203
+ // first part is just gonna be the id
204
+ const firstPart =
205
+ isIdPart(chunk[0]) ?
206
+ chunk[0].id
207
+ : (chunk[0] as PartDescriptorWithIndex).indexerArgs;
208
+ chunkExpression.push(firstPart);
209
+ continue;
210
+ }
211
+ const part = chunk[partIndex];
212
+ const prevPart =
213
+ partIndex === 0 ?
214
+ chunks[chunkIndex - 1].at(-1)!
215
+ : chunk[partIndex - 1];
216
+
217
+ if (isArgsPart(part)) {
218
+ // For parts with only args (no name), append function call directly with appropriate nullish operator
219
+ chunkExpression.push(formatCallExpr(prevPart, part));
220
+ } else if (isIdPart(part)) {
221
+ chunkExpression.push(formatMemberAccess(prevPart, part, true));
222
+ } else {
223
+ // bracket notation - don't include the dot
224
+ chunkExpression.push(formatElementAccess(prevPart, part));
225
+ }
226
+ }
227
+
228
+ expression.push(
229
+ chunkIndex === 0 ? chunkExpression : (
230
+ <>
231
+ <sbr />
232
+ {chunkExpression}
233
+ </>
234
+ ),
235
+ );
236
+ }
237
+
238
+ return (
239
+ <group>
240
+ <indent>{expression}</indent>
241
+ </group>
242
+ );
243
+ });
244
+ }
245
+
246
+ function formatNonCallChain(parts: PartDescriptor[]): Children {
247
+ return computed(() => {
248
+ const expression: Children[] = [];
249
+
250
+ for (let i = 0; i < parts.length; i++) {
251
+ const part = parts[i];
252
+ const base =
253
+ isIdPart(part) ?
254
+ part.id
255
+ : (part as PartDescriptorWithIndex).indexerArgs;
256
+ if (i === 0) {
257
+ expression.push(base, <TypeArgs args={(part as any).typeArgs} />);
258
+ } else {
259
+ // Determine if we should use nullish operator from previous part
260
+ const prevPart = parts[i - 1];
261
+
262
+ if (isArgsPart(part)) {
263
+ // For parts with only args (no name), append function call directly with appropriate nullish operator
264
+ expression.push(formatCallExpr(prevPart, part));
265
+ } else if (isIdPart(part)) {
266
+ expression.push(formatMemberAccess(prevPart, part));
267
+ } else {
268
+ // bracket notation - don't include the dot
269
+ expression.push(formatElementAccess(prevPart, part));
270
+ }
271
+ }
272
+ }
273
+
274
+ return expression;
275
+ });
276
+ }
277
+
278
+ function formatElementAccess(
279
+ prevPart: PartDescriptor,
280
+ part: PartDescriptorWithIndex,
281
+ ) {
282
+ return (
283
+ <group>
284
+ {part.conditional || ("nullable" in prevPart && prevPart.nullable) ?
285
+ "?"
286
+ : ""}
287
+ [
288
+ <indent>
289
+ <sbr />
290
+ <For each={part.indexerArgs} comma line>
291
+ {(arg) => arg}
292
+ </For>
293
+ </indent>
294
+ <sbr />]
295
+ </group>
296
+ );
297
+ }
298
+
299
+ function formatMemberAccess(
300
+ prevPart: PartDescriptor,
301
+ part: PartDescriptorWithId,
302
+ noIndent = false,
303
+ ) {
304
+ let Wrapping: ComponentDefinition<{ children: Children }>;
305
+ if (noIndent) {
306
+ Wrapping = function (props) {
307
+ return (
308
+ <group>
309
+ <sbr />
310
+ {props.children}
311
+ </group>
312
+ );
313
+ };
314
+ } else {
315
+ Wrapping = function (props) {
316
+ return (
317
+ <group>
318
+ <indent>
319
+ <sbr />
320
+ {props.children}
321
+ </indent>
322
+ </group>
323
+ );
324
+ };
325
+ }
326
+
327
+ return (
328
+ <Wrapping>
329
+ {part.conditional || ("nullable" in prevPart && prevPart.nullable) ?
330
+ "?."
331
+ : "."}
332
+ {isIdPart(part) ? part.id : (part as PartDescriptorWithIndex).indexerArgs}
333
+ <TypeArgs args={part.typeArgs} />
334
+ </Wrapping>
335
+ );
336
+ }
337
+
338
+ function TypeArgs(props: { args?: Children[] }) {
339
+ return (
340
+ <Show when={props.args && props.args.length > 0}>
341
+ {"<"}
342
+ <group>
343
+ <indent>
344
+ <sbr />
345
+ <For each={props.args!} comma line>
346
+ {(arg) => arg}
347
+ </For>
348
+ </indent>
349
+ <sbr />
350
+ </group>
351
+ {">"}
352
+ </Show>
353
+ );
354
+ }
355
+
356
+ function formatCallExpr(
357
+ prevPart: PartDescriptor,
358
+ part: PartDescriptorWithArgs,
359
+ ) {
360
+ return (
361
+ <group>
362
+ (<Show when={part.args.length <= 1}>{part.args[0]}</Show>
363
+ <Show when={part.args.length > 1}>
364
+ <indent>
365
+ <sbr />
366
+ <For each={part.args} comma line>
367
+ {(arg) => arg}
368
+ </For>
369
+ </indent>
370
+ <sbr />
371
+ </Show>
372
+ )
373
+ </group>
374
+ );
375
+ }
@@ -0,0 +1,175 @@
1
+ import {
2
+ Children,
3
+ computed,
4
+ isComponentCreator,
5
+ reactive,
6
+ ref,
7
+ symbolForRefkey,
8
+ ToRefs,
9
+ } from "@alloy-js/core";
10
+ import { CSharpSymbol } from "../../index.js";
11
+ import {
12
+ AccessExpression,
13
+ AccessExpressionPartProps,
14
+ } from "./access-expression.jsx";
15
+
16
+ export interface PartDescriptorWithId extends PartDescriptorBase {
17
+ /**
18
+ * The identifier of the access expression part. Will use member access, so must be a valid
19
+ * C# identifier.
20
+ */
21
+ id: Children;
22
+ conditional: boolean;
23
+ typeArgs?: Children[];
24
+ }
25
+
26
+ export function isIdPart(part: PartDescriptor): part is PartDescriptorWithId {
27
+ return "id" in part && part.id !== undefined;
28
+ }
29
+
30
+ export interface PartDescriptorWithIndex extends PartDescriptorBase {
31
+ /**
32
+ * The index of the access expression part. Will use element access.
33
+ */
34
+ indexerArgs: Children[];
35
+ conditional: boolean;
36
+ }
37
+
38
+ export function isIndexPart(
39
+ part: PartDescriptor,
40
+ ): part is PartDescriptorWithIndex {
41
+ return "indexerArgs" in part && part.indexerArgs !== undefined;
42
+ }
43
+
44
+ export interface PartDescriptorWithArgs extends PartDescriptorBase {
45
+ args: Children[];
46
+ }
47
+
48
+ export function isArgsPart(
49
+ part: PartDescriptor,
50
+ ): part is PartDescriptorWithArgs {
51
+ return "args" in part && part.args !== undefined;
52
+ }
53
+
54
+ export interface PartDescriptorBase {
55
+ nullable: boolean;
56
+ }
57
+
58
+ export type PartDescriptor =
59
+ | PartDescriptorWithId
60
+ | PartDescriptorWithIndex
61
+ | PartDescriptorWithArgs;
62
+
63
+ /**
64
+ * Build part descriptors from the children of a MemberExpression.
65
+ */
66
+ export function childrenToPartDescriptors(
67
+ children: Children[],
68
+ ): PartDescriptor[] {
69
+ const parts: PartDescriptor[] = [];
70
+ for (const child of children) {
71
+ if (!isComponentCreator(child, AccessExpression.Part)) {
72
+ // we ignore non-parts
73
+ continue;
74
+ }
75
+
76
+ parts.push(
77
+ createPartDescriptorFromProps(child.props, child === children[0]),
78
+ );
79
+ }
80
+
81
+ return parts;
82
+ }
83
+
84
+ const exclusiveParts: (keyof AccessExpressionPartProps)[] = [
85
+ "children",
86
+ "args",
87
+ "refkey",
88
+ "symbol",
89
+ "id",
90
+ ];
91
+ /**
92
+ * Creates a reactive part descriptor from the given part props.
93
+ *
94
+ * @param partProps The props for the part.
95
+ * @param first Whether this is the first part in the expression. Refkeys are
96
+ * handled specially for the first part.
97
+ */
98
+ function createPartDescriptorFromProps(
99
+ partProps: AccessExpressionPartProps,
100
+ first: boolean,
101
+ ) {
102
+ const foundProps = exclusiveParts.filter((key) => {
103
+ return key in partProps;
104
+ });
105
+
106
+ if (foundProps.length > 1) {
107
+ throw new Error(
108
+ `Only one of ${foundProps.join(", ")} can be used for a MemberExpression part at a time`,
109
+ );
110
+ }
111
+
112
+ const symbolSource = computed(() => {
113
+ if (partProps.refkey) {
114
+ return symbolForRefkey(partProps.refkey).value as CSharpSymbol;
115
+ } else if (partProps.symbol) {
116
+ return partProps.symbol;
117
+ } else {
118
+ return undefined;
119
+ }
120
+ });
121
+
122
+ const part: ToRefs<PartDescriptor> = {
123
+ id: computed(() => {
124
+ if (partProps.args || partProps.index || partProps.indexerArgs) {
125
+ return undefined;
126
+ } else if (partProps.children !== undefined) {
127
+ return partProps.children;
128
+ } else if (first && partProps.refkey) {
129
+ return partProps.refkey;
130
+ } else if (partProps.id !== undefined) {
131
+ return partProps.id;
132
+ } else if (symbolSource.value) {
133
+ return escapeId(symbolSource.value.name);
134
+ } else {
135
+ return "<unresolved symbol>";
136
+ }
137
+ }),
138
+ indexerArgs: computed(() => {
139
+ if (partProps.indexerArgs) {
140
+ return partProps.indexerArgs;
141
+ }
142
+
143
+ if (partProps.index !== undefined) {
144
+ return [partProps.index];
145
+ }
146
+
147
+ return [];
148
+ }),
149
+ conditional: computed(() => {
150
+ return !!partProps.conditional;
151
+ }),
152
+ nullable: computed(() => {
153
+ if (partProps.nullable) {
154
+ return true;
155
+ }
156
+
157
+ if (symbolSource.value) {
158
+ return symbolSource.value.isNullable;
159
+ }
160
+
161
+ return false;
162
+ }),
163
+ args: ref<any>(partProps.args === true ? [] : partProps.args),
164
+ typeArgs: ref<any>(partProps.typeArgs),
165
+ };
166
+
167
+ return reactive(part);
168
+ }
169
+
170
+ /**
171
+ * replaces quotes with escaped quotes
172
+ */
173
+ function escapeId(id: string) {
174
+ return id.replace(/"/g, '\\"');
175
+ }