@alloy-js/csharp 0.21.0-dev.1 → 0.21.0-dev.12

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 (441) hide show
  1. package/dist/scripts/components/library-interface.d.ts +9 -0
  2. package/dist/scripts/components/library-interface.d.ts.map +1 -0
  3. package/dist/scripts/components/library-interface.js +43 -0
  4. package/dist/scripts/components/library-interface.js.map +1 -0
  5. package/dist/scripts/components/namespace-directory.d.ts +7 -0
  6. package/dist/scripts/components/namespace-directory.d.ts.map +1 -0
  7. package/dist/scripts/components/namespace-directory.js +96 -0
  8. package/dist/scripts/components/namespace-directory.js.map +1 -0
  9. package/dist/scripts/generate-builtins.d.ts +11 -0
  10. package/dist/scripts/generate-builtins.d.ts.map +1 -0
  11. package/dist/scripts/generate-builtins.js +35 -0
  12. package/dist/scripts/generate-builtins.js.map +1 -0
  13. package/dist/scripts/process-docfx.d.ts +3 -0
  14. package/dist/scripts/process-docfx.d.ts.map +1 -0
  15. package/dist/scripts/process-docfx.js +288 -0
  16. package/dist/scripts/process-docfx.js.map +1 -0
  17. package/dist/src/access.d.ts +13 -0
  18. package/dist/src/access.d.ts.map +1 -0
  19. package/dist/src/access.js +65 -0
  20. package/dist/src/access.js.map +1 -0
  21. package/dist/src/access.test.d.ts +2 -0
  22. package/dist/src/access.test.d.ts.map +1 -0
  23. package/dist/src/access.test.js +43 -0
  24. package/dist/src/access.test.js.map +1 -0
  25. package/dist/src/builtins/Microsoft/Win32/SafeHandles/index.d.ts +32 -0
  26. package/dist/src/builtins/Microsoft/Win32/SafeHandles/index.d.ts.map +1 -0
  27. package/dist/src/builtins/Microsoft/Win32/SafeHandles/index.js +117 -0
  28. package/dist/src/builtins/Microsoft/Win32/SafeHandles/index.js.map +1 -0
  29. package/dist/src/builtins/Microsoft/Win32/index.d.ts +6 -0
  30. package/dist/src/builtins/Microsoft/Win32/index.d.ts.map +1 -0
  31. package/dist/src/builtins/Microsoft/Win32/index.js +5 -0
  32. package/dist/src/builtins/Microsoft/Win32/index.js.map +1 -0
  33. package/dist/src/builtins/Microsoft/index.d.ts +6 -0
  34. package/dist/src/builtins/Microsoft/index.d.ts.map +1 -0
  35. package/dist/src/builtins/Microsoft/index.js +5 -0
  36. package/dist/src/builtins/Microsoft/index.js.map +1 -0
  37. package/dist/src/builtins/System/Buffers/Text/index.d.ts +31 -0
  38. package/dist/src/builtins/System/Buffers/Text/index.d.ts.map +1 -0
  39. package/dist/src/builtins/System/Buffers/Text/index.js +122 -0
  40. package/dist/src/builtins/System/Buffers/Text/index.js.map +1 -0
  41. package/dist/src/builtins/System/Buffers/index.d.ts +57 -0
  42. package/dist/src/builtins/System/Buffers/index.d.ts.map +1 -0
  43. package/dist/src/builtins/System/Buffers/index.js +214 -0
  44. package/dist/src/builtins/System/Buffers/index.js.map +1 -0
  45. package/dist/src/builtins/System/CodeDom/Compiler/index.d.ts +31 -0
  46. package/dist/src/builtins/System/CodeDom/Compiler/index.d.ts.map +1 -0
  47. package/dist/src/builtins/System/CodeDom/Compiler/index.js +131 -0
  48. package/dist/src/builtins/System/CodeDom/Compiler/index.js.map +1 -0
  49. package/dist/src/builtins/System/CodeDom/index.d.ts +6 -0
  50. package/dist/src/builtins/System/CodeDom/index.d.ts.map +1 -0
  51. package/dist/src/builtins/System/CodeDom/index.js +5 -0
  52. package/dist/src/builtins/System/CodeDom/index.js.map +1 -0
  53. package/dist/src/builtins/System/Collections/Generic/index.d.ts +99 -0
  54. package/dist/src/builtins/System/Collections/Generic/index.d.ts.map +1 -0
  55. package/dist/src/builtins/System/Collections/Generic/index.js +342 -0
  56. package/dist/src/builtins/System/Collections/Generic/index.js.map +1 -0
  57. package/dist/src/builtins/System/Collections/ObjectModel/index.d.ts +49 -0
  58. package/dist/src/builtins/System/Collections/ObjectModel/index.d.ts.map +1 -0
  59. package/dist/src/builtins/System/Collections/ObjectModel/index.js +185 -0
  60. package/dist/src/builtins/System/Collections/ObjectModel/index.js.map +1 -0
  61. package/dist/src/builtins/System/Collections/index.d.ts +142 -0
  62. package/dist/src/builtins/System/Collections/index.d.ts.map +1 -0
  63. package/dist/src/builtins/System/Collections/index.js +634 -0
  64. package/dist/src/builtins/System/Collections/index.js.map +1 -0
  65. package/dist/src/builtins/System/ComponentModel/index.d.ts +24 -0
  66. package/dist/src/builtins/System/ComponentModel/index.d.ts.map +1 -0
  67. package/dist/src/builtins/System/ComponentModel/index.js +86 -0
  68. package/dist/src/builtins/System/ComponentModel/index.js.map +1 -0
  69. package/dist/src/builtins/System/Configuration/Assemblies/index.d.ts +19 -0
  70. package/dist/src/builtins/System/Configuration/Assemblies/index.d.ts.map +1 -0
  71. package/dist/src/builtins/System/Configuration/Assemblies/index.js +69 -0
  72. package/dist/src/builtins/System/Configuration/Assemblies/index.js.map +1 -0
  73. package/dist/src/builtins/System/Configuration/index.d.ts +6 -0
  74. package/dist/src/builtins/System/Configuration/index.d.ts.map +1 -0
  75. package/dist/src/builtins/System/Configuration/index.js +5 -0
  76. package/dist/src/builtins/System/Configuration/index.js.map +1 -0
  77. package/dist/src/builtins/System/Diagnostics/CodeAnalysis/index.d.ts +155 -0
  78. package/dist/src/builtins/System/Diagnostics/CodeAnalysis/index.d.ts.map +1 -0
  79. package/dist/src/builtins/System/Diagnostics/CodeAnalysis/index.js +705 -0
  80. package/dist/src/builtins/System/Diagnostics/CodeAnalysis/index.js.map +1 -0
  81. package/dist/src/builtins/System/Diagnostics/index.d.ts +115 -0
  82. package/dist/src/builtins/System/Diagnostics/index.d.ts.map +1 -0
  83. package/dist/src/builtins/System/Diagnostics/index.js +509 -0
  84. package/dist/src/builtins/System/Diagnostics/index.js.map +1 -0
  85. package/dist/src/builtins/System/Globalization/index.d.ts +737 -0
  86. package/dist/src/builtins/System/Globalization/index.d.ts.map +1 -0
  87. package/dist/src/builtins/System/Globalization/index.js +3848 -0
  88. package/dist/src/builtins/System/Globalization/index.js.map +1 -0
  89. package/dist/src/builtins/System/IO/Enumeration/index.d.ts +53 -0
  90. package/dist/src/builtins/System/IO/Enumeration/index.d.ts.map +1 -0
  91. package/dist/src/builtins/System/IO/Enumeration/index.js +218 -0
  92. package/dist/src/builtins/System/IO/Enumeration/index.js.map +1 -0
  93. package/dist/src/builtins/System/IO/index.d.ts +622 -0
  94. package/dist/src/builtins/System/IO/index.d.ts.map +1 -0
  95. package/dist/src/builtins/System/IO/index.js +3083 -0
  96. package/dist/src/builtins/System/IO/index.js.map +1 -0
  97. package/dist/src/builtins/System/Net/index.d.ts +14 -0
  98. package/dist/src/builtins/System/Net/index.d.ts.map +1 -0
  99. package/dist/src/builtins/System/Net/index.js +41 -0
  100. package/dist/src/builtins/System/Net/index.js.map +1 -0
  101. package/dist/src/builtins/System/Numerics/index.d.ts +204 -0
  102. package/dist/src/builtins/System/Numerics/index.d.ts.map +1 -0
  103. package/dist/src/builtins/System/Numerics/index.js +952 -0
  104. package/dist/src/builtins/System/Numerics/index.js.map +1 -0
  105. package/dist/src/builtins/System/Reflection/index.d.ts +918 -0
  106. package/dist/src/builtins/System/Reflection/index.d.ts.map +1 -0
  107. package/dist/src/builtins/System/Reflection/index.js +4675 -0
  108. package/dist/src/builtins/System/Reflection/index.js.map +1 -0
  109. package/dist/src/builtins/System/Resources/index.d.ts +56 -0
  110. package/dist/src/builtins/System/Resources/index.d.ts.map +1 -0
  111. package/dist/src/builtins/System/Resources/index.js +235 -0
  112. package/dist/src/builtins/System/Resources/index.js.map +1 -0
  113. package/dist/src/builtins/System/Runtime/CompilerServices/index.d.ts +396 -0
  114. package/dist/src/builtins/System/Runtime/CompilerServices/index.d.ts.map +1 -0
  115. package/dist/src/builtins/System/Runtime/CompilerServices/index.js +1531 -0
  116. package/dist/src/builtins/System/Runtime/CompilerServices/index.js.map +1 -0
  117. package/dist/src/builtins/System/Runtime/ConstrainedExecution/index.d.ts +29 -0
  118. package/dist/src/builtins/System/Runtime/ConstrainedExecution/index.d.ts.map +1 -0
  119. package/dist/src/builtins/System/Runtime/ConstrainedExecution/index.js +103 -0
  120. package/dist/src/builtins/System/Runtime/ConstrainedExecution/index.js.map +1 -0
  121. package/dist/src/builtins/System/Runtime/ExceptionServices/index.d.ts +20 -0
  122. package/dist/src/builtins/System/Runtime/ExceptionServices/index.d.ts.map +1 -0
  123. package/dist/src/builtins/System/Runtime/ExceptionServices/index.js +62 -0
  124. package/dist/src/builtins/System/Runtime/ExceptionServices/index.js.map +1 -0
  125. package/dist/src/builtins/System/Runtime/InteropServices/Marshalling/index.d.ts +84 -0
  126. package/dist/src/builtins/System/Runtime/InteropServices/Marshalling/index.d.ts.map +1 -0
  127. package/dist/src/builtins/System/Runtime/InteropServices/Marshalling/index.js +310 -0
  128. package/dist/src/builtins/System/Runtime/InteropServices/Marshalling/index.js.map +1 -0
  129. package/dist/src/builtins/System/Runtime/InteropServices/Swift/index.d.ts +18 -0
  130. package/dist/src/builtins/System/Runtime/InteropServices/Swift/index.d.ts.map +1 -0
  131. package/dist/src/builtins/System/Runtime/InteropServices/Swift/index.js +49 -0
  132. package/dist/src/builtins/System/Runtime/InteropServices/Swift/index.js.map +1 -0
  133. package/dist/src/builtins/System/Runtime/InteropServices/index.d.ts +165 -0
  134. package/dist/src/builtins/System/Runtime/InteropServices/index.d.ts.map +1 -0
  135. package/dist/src/builtins/System/Runtime/InteropServices/index.js +774 -0
  136. package/dist/src/builtins/System/Runtime/InteropServices/index.js.map +1 -0
  137. package/dist/src/builtins/System/Runtime/Remoting/index.d.ts +10 -0
  138. package/dist/src/builtins/System/Runtime/Remoting/index.d.ts.map +1 -0
  139. package/dist/src/builtins/System/Runtime/Remoting/index.js +18 -0
  140. package/dist/src/builtins/System/Runtime/Remoting/index.js.map +1 -0
  141. package/dist/src/builtins/System/Runtime/Serialization/index.d.ts +118 -0
  142. package/dist/src/builtins/System/Runtime/Serialization/index.d.ts.map +1 -0
  143. package/dist/src/builtins/System/Runtime/Serialization/index.js +468 -0
  144. package/dist/src/builtins/System/Runtime/Serialization/index.js.map +1 -0
  145. package/dist/src/builtins/System/Runtime/Versioning/index.d.ts +81 -0
  146. package/dist/src/builtins/System/Runtime/Versioning/index.d.ts.map +1 -0
  147. package/dist/src/builtins/System/Runtime/Versioning/index.js +336 -0
  148. package/dist/src/builtins/System/Runtime/Versioning/index.js.map +1 -0
  149. package/dist/src/builtins/System/Runtime/index.d.ts +65 -0
  150. package/dist/src/builtins/System/Runtime/index.d.ts.map +1 -0
  151. package/dist/src/builtins/System/Runtime/index.js +243 -0
  152. package/dist/src/builtins/System/Runtime/index.js.map +1 -0
  153. package/dist/src/builtins/System/Security/Cryptography/index.d.ts +9 -0
  154. package/dist/src/builtins/System/Security/Cryptography/index.d.ts.map +1 -0
  155. package/dist/src/builtins/System/Security/Cryptography/index.js +14 -0
  156. package/dist/src/builtins/System/Security/Cryptography/index.js.map +1 -0
  157. package/dist/src/builtins/System/Security/Permissions/index.d.ts +67 -0
  158. package/dist/src/builtins/System/Security/Permissions/index.d.ts.map +1 -0
  159. package/dist/src/builtins/System/Security/Permissions/index.js +325 -0
  160. package/dist/src/builtins/System/Security/Permissions/index.js.map +1 -0
  161. package/dist/src/builtins/System/Security/Principal/index.d.ts +27 -0
  162. package/dist/src/builtins/System/Security/Principal/index.d.ts.map +1 -0
  163. package/dist/src/builtins/System/Security/Principal/index.js +104 -0
  164. package/dist/src/builtins/System/Security/Principal/index.js.map +1 -0
  165. package/dist/src/builtins/System/Security/index.d.ts +141 -0
  166. package/dist/src/builtins/System/Security/index.d.ts.map +1 -0
  167. package/dist/src/builtins/System/Security/index.js +590 -0
  168. package/dist/src/builtins/System/Security/index.js.map +1 -0
  169. package/dist/src/builtins/System/Text/Unicode/index.d.ts +12 -0
  170. package/dist/src/builtins/System/Text/Unicode/index.d.ts.map +1 -0
  171. package/dist/src/builtins/System/Text/Unicode/index.js +31 -0
  172. package/dist/src/builtins/System/Text/Unicode/index.js.map +1 -0
  173. package/dist/src/builtins/System/Text/index.d.ts +268 -0
  174. package/dist/src/builtins/System/Text/index.d.ts.map +1 -0
  175. package/dist/src/builtins/System/Text/index.js +1278 -0
  176. package/dist/src/builtins/System/Text/index.js.map +1 -0
  177. package/dist/src/builtins/System/Threading/Tasks/Sources/index.d.ts +32 -0
  178. package/dist/src/builtins/System/Threading/Tasks/Sources/index.d.ts.map +1 -0
  179. package/dist/src/builtins/System/Threading/Tasks/Sources/index.js +117 -0
  180. package/dist/src/builtins/System/Threading/Tasks/Sources/index.js.map +1 -0
  181. package/dist/src/builtins/System/Threading/Tasks/index.d.ts +140 -0
  182. package/dist/src/builtins/System/Threading/Tasks/index.d.ts.map +1 -0
  183. package/dist/src/builtins/System/Threading/Tasks/index.js +621 -0
  184. package/dist/src/builtins/System/Threading/Tasks/index.js.map +1 -0
  185. package/dist/src/builtins/System/Threading/index.d.ts +92 -0
  186. package/dist/src/builtins/System/Threading/index.d.ts.map +1 -0
  187. package/dist/src/builtins/System/Threading/index.js +372 -0
  188. package/dist/src/builtins/System/Threading/index.js.map +1 -0
  189. package/dist/src/builtins/System/index.d.ts +2746 -0
  190. package/dist/src/builtins/System/index.d.ts.map +1 -0
  191. package/dist/src/builtins/System/index.js +13070 -0
  192. package/dist/src/builtins/System/index.js.map +1 -0
  193. package/dist/src/builtins/index.d.ts +3 -0
  194. package/dist/src/builtins/index.d.ts.map +1 -0
  195. package/dist/src/builtins/index.js +3 -0
  196. package/dist/src/builtins/index.js.map +1 -0
  197. package/dist/src/components/access-expression/access-expression.d.ts +3 -3
  198. package/dist/src/components/access-expression/access-expression.d.ts.map +1 -1
  199. package/dist/src/components/enum/declaration.d.ts +2 -2
  200. package/dist/src/components/enum/declaration.d.ts.map +1 -1
  201. package/dist/src/components/enum/declaration.js +3 -3
  202. package/dist/src/components/enum/declaration.js.map +1 -1
  203. package/dist/src/components/enum/declaration.ref.test.js +1 -1
  204. package/dist/src/components/enum/declaration.test.js +15 -1
  205. package/dist/src/components/enum/declaration.test.js.map +1 -1
  206. package/dist/src/components/enum/member.d.ts +2 -2
  207. package/dist/src/components/enum/member.d.ts.map +1 -1
  208. package/dist/src/components/enum/member.js +3 -3
  209. package/dist/src/components/enum/member.js.map +1 -1
  210. package/dist/src/components/enum/member.test.js +24 -1
  211. package/dist/src/components/enum/member.test.js.map +1 -1
  212. package/dist/src/components/field/field.d.ts +2 -2
  213. package/dist/src/components/field/field.d.ts.map +1 -1
  214. package/dist/src/components/field/field.js.map +1 -1
  215. package/dist/src/components/field/field.test.js +19 -1
  216. package/dist/src/components/field/field.test.js.map +1 -1
  217. package/dist/src/components/if/if-statement.d.ts +25 -0
  218. package/dist/src/components/if/if-statement.d.ts.map +1 -0
  219. package/dist/src/components/if/if-statement.js +36 -0
  220. package/dist/src/components/if/if-statement.js.map +1 -0
  221. package/dist/src/components/if/if-statement.test.d.ts +2 -0
  222. package/dist/src/components/if/if-statement.test.d.ts.map +1 -0
  223. package/dist/src/components/if/if-statement.test.js +29 -0
  224. package/dist/src/components/if/if-statement.test.js.map +1 -0
  225. package/dist/src/components/index.d.ts +3 -1
  226. package/dist/src/components/index.d.ts.map +1 -1
  227. package/dist/src/components/index.js +3 -2
  228. package/dist/src/components/index.js.map +1 -1
  229. package/dist/src/components/interface/declaration.d.ts +1 -1
  230. package/dist/src/components/interface/declaration.d.ts.map +1 -1
  231. package/dist/src/components/interface/declaration.js +3 -3
  232. package/dist/src/components/interface/declaration.js.map +1 -1
  233. package/dist/src/components/interface/declaration.test.js +14 -1
  234. package/dist/src/components/interface/declaration.test.js.map +1 -1
  235. package/dist/src/components/interface/method.d.ts +2 -2
  236. package/dist/src/components/interface/method.d.ts.map +1 -1
  237. package/dist/src/components/interface/method.js.map +1 -1
  238. package/dist/src/components/interface/method.test.js +17 -1
  239. package/dist/src/components/interface/method.test.js.map +1 -1
  240. package/dist/src/components/interface/property.d.ts +2 -2
  241. package/dist/src/components/interface/property.d.ts.map +1 -1
  242. package/dist/src/components/interface/property.js.map +1 -1
  243. package/dist/src/components/interface/property.test.js +19 -0
  244. package/dist/src/components/interface/property.test.js.map +1 -1
  245. package/dist/src/components/method/method.js +10 -2
  246. package/dist/src/components/method/method.js.map +1 -1
  247. package/dist/src/components/method/method.test.js +61 -0
  248. package/dist/src/components/method/method.test.js.map +1 -1
  249. package/dist/src/components/namespace/namespace-name.d.ts +10 -0
  250. package/dist/src/components/namespace/namespace-name.d.ts.map +1 -0
  251. package/dist/src/components/namespace/namespace-name.js +20 -0
  252. package/dist/src/components/namespace/namespace-name.js.map +1 -0
  253. package/dist/src/components/{namespace.d.ts → namespace/namespace.d.ts} +3 -1
  254. package/dist/src/components/namespace/namespace.d.ts.map +1 -0
  255. package/dist/src/components/{namespace.js → namespace/namespace.js} +12 -13
  256. package/dist/src/components/namespace/namespace.js.map +1 -0
  257. package/dist/src/components/namespace/namespace.test.d.ts.map +1 -0
  258. package/dist/src/components/namespace/namespace.test.js +207 -0
  259. package/dist/src/components/namespace/namespace.test.js.map +1 -0
  260. package/dist/src/components/namespace.ref.test.js +42 -10
  261. package/dist/src/components/namespace.ref.test.js.map +1 -1
  262. package/dist/src/components/parameters/parameters.d.ts.map +1 -1
  263. package/dist/src/components/parameters/parameters.js +2 -2
  264. package/dist/src/components/parameters/parameters.js.map +1 -1
  265. package/dist/src/components/property/property.d.ts.map +1 -1
  266. package/dist/src/components/property/property.js +21 -12
  267. package/dist/src/components/property/property.js.map +1 -1
  268. package/dist/src/components/property/property.test.js +28 -0
  269. package/dist/src/components/property/property.test.js.map +1 -1
  270. package/dist/src/components/record/declaration.d.ts +1 -1
  271. package/dist/src/components/record/declaration.d.ts.map +1 -1
  272. package/dist/src/components/record/declaration.js +3 -4
  273. package/dist/src/components/record/declaration.js.map +1 -1
  274. package/dist/src/components/record/declaration.test.js +14 -1
  275. package/dist/src/components/record/declaration.test.js.map +1 -1
  276. package/dist/src/components/source-file/source-file.d.ts.map +1 -1
  277. package/dist/src/components/source-file/source-file.js +4 -2
  278. package/dist/src/components/source-file/source-file.js.map +1 -1
  279. package/dist/src/components/source-file/source-file.test.js +1 -1
  280. package/dist/src/components/source-file/using.test.js +1 -1
  281. package/dist/src/components/struct/declaration.d.ts +1 -1
  282. package/dist/src/components/struct/declaration.d.ts.map +1 -1
  283. package/dist/src/components/struct/declaration.js +3 -3
  284. package/dist/src/components/struct/declaration.js.map +1 -1
  285. package/dist/src/components/struct/declaration.test.js +14 -1
  286. package/dist/src/components/struct/declaration.test.js.map +1 -1
  287. package/dist/src/components/type-parameters/type-parameter.d.ts +2 -2
  288. package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -1
  289. package/dist/src/components/type-parameters/type-parameter.js.map +1 -1
  290. package/dist/src/components/type-parameters/type-parameters.test.js +14 -0
  291. package/dist/src/components/type-parameters/type-parameters.test.js.map +1 -1
  292. package/dist/src/components/var/declaration.d.ts +4 -2
  293. package/dist/src/components/var/declaration.d.ts.map +1 -1
  294. package/dist/src/components/var/declaration.js +17 -3
  295. package/dist/src/components/var/declaration.js.map +1 -1
  296. package/dist/src/components/var/declaration.test.js +22 -1
  297. package/dist/src/components/var/declaration.test.js.map +1 -1
  298. package/dist/src/contexts/global-namespace.d.ts +1 -0
  299. package/dist/src/contexts/global-namespace.d.ts.map +1 -1
  300. package/dist/src/contexts/global-namespace.js +6 -1
  301. package/dist/src/contexts/global-namespace.js.map +1 -1
  302. package/dist/src/create-library.d.ts +62 -0
  303. package/dist/src/create-library.d.ts.map +1 -0
  304. package/dist/src/create-library.js +128 -0
  305. package/dist/src/create-library.js.map +1 -0
  306. package/dist/src/create-library.test.d.ts +10 -0
  307. package/dist/src/create-library.test.d.ts.map +1 -0
  308. package/dist/src/create-library.test.js +220 -0
  309. package/dist/src/create-library.test.js.map +1 -0
  310. package/dist/src/index.d.ts +2 -0
  311. package/dist/src/index.d.ts.map +1 -1
  312. package/dist/src/index.js +2 -0
  313. package/dist/src/index.js.map +1 -1
  314. package/dist/src/name-policy.d.ts +1 -1
  315. package/dist/src/name-policy.d.ts.map +1 -1
  316. package/dist/src/name-policy.js +1 -0
  317. package/dist/src/name-policy.js.map +1 -1
  318. package/dist/src/symbols/factories.d.ts +1 -1
  319. package/dist/src/symbols/factories.d.ts.map +1 -1
  320. package/dist/src/symbols/factories.js +27 -7
  321. package/dist/src/symbols/factories.js.map +1 -1
  322. package/dist/src/symbols/named-type.d.ts +3 -3
  323. package/dist/src/symbols/named-type.d.ts.map +1 -1
  324. package/dist/src/symbols/named-type.js.map +1 -1
  325. package/dist/src/symbols/namespace.d.ts +2 -2
  326. package/dist/src/symbols/namespace.d.ts.map +1 -1
  327. package/dist/src/symbols/namespace.js.map +1 -1
  328. package/dist/src/symbols/reference.d.ts.map +1 -1
  329. package/dist/src/symbols/reference.js +3 -3
  330. package/dist/src/symbols/reference.js.map +1 -1
  331. package/dist/test/utils.d.ts +4 -2
  332. package/dist/test/utils.d.ts.map +1 -1
  333. package/dist/test/utils.js +5 -4
  334. package/dist/test/utils.js.map +1 -1
  335. package/dist/tsconfig.tsbuildinfo +1 -1
  336. package/package.json +14 -3
  337. package/scripts/components/library-interface.tsx +41 -0
  338. package/scripts/components/namespace-directory.tsx +104 -0
  339. package/scripts/generate-builtins.tsx +35 -0
  340. package/scripts/process-docfx.tsx +309 -0
  341. package/src/access.test.tsx +49 -0
  342. package/src/access.tsx +70 -0
  343. package/src/builtins/Microsoft/Win32/SafeHandles/index.ts +147 -0
  344. package/src/builtins/Microsoft/Win32/index.ts +8 -0
  345. package/src/builtins/Microsoft/index.ts +8 -0
  346. package/src/builtins/System/Buffers/Text/index.ts +150 -0
  347. package/src/builtins/System/Buffers/index.ts +267 -0
  348. package/src/builtins/System/CodeDom/Compiler/index.ts +160 -0
  349. package/src/builtins/System/CodeDom/index.ts +8 -0
  350. package/src/builtins/System/Collections/Generic/index.ts +439 -0
  351. package/src/builtins/System/Collections/ObjectModel/index.ts +232 -0
  352. package/src/builtins/System/Collections/index.ts +771 -0
  353. package/src/builtins/System/ComponentModel/index.ts +108 -0
  354. package/src/builtins/System/Configuration/Assemblies/index.ts +85 -0
  355. package/src/builtins/System/Configuration/index.ts +8 -0
  356. package/src/builtins/System/Diagnostics/CodeAnalysis/index.ts +858 -0
  357. package/src/builtins/System/Diagnostics/index.ts +620 -0
  358. package/src/builtins/System/Globalization/index.ts +4583 -0
  359. package/src/builtins/System/IO/Enumeration/index.ts +269 -0
  360. package/src/builtins/System/IO/index.ts +3701 -0
  361. package/src/builtins/System/Net/index.ts +52 -0
  362. package/src/builtins/System/Numerics/index.ts +1184 -0
  363. package/src/builtins/System/Reflection/index.ts +5591 -0
  364. package/src/builtins/System/Resources/index.ts +289 -0
  365. package/src/builtins/System/Runtime/CompilerServices/index.ts +1929 -0
  366. package/src/builtins/System/Runtime/ConstrainedExecution/index.ts +129 -0
  367. package/src/builtins/System/Runtime/ExceptionServices/index.ts +80 -0
  368. package/src/builtins/System/Runtime/InteropServices/Marshalling/index.ts +394 -0
  369. package/src/builtins/System/Runtime/InteropServices/Swift/index.ts +65 -0
  370. package/src/builtins/System/Runtime/InteropServices/index.ts +934 -0
  371. package/src/builtins/System/Runtime/Remoting/index.ts +25 -0
  372. package/src/builtins/System/Runtime/Serialization/index.ts +584 -0
  373. package/src/builtins/System/Runtime/Versioning/index.ts +415 -0
  374. package/src/builtins/System/Runtime/index.ts +298 -0
  375. package/src/builtins/System/Security/Cryptography/index.ts +20 -0
  376. package/src/builtins/System/Security/Permissions/index.ts +390 -0
  377. package/src/builtins/System/Security/Principal/index.ts +129 -0
  378. package/src/builtins/System/Security/index.ts +725 -0
  379. package/src/builtins/System/Text/Unicode/index.ts +40 -0
  380. package/src/builtins/System/Text/index.ts +1542 -0
  381. package/src/builtins/System/Threading/Tasks/Sources/index.ts +147 -0
  382. package/src/builtins/System/Threading/Tasks/index.ts +757 -0
  383. package/src/builtins/System/Threading/index.ts +460 -0
  384. package/src/builtins/System/index.ts +15803 -0
  385. package/src/builtins/index.ts +2 -0
  386. package/src/components/access-expression/access-expression.tsx +2 -2
  387. package/src/components/enum/declaration.ref.test.tsx +1 -1
  388. package/src/components/enum/declaration.test.tsx +14 -1
  389. package/src/components/enum/declaration.tsx +4 -3
  390. package/src/components/enum/member.test.tsx +22 -1
  391. package/src/components/enum/member.tsx +4 -4
  392. package/src/components/field/field.test.tsx +14 -1
  393. package/src/components/field/field.tsx +2 -2
  394. package/src/components/if/if-statement.test.tsx +26 -0
  395. package/src/components/if/if-statement.tsx +50 -0
  396. package/src/components/index.ts +3 -1
  397. package/src/components/interface/declaration.test.tsx +11 -1
  398. package/src/components/interface/declaration.tsx +3 -4
  399. package/src/components/interface/method.test.tsx +14 -1
  400. package/src/components/interface/method.tsx +2 -1
  401. package/src/components/interface/property.test.tsx +13 -0
  402. package/src/components/interface/property.tsx +2 -1
  403. package/src/components/method/method.test.tsx +49 -0
  404. package/src/components/method/method.tsx +7 -4
  405. package/src/components/namespace/namespace-name.tsx +31 -0
  406. package/src/components/namespace/namespace.test.tsx +145 -0
  407. package/src/components/{namespace.tsx → namespace/namespace.tsx} +12 -15
  408. package/src/components/namespace.ref.test.tsx +34 -9
  409. package/src/components/parameters/parameters.tsx +7 -2
  410. package/src/components/property/property.test.tsx +25 -0
  411. package/src/components/property/property.tsx +22 -11
  412. package/src/components/record/declaration.test.tsx +11 -1
  413. package/src/components/record/declaration.tsx +3 -4
  414. package/src/components/source-file/source-file.test.tsx +1 -1
  415. package/src/components/source-file/source-file.tsx +2 -2
  416. package/src/components/source-file/using.test.tsx +1 -1
  417. package/src/components/struct/declaration.test.tsx +11 -1
  418. package/src/components/struct/declaration.tsx +3 -4
  419. package/src/components/type-parameters/type-parameter.tsx +2 -1
  420. package/src/components/type-parameters/type-parameters.test.tsx +9 -0
  421. package/src/components/var/declaration.test.tsx +16 -1
  422. package/src/components/var/declaration.tsx +17 -2
  423. package/src/contexts/global-namespace.ts +8 -1
  424. package/src/create-library.test.tsx +202 -0
  425. package/src/create-library.ts +270 -0
  426. package/src/index.ts +2 -0
  427. package/src/name-policy.ts +3 -1
  428. package/src/symbols/factories.ts +47 -10
  429. package/src/symbols/named-type.ts +3 -3
  430. package/src/symbols/namespace.ts +2 -2
  431. package/src/symbols/reference.tsx +10 -3
  432. package/temp/api.json +3868 -712
  433. package/test/utils.tsx +6 -3
  434. package/tsconfig.json +11 -2
  435. package/dist/src/components/namespace.d.ts.map +0 -1
  436. package/dist/src/components/namespace.js.map +0 -1
  437. package/dist/src/components/namespace.test.d.ts.map +0 -1
  438. package/dist/src/components/namespace.test.js +0 -79
  439. package/dist/src/components/namespace.test.js.map +0 -1
  440. package/src/components/namespace.test.tsx +0 -52
  441. /package/dist/src/components/{namespace.test.d.ts → namespace/namespace.test.d.ts} +0 -0
@@ -1,17 +1,21 @@
1
- import { Block } from "@alloy-js/core";
1
+ import { Block, Namekey, Refkey } from "@alloy-js/core";
2
2
  import { Children } from "@alloy-js/core/jsx-runtime";
3
- import { NamespaceContext } from "../contexts/namespace.js";
4
- import { useSourceFileScope } from "../scopes/source-file.js";
5
- import { createNamespaceSymbol } from "../symbols/factories.js";
6
- import { NamespaceScope } from "./namespace-scopes.jsx";
3
+ import { NamespaceContext } from "../../contexts/namespace.js";
4
+ import { useSourceFileScope } from "../../scopes/source-file.js";
5
+ import { createNamespaceSymbol } from "../../symbols/factories.js";
6
+ import { NamespaceScope } from "../namespace-scopes.jsx";
7
+ import { NamespaceName } from "./namespace-name.jsx";
7
8
 
8
9
  export interface NamespaceProps {
9
- name: string;
10
+ name: string | Namekey | (string | Namekey)[];
11
+ refkey?: Refkey | Refkey[];
10
12
  children?: Children;
11
13
  }
12
14
 
13
15
  export function Namespace(props: NamespaceProps) {
14
- const namespaceSymbol = createNamespaceSymbol(props.name);
16
+ const namespaceSymbol = createNamespaceSymbol(props.name, {
17
+ refkeys: props.refkey,
18
+ });
15
19
  const sfScope = useSourceFileScope();
16
20
 
17
21
  if (!sfScope) {
@@ -24,7 +28,7 @@ export function Namespace(props: NamespaceProps) {
24
28
  sfScope.hasBlockNamespace = true;
25
29
  return (
26
30
  <>
27
- namespace {namespaceSymbol.name}{" "}
31
+ namespace <NamespaceName symbol={namespaceSymbol} relative />{" "}
28
32
  <Block>
29
33
  <NamespaceContext.Provider value={{ symbol: namespaceSymbol }}>
30
34
  <NamespaceScope symbol={namespaceSymbol}>
@@ -36,10 +40,3 @@ export function Namespace(props: NamespaceProps) {
36
40
  );
37
41
  }
38
42
  }
39
-
40
- /*
41
- const scope = createCSharpNamespaceScope(namespaceSymbol);
42
-
43
- return <Scope value={scope}>{props.children}</Scope>;
44
- }
45
- */
@@ -1,8 +1,7 @@
1
- import { Output, refkey } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
1
+ import { List, memberRefkey, namekey, Output, refkey } from "@alloy-js/core";
3
2
  import { expect, it } from "vitest";
4
3
  import { ClassDeclaration } from "./class/declaration.jsx";
5
- import { Namespace } from "./namespace.jsx";
4
+ import { Namespace } from "./namespace/namespace.jsx";
6
5
  import { SourceFile } from "./source-file/source-file.jsx";
7
6
 
8
7
  it("references types in the same namespace", () => {
@@ -20,7 +19,7 @@ it("references types in the same namespace", () => {
20
19
  </Output>
21
20
  );
22
21
 
23
- expect(tree).toRenderTo(d`
22
+ expect(tree).toRenderTo(`
24
23
  namespace Test;
25
24
 
26
25
  class TestClass;
@@ -43,7 +42,7 @@ it("references types in a parent namespace", () => {
43
42
  </Output>
44
43
  );
45
44
 
46
- expect(tree).toRenderTo(d`
45
+ expect(tree).toRenderTo(`
47
46
  namespace Test {
48
47
  class TestClass;
49
48
  namespace Nested {
@@ -69,7 +68,7 @@ it("references types in a child namespace", () => {
69
68
  </Output>
70
69
  );
71
70
 
72
- expect(tree).toRenderTo(d`
71
+ expect(tree).toRenderTo(`
73
72
  namespace Test {
74
73
  Nested.TestClass;
75
74
  namespace Nested {
@@ -94,7 +93,7 @@ it("references types in a different top-level namespace declared in the same fil
94
93
  </Output>
95
94
  );
96
95
 
97
- expect(tree).toRenderTo(d`
96
+ expect(tree).toRenderTo(`
98
97
  using TestCode2;
99
98
 
100
99
  namespace TestCode1 {
@@ -123,17 +122,43 @@ it("references types in a different top-level namespace declared in a different
123
122
  );
124
123
 
125
124
  expect(tree).toRenderTo({
126
- "test.cs": d`
125
+ "test.cs": `
127
126
  using TestCode2;
128
127
 
129
128
  namespace TestCode1 {
130
129
  TestClass;
131
130
  }
132
131
  `,
133
- "other.cs": d`
132
+ "other.cs": `
134
133
  namespace TestCode2 {
135
134
  class TestClass;
136
135
  }
137
136
  `,
138
137
  });
139
138
  });
139
+
140
+ it("can be referenced by refkey", () => {
141
+ const classRef = namekey("TestClass");
142
+ const nsRef = namekey("TestCode2");
143
+ const tree = (
144
+ <Output>
145
+ <SourceFile path="other.cs">
146
+ <List>
147
+ <Namespace name={nsRef}>
148
+ <ClassDeclaration name={classRef} />
149
+ </Namespace>
150
+ <>{memberRefkey(nsRef, classRef)};</>
151
+ </List>
152
+ </SourceFile>
153
+ </Output>
154
+ );
155
+
156
+ expect(tree).toRenderTo(`
157
+ using TestCode2;
158
+
159
+ namespace TestCode2 {
160
+ class TestClass;
161
+ }
162
+ TestClass;
163
+ `);
164
+ });
@@ -51,9 +51,14 @@ export function Parameters(props: ParametersProps) {
51
51
  <group>
52
52
  {"("}
53
53
  {props.parameters && (
54
- <Indent softline>
54
+ <Indent nobreak>
55
55
  <For each={props.parameters} joiner={", "}>
56
- {(param) => <Parameter {...param} />}
56
+ {(param) => (
57
+ <>
58
+ <softline />
59
+ <Parameter {...param} />
60
+ </>
61
+ )}
57
62
  </For>
58
63
  </Indent>
59
64
  )}
@@ -207,3 +207,28 @@ it("specify attributes", () => {
207
207
  }
208
208
  `);
209
209
  });
210
+
211
+ describe("format", () => {
212
+ it("split after = if initializer too long", () => {
213
+ expect(
214
+ <TestNamespace printWidth={60}>
215
+ <ClassDeclaration name="Test">
216
+ <Property
217
+ public
218
+ get
219
+ set
220
+ name="ThisIsAVeryLongPropertyName"
221
+ type="string"
222
+ initializer={`"Some very long initializer value"`}
223
+ />
224
+ </ClassDeclaration>
225
+ </TestNamespace>,
226
+ ).toRenderTo(`
227
+ class Test
228
+ {
229
+ public string ThisIsAVeryLongPropertyName { get; set; } =
230
+ "Some very long initializer value";
231
+ }
232
+ `);
233
+ });
234
+ });
@@ -1,7 +1,5 @@
1
1
  import {
2
- Block,
3
2
  Children,
4
- code,
5
3
  createSymbolSlot,
6
4
  List,
7
5
  MemberDeclaration,
@@ -142,15 +140,28 @@ export function Property(props: PropertyProps) {
142
140
  <AttributeList attributes={props.attributes} endline />
143
141
  {modifiers}
144
142
  <TypeSlot>{props.type}</TypeSlot>
145
- {props.nullable && "?"} <MemberName />{" "}
146
- <Block newline inline>
147
- <List joiner=" ">
148
- {props.get && "get;"}
149
- {props.set && "set;"}
150
- {props.init && "init;"}
151
- </List>
152
- </Block>
153
- {props.initializer && code` = ${props.initializer};`}
143
+ {props.nullable && "?"} <MemberName /> {"{ "}
144
+ <List joiner=" ">
145
+ {props.get && "get;"}
146
+ {props.set && "set;"}
147
+ {props.init && "init;"}
148
+ </List>
149
+ {" }"}
150
+ {props.initializer && (
151
+ <PropertyInitializer>{props.initializer}</PropertyInitializer>
152
+ )}
154
153
  </MemberDeclaration>
155
154
  );
156
155
  }
156
+
157
+ function PropertyInitializer(props: { children: Children }) {
158
+ return (
159
+ <group>
160
+ {" ="}
161
+ <indent>
162
+ <line />
163
+ {props.children};
164
+ </indent>
165
+ </group>
166
+ );
167
+ }
@@ -1,4 +1,4 @@
1
- import { Children, code, refkey } from "@alloy-js/core";
1
+ import { Children, code, namekey, refkey } from "@alloy-js/core";
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { TestNamespace } from "../../../test/utils.jsx";
4
4
  import { Property } from "../property/property.jsx";
@@ -19,6 +19,16 @@ it("declares record with no members", () => {
19
19
  `);
20
20
  });
21
21
 
22
+ it("takes a namekey", () => {
23
+ expect(
24
+ <TestNamespace>
25
+ <RecordDeclaration name={namekey("my-record")} />
26
+ </TestNamespace>,
27
+ ).toRenderTo(`
28
+ record MyRecord;
29
+ `);
30
+ });
31
+
22
32
  describe("modifiers", () => {
23
33
  it.each(["public", "private", "internal"])("%s", (mod) => {
24
34
  expect(
@@ -26,7 +26,7 @@ export interface RecordDeclarationProps
26
26
  extends Omit<core.DeclarationProps, "nameKind">,
27
27
  AccessModifiers,
28
28
  RecordModifiers {
29
- name: string;
29
+ name: string | core.Namekey;
30
30
 
31
31
  /** Doc comment */
32
32
  doc?: core.Children;
@@ -73,12 +73,11 @@ export interface RecordDeclarationProps
73
73
  * ```
74
74
  */
75
75
  export function RecordDeclaration(props: RecordDeclarationProps) {
76
- const name = useCSharpNamePolicy().getName(props.name!, "record");
77
-
78
76
  // records don't have their own type kind but instead use class or struct
79
77
  // depending on what kind of record we have.
80
- const thisRecordSymbol = createNamedTypeSymbol(name, "record", {
78
+ const thisRecordSymbol = createNamedTypeSymbol(props.name, "record", {
81
79
  refkeys: props.refkey,
80
+ namePolicy: useCSharpNamePolicy().for("record"),
82
81
  });
83
82
 
84
83
  const thisRecordScope = createClassScope(thisRecordSymbol);
@@ -1,5 +1,5 @@
1
1
  import { ClassDeclaration } from "#components/class/declaration.jsx";
2
- import { Namespace } from "#components/namespace.jsx";
2
+ import { Namespace } from "#components/namespace/namespace.jsx";
3
3
  import { Children, FormatOptions, Indent, Output, Prose } from "@alloy-js/core";
4
4
  import { describe, expect, it } from "vitest";
5
5
  import { CSharpFormatOptions } from "../../contexts/format-options.js";
@@ -1,4 +1,5 @@
1
1
  import { NamespaceScopes } from "#components/namespace-scopes.jsx";
2
+ import { NamespaceName } from "#components/namespace/namespace-name.jsx";
2
3
  import { Reference } from "#components/Reference.jsx";
3
4
  import { Usings } from "#components/using/using.jsx";
4
5
  import {
@@ -42,7 +43,6 @@ export function SourceFile(props: SourceFileProps) {
42
43
  const nsContext = useNamespaceContext();
43
44
  const globalNs = getGlobalNamespace(useBinder());
44
45
  const nsSymbol = nsContext ? nsContext.symbol : globalNs;
45
- const nsRef = nsContext ? nsContext.symbol.name : undefined;
46
46
  const usings = computed(() => {
47
47
  return (
48
48
  Array.from(sourceFileScope.usings) as (NamespaceSymbol | string)[]
@@ -78,7 +78,7 @@ export function SourceFile(props: SourceFileProps) {
78
78
  {nsSymbol === globalNs ?
79
79
  content
80
80
  : <>
81
- namespace {nsRef}
81
+ namespace <NamespaceName symbol={nsSymbol} />
82
82
  {sourceFileScope.hasBlockNamespace ?
83
83
  <>
84
84
  {" "}
@@ -2,7 +2,7 @@ import { ClassDeclaration } from "#components/class/declaration.jsx";
2
2
  import { EnumDeclaration } from "#components/enum/declaration.jsx";
3
3
  import { EnumMember } from "#components/enum/member.jsx";
4
4
  import { Method } from "#components/method/method.jsx";
5
- import { Namespace } from "#components/namespace.jsx";
5
+ import { Namespace } from "#components/namespace/namespace.jsx";
6
6
  import { SourceFile } from "#components/source-file/source-file.jsx";
7
7
  import { Output, refkey } from "@alloy-js/core";
8
8
  import * as coretest from "@alloy-js/core/testing";
@@ -1,4 +1,4 @@
1
- import { List, refkey } from "@alloy-js/core";
1
+ import { List, namekey, refkey } from "@alloy-js/core";
2
2
  import { describe, expect, it } from "vitest";
3
3
  import { TestNamespace } from "../../../test/utils.jsx";
4
4
  import { Attribute } from "../attributes/attributes.jsx";
@@ -19,6 +19,16 @@ it("declares struct with no members", () => {
19
19
  `);
20
20
  });
21
21
 
22
+ it("takes a namekey", () => {
23
+ expect(
24
+ <TestNamespace>
25
+ <StructDeclaration name={namekey("my-struct")} />
26
+ </TestNamespace>,
27
+ ).toRenderTo(`
28
+ struct MyStruct;
29
+ `);
30
+ });
31
+
22
32
  describe("modifiers", () => {
23
33
  it.each(["public", "private", "internal"])("%s", (mod) => {
24
34
  expect(
@@ -35,7 +35,7 @@ export interface StructDeclarationProps
35
35
  extends Omit<core.DeclarationProps, "nameKind">,
36
36
  AccessModifiers,
37
37
  StructModifiers {
38
- name: string;
38
+ name: string | core.Namekey;
39
39
 
40
40
  /** Doc comment */
41
41
  doc?: core.Children;
@@ -98,10 +98,9 @@ export interface StructDeclarationProps
98
98
  * ```
99
99
  */
100
100
  export function StructDeclaration(props: StructDeclarationProps) {
101
- const name = useCSharpNamePolicy().getName(props.name!, "struct");
102
-
103
- const thisStructSymbol = createNamedTypeSymbol(name, "struct", {
101
+ const thisStructSymbol = createNamedTypeSymbol(props.name, "struct", {
104
102
  refkeys: props.refkey,
103
+ namePolicy: useCSharpNamePolicy().for("struct"),
105
104
  });
106
105
 
107
106
  const thisStructScope = createNamedTypeScope(thisStructSymbol);
@@ -2,6 +2,7 @@ import {
2
2
  Children,
3
3
  MemberDeclaration,
4
4
  MemberName,
5
+ Namekey,
5
6
  Refkey,
6
7
  } from "@alloy-js/core";
7
8
  import { createTypeParameterSymbol } from "../../symbols/factories.js";
@@ -13,7 +14,7 @@ export interface TypeParameterProps {
13
14
  /**
14
15
  * The name of the type parameter.
15
16
  */
16
- readonly name: string;
17
+ readonly name: string | Namekey;
17
18
 
18
19
  /**
19
20
  * The parameter constraint
@@ -1,3 +1,4 @@
1
+ import { namekey } from "@alloy-js/core";
1
2
  import { expect, it } from "vitest";
2
3
  import { TestNamespace } from "../../../test/utils.jsx";
3
4
  import { TypeParameters } from "./type-parameters.jsx";
@@ -44,3 +45,11 @@ it("declare type parameters using parameters", () => {
44
45
  </TestNamespace>,
45
46
  ).toRenderTo(`<A, B>`);
46
47
  });
48
+
49
+ it("takes a namekey", () => {
50
+ expect(
51
+ <TestNamespace>
52
+ <TypeParameters parameters={[{ name: namekey("my-param") }]} />
53
+ </TestNamespace>,
54
+ ).toRenderTo(`<MyParam>`);
55
+ });
@@ -1,4 +1,4 @@
1
- import { List, refkey } from "@alloy-js/core";
1
+ import { List, namekey, refkey } from "@alloy-js/core";
2
2
  import { expect, it } from "vitest";
3
3
  import { TestNamespace } from "../../../test/utils.jsx";
4
4
  import { VarDeclaration } from "./declaration.jsx";
@@ -51,3 +51,18 @@ it("links refkey", () => {
51
51
  var testVar2 = testVar;
52
52
  `);
53
53
  });
54
+
55
+ it("links namekey", () => {
56
+ const key = namekey("test-var");
57
+ expect(
58
+ <TestNamespace>
59
+ <List>
60
+ <VarDeclaration name={key}>42</VarDeclaration>
61
+ <VarDeclaration name="testVar2">{key}</VarDeclaration>
62
+ </List>
63
+ </TestNamespace>,
64
+ ).toRenderTo(`
65
+ var testVar = 42;
66
+ var testVar2 = testVar;
67
+ `);
68
+ });
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  Children,
3
+ createSymbolSlot,
3
4
  Declaration,
4
5
  DeclarationProps,
5
6
  Name,
7
+ Namekey,
6
8
  Refkey,
7
9
  } from "@alloy-js/core";
8
10
  import { createVariableSymbol } from "../../symbols/factories.js";
@@ -11,13 +13,16 @@ import { createVariableSymbol } from "../../symbols/factories.js";
11
13
  export interface VarDeclarationProps
12
14
  extends Omit<DeclarationProps, "nameKind"> {
13
15
  /** Variable name */
14
- name: string;
16
+ name: string | Namekey;
15
17
  /** Type of the variable declaration. If not specified, defaults to "var" */
16
18
  type?: Children;
17
19
  /** Variable refkey */
18
20
  refkey?: Refkey;
19
21
  /** Variable value */
20
22
  children?: Children;
23
+
24
+ /** Constant variable. Add the const modifier. */
25
+ const?: boolean;
21
26
  }
22
27
 
23
28
  /**
@@ -42,12 +47,22 @@ export interface VarDeclarationProps
42
47
  * ```
43
48
  */
44
49
  export function VarDeclaration(props: VarDeclarationProps) {
50
+ const TypeSlot = createSymbolSlot();
51
+ const ValueSlot = createSymbolSlot();
52
+
45
53
  const sym = createVariableSymbol(props.name, {
46
54
  refkeys: props.refkey,
55
+ type: props.type ? TypeSlot.firstSymbol : ValueSlot.firstSymbol,
47
56
  });
57
+
58
+ if (props.const && !props.type) {
59
+ throw new Error("Implicitly-typed variables cannot be constant");
60
+ }
48
61
  return (
49
62
  <Declaration symbol={sym}>
50
- {props.type ?? "var"} <Name /> = {props.children};
63
+ {props.const ? "const " : ""}
64
+ <TypeSlot>{props.type ?? "var"}</TypeSlot> <Name /> ={" "}
65
+ <ValueSlot>{props.children}</ValueSlot>;
51
66
  </Declaration>
52
67
  );
53
68
  }
@@ -7,9 +7,16 @@ export function useGlobalNamespace() {
7
7
  }
8
8
 
9
9
  const globalNamespaces = new WeakMap<Binder, NamespaceSymbol>();
10
- const defaultGlobalNamespace = new NamespaceSymbol("global", undefined, {
10
+ let defaultGlobalNamespace = new NamespaceSymbol("global", undefined, {
11
11
  isGlobal: true,
12
12
  });
13
+
14
+ export function resetGlobalNamespace() {
15
+ defaultGlobalNamespace = new NamespaceSymbol("global", undefined, {
16
+ isGlobal: true,
17
+ });
18
+ }
19
+
13
20
  export function getGlobalNamespace(binder: Binder | undefined) {
14
21
  if (!binder) {
15
22
  return defaultGlobalNamespace;