@typespec/emitter-framework 0.9.0-dev.3 → 0.9.0-dev.7

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 (175) hide show
  1. package/dist/src/core/components/output.d.ts +4 -4
  2. package/dist/src/core/components/output.d.ts.map +1 -1
  3. package/dist/src/core/components/output.js +3 -3
  4. package/dist/src/core/context/name-policy-context.d.ts +2 -2
  5. package/dist/src/core/context/name-policy-context.d.ts.map +1 -1
  6. package/dist/src/core/context/tsp-context.d.ts +2 -2
  7. package/dist/src/core/context/tsp-context.d.ts.map +1 -1
  8. package/dist/src/core/transport-name-policy.d.ts +1 -1
  9. package/dist/src/core/transport-name-policy.d.ts.map +1 -1
  10. package/dist/src/core/write-output.d.ts +2 -2
  11. package/dist/src/core/write-output.d.ts.map +1 -1
  12. package/dist/src/csharp/components/class/declaration.d.ts +13 -0
  13. package/dist/src/csharp/components/class/declaration.d.ts.map +1 -0
  14. package/dist/src/csharp/components/class/declaration.js +91 -0
  15. package/dist/src/csharp/components/class/declaration.test.d.ts +2 -0
  16. package/dist/src/csharp/components/class/declaration.test.d.ts.map +1 -0
  17. package/dist/src/csharp/components/class/declaration.test.js +392 -0
  18. package/dist/src/csharp/components/enum-declaration.d.ts +4 -4
  19. package/dist/src/csharp/components/enum-declaration.d.ts.map +1 -1
  20. package/dist/src/csharp/components/enum-declaration.js +14 -11
  21. package/dist/src/csharp/components/index.d.ts +2 -1
  22. package/dist/src/csharp/components/index.d.ts.map +1 -1
  23. package/dist/src/csharp/components/index.js +2 -1
  24. package/dist/src/csharp/components/property/property.d.ts +15 -0
  25. package/dist/src/csharp/components/property/property.d.ts.map +1 -0
  26. package/dist/src/csharp/components/property/property.js +85 -0
  27. package/dist/src/csharp/components/property/property.test.d.ts +2 -0
  28. package/dist/src/csharp/components/property/property.test.d.ts.map +1 -0
  29. package/dist/src/csharp/components/property/property.test.js +117 -0
  30. package/dist/src/csharp/components/type-expression.d.ts +3 -3
  31. package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
  32. package/dist/src/csharp/components/type-expression.js +15 -1
  33. package/dist/src/csharp/components/type-expression.test.d.ts +2 -0
  34. package/dist/src/csharp/components/type-expression.test.d.ts.map +1 -0
  35. package/dist/src/csharp/components/type-expression.test.js +128 -0
  36. package/dist/src/csharp/components/utils/doc-comments.d.ts +14 -0
  37. package/dist/src/csharp/components/utils/doc-comments.d.ts.map +1 -0
  38. package/dist/src/csharp/components/utils/doc-comments.js +67 -0
  39. package/dist/src/testing/index.d.ts +1 -1
  40. package/dist/src/testing/index.d.ts.map +1 -1
  41. package/dist/src/testing/scenario-test/harness.d.ts +2 -2
  42. package/dist/src/testing/scenario-test/harness.d.ts.map +1 -1
  43. package/dist/src/testing/scenario-test/test-host.d.ts +2 -2
  44. package/dist/src/testing/scenario-test/test-host.d.ts.map +1 -1
  45. package/dist/src/typescript/components/array-expression.d.ts +2 -3
  46. package/dist/src/typescript/components/array-expression.d.ts.map +1 -1
  47. package/dist/src/typescript/components/array-expression.js +2 -2
  48. package/dist/src/typescript/components/arrow-function.d.ts +2 -2
  49. package/dist/src/typescript/components/arrow-function.d.ts.map +1 -1
  50. package/dist/src/typescript/components/arrow-function.js +2 -1
  51. package/dist/src/typescript/components/class-method.d.ts +1 -1
  52. package/dist/src/typescript/components/class-method.d.ts.map +1 -1
  53. package/dist/src/typescript/components/enum-declaration.d.ts +6 -6
  54. package/dist/src/typescript/components/enum-declaration.d.ts.map +1 -1
  55. package/dist/src/typescript/components/enum-declaration.js +2 -2
  56. package/dist/src/typescript/components/function-declaration.d.ts +1 -1
  57. package/dist/src/typescript/components/function-declaration.d.ts.map +1 -1
  58. package/dist/src/typescript/components/function-expression.d.ts +2 -2
  59. package/dist/src/typescript/components/function-expression.d.ts.map +1 -1
  60. package/dist/src/typescript/components/function-expression.js +2 -1
  61. package/dist/src/typescript/components/function-type.d.ts +2 -2
  62. package/dist/src/typescript/components/function-type.d.ts.map +1 -1
  63. package/dist/src/typescript/components/function-type.js +2 -1
  64. package/dist/src/typescript/components/interface-declaration.d.ts +4 -4
  65. package/dist/src/typescript/components/interface-declaration.d.ts.map +1 -1
  66. package/dist/src/typescript/components/interface-declaration.js +3 -4
  67. package/dist/src/typescript/components/interface-member.d.ts +2 -2
  68. package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
  69. package/dist/src/typescript/components/interface-method.d.ts +2 -2
  70. package/dist/src/typescript/components/interface-method.d.ts.map +1 -1
  71. package/dist/src/typescript/components/record-expression.d.ts +1 -1
  72. package/dist/src/typescript/components/record-expression.d.ts.map +1 -1
  73. package/dist/src/typescript/components/type-alias-declaration.d.ts +1 -1
  74. package/dist/src/typescript/components/type-alias-declaration.d.ts.map +1 -1
  75. package/dist/src/typescript/components/type-declaration.d.ts +1 -1
  76. package/dist/src/typescript/components/type-declaration.d.ts.map +1 -1
  77. package/dist/src/typescript/components/type-expression.d.ts +1 -1
  78. package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
  79. package/dist/src/typescript/components/type-transform.d.ts +2 -2
  80. package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
  81. package/dist/src/typescript/components/union-declaration.d.ts +2 -2
  82. package/dist/src/typescript/components/union-declaration.d.ts.map +1 -1
  83. package/dist/src/typescript/components/union-expression.d.ts +3 -4
  84. package/dist/src/typescript/components/union-expression.d.ts.map +1 -1
  85. package/dist/src/typescript/components/union-expression.js +3 -3
  86. package/dist/src/typescript/components/value-expression.d.ts +2 -2
  87. package/dist/src/typescript/components/value-expression.d.ts.map +1 -1
  88. package/dist/src/typescript/utils/operation.d.ts +2 -2
  89. package/dist/src/typescript/utils/operation.d.ts.map +1 -1
  90. package/dist/test/csharp/components/enum-declaration.test.js +57 -9
  91. package/dist/test/csharp/test-host.d.ts +1 -1
  92. package/dist/test/csharp/test-host.d.ts.map +1 -1
  93. package/dist/test/csharp/utils.d.ts +1 -1
  94. package/dist/test/csharp/utils.d.ts.map +1 -1
  95. package/dist/test/test-host.d.ts +2 -0
  96. package/dist/test/test-host.d.ts.map +1 -0
  97. package/dist/test/test-host.js +5 -0
  98. package/dist/test/typescript/components/member-expression.test.js +5 -5
  99. package/dist/test/typescript/test-host.d.ts +1 -1
  100. package/dist/test/typescript/test-host.d.ts.map +1 -1
  101. package/dist/test/utils.d.ts +2 -2
  102. package/dist/test/utils.d.ts.map +1 -1
  103. package/dist/test/vitest.setup.d.ts +2 -0
  104. package/dist/test/vitest.setup.d.ts.map +1 -0
  105. package/dist/test/vitest.setup.js +1 -0
  106. package/package.json +10 -7
  107. package/src/core/components/output.tsx +9 -5
  108. package/src/core/context/name-policy-context.ts +2 -2
  109. package/src/core/context/tsp-context.ts +2 -2
  110. package/src/core/transport-name-policy.ts +1 -1
  111. package/src/core/write-output.ts +2 -2
  112. package/src/csharp/components/class/declaration.test.tsx +401 -0
  113. package/src/csharp/components/class/declaration.tsx +86 -0
  114. package/src/csharp/components/enum-declaration.tsx +26 -18
  115. package/src/csharp/components/index.ts +2 -1
  116. package/src/csharp/components/property/property.test.tsx +97 -0
  117. package/src/csharp/components/property/property.tsx +62 -0
  118. package/src/csharp/components/type-expression.test.tsx +133 -0
  119. package/src/csharp/components/type-expression.tsx +11 -4
  120. package/src/csharp/components/utils/doc-comments.tsx +58 -0
  121. package/src/testing/index.ts +1 -1
  122. package/src/testing/scenario-test/harness.ts +2 -2
  123. package/src/testing/scenario-test/test-host.ts +4 -4
  124. package/src/typescript/components/array-expression.tsx +3 -3
  125. package/src/typescript/components/arrow-function.tsx +2 -2
  126. package/src/typescript/components/class-method.tsx +1 -1
  127. package/src/typescript/components/enum-declaration.tsx +6 -6
  128. package/src/typescript/components/function-declaration.tsx +1 -1
  129. package/src/typescript/components/function-expression.tsx +2 -2
  130. package/src/typescript/components/function-type.tsx +2 -2
  131. package/src/typescript/components/interface-declaration.tsx +11 -12
  132. package/src/typescript/components/interface-member.tsx +2 -2
  133. package/src/typescript/components/interface-method.tsx +2 -2
  134. package/src/typescript/components/record-expression.tsx +1 -1
  135. package/src/typescript/components/type-alias-declaration.tsx +1 -1
  136. package/src/typescript/components/type-declaration.tsx +1 -1
  137. package/src/typescript/components/type-expression.tsx +2 -2
  138. package/src/typescript/components/type-transform.tsx +3 -3
  139. package/src/typescript/components/union-declaration.tsx +2 -2
  140. package/src/typescript/components/union-expression.tsx +12 -7
  141. package/src/typescript/components/value-expression.tsx +2 -2
  142. package/src/typescript/utils/operation.ts +2 -2
  143. package/test/csharp/components/enum-declaration.test.tsx +52 -11
  144. package/test/csharp/test-host.ts +2 -2
  145. package/test/csharp/utils.ts +1 -1
  146. package/test/test-host.ts +4 -0
  147. package/test/testing/snippet-extractor-csharp.test.ts +1 -1
  148. package/test/testing/snippet-extractor-java.test.ts +1 -1
  149. package/test/testing/snippet-extractor-python.test.ts +1 -1
  150. package/test/testing/snippet-extractor-typescript.test.ts +1 -1
  151. package/test/typescript/components/arrow-function.test.tsx +2 -2
  152. package/test/typescript/components/enum-declaration.test.tsx +1 -1
  153. package/test/typescript/components/function-declaration.test.tsx +1 -1
  154. package/test/typescript/components/function-expression.test.tsx +2 -2
  155. package/test/typescript/components/function-type.test.tsx +2 -2
  156. package/test/typescript/components/interface-declaration.test.tsx +1 -1
  157. package/test/typescript/components/interface-method.test.tsx +2 -2
  158. package/test/typescript/components/member-expression.test.tsx +10 -10
  159. package/test/typescript/components/type-alias-declaration.test.tsx +1 -1
  160. package/test/typescript/components/type-transform.test.tsx +2 -2
  161. package/test/typescript/components/union-declaration.test.tsx +2 -2
  162. package/test/typescript/components/value-expression.test.tsx +6 -6
  163. package/test/typescript/test-host.ts +1 -1
  164. package/test/utils.ts +2 -2
  165. package/test/vitest.setup.ts +1 -0
  166. package/tsconfig.json +3 -1
  167. package/vitest.config.ts +2 -1
  168. package/dist/src/csharp/components/class-declaration.d.ts +0 -9
  169. package/dist/src/csharp/components/class-declaration.d.ts.map +0 -1
  170. package/dist/src/csharp/components/class-declaration.js +0 -97
  171. package/dist/test/csharp/components/class-declaration.test.d.ts +0 -2
  172. package/dist/test/csharp/components/class-declaration.test.d.ts.map +0 -1
  173. package/dist/test/csharp/components/class-declaration.test.js +0 -421
  174. package/src/csharp/components/class-declaration.tsx +0 -87
  175. package/test/csharp/components/class-declaration.test.tsx +0 -344
@@ -1,10 +1,10 @@
1
- import * as ay from "@alloy-js/core";
2
- import { Program } from "@typespec/compiler";
3
- export interface OutputProps extends ay.OutputProps {
1
+ import { type OutputProps as CoreOutputProps } from "@alloy-js/core";
2
+ import type { Program } from "@typespec/compiler";
3
+ export interface OutputProps extends CoreOutputProps {
4
4
  /**
5
5
  * TypeSpec program.
6
6
  */
7
7
  program: Program;
8
8
  }
9
- export declare function Output(props: OutputProps): ay.Children;
9
+ export declare function Output(props: OutputProps): import("@alloy-js/core").Children;
10
10
  //# sourceMappingURL=output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/core/components/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,WAAW,WAAY,SAAQ,EAAE,CAAC,WAAW;IACjD;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,eAOxC"}
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/core/components/output.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,IAAI,eAAe,EACpC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,qCAOxC"}
@@ -1,16 +1,16 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import * as ay from "@alloy-js/core";
2
+ import { Output as CoreOutput, splitProps } from "@alloy-js/core";
3
3
  import { TspContext } from "../context/tsp-context.js";
4
4
  export function Output(props) {
5
5
  const [{
6
6
  program
7
- }, rest] = ay.splitProps(props, ["program"]);
7
+ }, rest] = splitProps(props, ["program"]);
8
8
  return _$createComponent(TspContext.Provider, {
9
9
  value: {
10
10
  program
11
11
  },
12
12
  get children() {
13
- return _$createComponent(ay.Output, rest);
13
+ return _$createComponent(CoreOutput, rest);
14
14
  }
15
15
  });
16
16
  }
@@ -1,5 +1,5 @@
1
- import { ComponentContext } from "@alloy-js/core";
2
- import { TransformNamePolicy } from "../transport-name-policy.js";
1
+ import { type ComponentContext } from "@alloy-js/core";
2
+ import type { TransformNamePolicy } from "../transport-name-policy.js";
3
3
  export declare const TransformNamePolicyContext: ComponentContext<TransformNamePolicy>;
4
4
  export declare function useTransformNamePolicy(): TransformNamePolicy;
5
5
  //# sourceMappingURL=name-policy-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"name-policy-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/name-policy-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAElE,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,CAAC,mBAAmB,CAQzE,CAAC;AAEL,wBAAgB,sBAAsB,wBAErC"}
1
+ {"version":3,"file":"name-policy-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/name-policy-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,CAAC,mBAAmB,CAQzE,CAAC;AAEL,wBAAgB,sBAAsB,wBAErC"}
@@ -1,5 +1,5 @@
1
- import { ComponentContext } from "@alloy-js/core";
2
- import { Program } from "@typespec/compiler";
1
+ import { type ComponentContext } from "@alloy-js/core";
2
+ import type { Program } from "@typespec/compiler";
3
3
  import { type Typekit } from "@typespec/compiler/typekit";
4
4
  export type TspContext = {
5
5
  program: Program;
@@ -1 +1 @@
1
- {"version":3,"file":"tsp-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/tsp-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,EAAE,OAAO,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,OAAO,CAAA;CAAE,CAG3D,CAAC;AAEjB,wBAAgB,MAAM,IAaF,UAAU,CAC7B"}
1
+ {"version":3,"file":"tsp-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/tsp-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,EAAE,OAAO,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,OAAO,CAAA;CAAE,CAG3D,CAAC;AAEjB,wBAAgB,MAAM,IAaF,UAAU,CAC7B"}
@@ -1,4 +1,4 @@
1
- import { Type } from "@typespec/compiler";
1
+ import type { Type } from "@typespec/compiler";
2
2
  /**
3
3
  * A type that extends `Type` and includes a `name` property that can either be a `string` or `symbol`.
4
4
  * This type is used to represent objects that have a `name` of type `string` or `symbol`.
@@ -1 +1 @@
1
- {"version":3,"file":"transport-name-policy.d.ts","sourceRoot":"","sources":["../../../src/core/transport-name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3D;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC7D,gBAAgB,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CAChE,GAAG,mBAAmB,CAsBtB"}
1
+ {"version":3,"file":"transport-name-policy.d.ts","sourceRoot":"","sources":["../../../src/core/transport-name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3D;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC7D,gBAAgB,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CAChE,GAAG,mBAAmB,CAsBtB"}
@@ -1,4 +1,4 @@
1
- import { Children } from "@alloy-js/core";
2
- import { Program } from "@typespec/compiler";
1
+ import { type Children } from "@alloy-js/core";
2
+ import { type Program } from "@typespec/compiler";
3
3
  export declare function writeOutput(program: Program, rootComponent: Children, emitterOutputDir: string): Promise<void>;
4
4
  //# sourceMappingURL=write-output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAuB,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,QAAQ,EACvB,gBAAgB,EAAE,MAAM,iBAIzB"}
1
+ {"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAgC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEvE,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,QAAQ,EACvB,gBAAgB,EAAE,MAAM,iBAIzB"}
@@ -0,0 +1,13 @@
1
+ import { type Children } from "@alloy-js/core";
2
+ import * as cs from "@alloy-js/csharp";
3
+ import type { Interface, Model } from "@typespec/compiler";
4
+ export interface ClassDeclarationProps extends Omit<cs.ClassDeclarationProps, "name"> {
5
+ /** Set an alternative name for the class. Otherwise default to the type name. */
6
+ name?: string;
7
+ /** Type to use to create this class. */
8
+ type: Model | Interface;
9
+ /** If set the property will add the json serialization attributes(using System.Text.Json). */
10
+ jsonAttributes?: boolean;
11
+ }
12
+ export declare function ClassDeclaration(props: ClassDeclarationProps): Children;
13
+ //# sourceMappingURL=declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/class/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAO3D,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,EAAE,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACnF,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAYD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,QAAQ,CAuBvE"}
@@ -0,0 +1,91 @@
1
+ import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { For } from "@alloy-js/core";
3
+ import * as cs from "@alloy-js/csharp";
4
+ import { useTsp } from "../../../core/index.js";
5
+ import { Property } from "../property/property.js";
6
+ import { TypeExpression } from "../type-expression.js";
7
+ import { getDocComments } from "../utils/doc-comments.js";
8
+ import { declarationRefkeys } from "../utils/refkey.js";
9
+ export function ClassDeclaration(props) {
10
+ const {
11
+ $
12
+ } = useTsp();
13
+ const namePolicy = cs.useCSharpNamePolicy();
14
+ const className = props.name ?? namePolicy.getName(props.type.name, "class");
15
+ const refkeys = declarationRefkeys(props.refkey, props.type)[0]; // TODO: support multiple refkeys for declarations in alloy
16
+
17
+ return [_$createComponent(cs.ClassDeclaration, _$mergeProps(props, {
18
+ name: className,
19
+ refkey: refkeys,
20
+ get doc() {
21
+ return getDocComments($, props.type);
22
+ },
23
+ get children() {
24
+ return [_$memo(() => _$memo(() => props.type.kind === "Model")() && _$createComponent(ClassProperties, {
25
+ get type() {
26
+ return props.type;
27
+ },
28
+ get jsonAttributes() {
29
+ return props.jsonAttributes;
30
+ }
31
+ })), _$memo(() => _$memo(() => props.type.kind === "Interface")() && _$createComponent(ClassMethods, {
32
+ get type() {
33
+ return props.type;
34
+ }
35
+ }))];
36
+ }
37
+ }))];
38
+ }
39
+ function ClassProperties(props) {
40
+ return _$createComponent(For, {
41
+ get each() {
42
+ return props.type.properties.entries();
43
+ },
44
+ hardline: true,
45
+ children: ([name, property]) => _$createComponent(Property, {
46
+ type: property,
47
+ get jsonAttributes() {
48
+ return props.jsonAttributes;
49
+ }
50
+ })
51
+ });
52
+ }
53
+ function ClassMethods(props) {
54
+ const {
55
+ $
56
+ } = useTsp();
57
+ const namePolicy = cs.useCSharpNamePolicy();
58
+ const abstractMethods = [];
59
+ for (const [name, method] of props.type.operations) {
60
+ abstractMethods.push(_$createComponent(cs.ClassMethod, {
61
+ get name() {
62
+ return namePolicy.getName(name, "class-method");
63
+ },
64
+ abstract: true,
65
+ get parameters() {
66
+ return [...method.parameters.properties.entries()].map(([name, prop]) => {
67
+ return {
68
+ name: namePolicy.getName(name, "type-parameter"),
69
+ type: _$createComponent(TypeExpression, {
70
+ get type() {
71
+ return prop.type;
72
+ }
73
+ })
74
+ };
75
+ });
76
+ },
77
+ "public": true,
78
+ get doc() {
79
+ return getDocComments($, method);
80
+ },
81
+ get returns() {
82
+ return _$createComponent(TypeExpression, {
83
+ get type() {
84
+ return method.returnType;
85
+ }
86
+ });
87
+ }
88
+ }));
89
+ }
90
+ return [abstractMethods];
91
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=declaration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/class/declaration.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,392 @@
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { Tester } from "#test/test-host.js";
3
+ import { render } from "@alloy-js/core";
4
+ import { d } from "@alloy-js/core/testing";
5
+ import { createCSharpNamePolicy, Namespace, SourceFile } from "@alloy-js/csharp";
6
+ import { t } from "@typespec/compiler/testing";
7
+ import { beforeEach, describe, it } from "vitest";
8
+ import { assertFileContents } from "../../../../test/csharp/utils.js";
9
+ import { Output } from "../../../core/index.js";
10
+ import { ClassDeclaration, EnumDeclaration } from "../../index.js";
11
+ let runner;
12
+ beforeEach(async () => {
13
+ runner = await Tester.createInstance();
14
+ });
15
+ function Wrapper(props) {
16
+ const policy = createCSharpNamePolicy();
17
+ return _$createComponent(Output, {
18
+ get program() {
19
+ return runner.program;
20
+ },
21
+ namePolicy: policy,
22
+ get children() {
23
+ return _$createComponent(Namespace, {
24
+ name: "TestNamespace",
25
+ get children() {
26
+ return _$createComponent(SourceFile, {
27
+ path: "test.cs",
28
+ get children() {
29
+ return props.children;
30
+ }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ });
36
+ }
37
+ it("renders an empty class declaration", async () => {
38
+ const {
39
+ TestModel
40
+ } = await runner.compile(t.code`
41
+ model ${t.model("TestModel")} {}
42
+ `);
43
+ const res = render(_$createComponent(Wrapper, {
44
+ get children() {
45
+ return _$createComponent(ClassDeclaration, {
46
+ type: TestModel
47
+ });
48
+ }
49
+ }));
50
+ assertFileContents(res, d`
51
+ namespace TestNamespace
52
+ {
53
+ class TestModel
54
+ {
55
+
56
+ }
57
+ }
58
+ `);
59
+ });
60
+ it("renders a class declaration with properties", async () => {
61
+ const {
62
+ TestModel
63
+ } = await runner.compile(t.code`
64
+ model ${t.model("TestModel")} {
65
+ @test Prop1: string;
66
+ @test Prop2: int32;
67
+ }
68
+ `);
69
+ const res = render(_$createComponent(Wrapper, {
70
+ get children() {
71
+ return _$createComponent(ClassDeclaration, {
72
+ type: TestModel
73
+ });
74
+ }
75
+ }));
76
+ assertFileContents(res, d`
77
+ namespace TestNamespace
78
+ {
79
+ class TestModel
80
+ {
81
+ public required string Prop1 { get; set; }
82
+ public required int Prop2 { get; set; }
83
+ }
84
+ }
85
+ `);
86
+ });
87
+ it("can override class name", async () => {
88
+ const {
89
+ TestModel
90
+ } = await runner.compile(t.code`
91
+ model ${t.model("TestModel")} {}
92
+ `);
93
+ const res = render(_$createComponent(Wrapper, {
94
+ get children() {
95
+ return _$createComponent(ClassDeclaration, {
96
+ type: TestModel,
97
+ name: "CustomClassName"
98
+ });
99
+ }
100
+ }));
101
+ assertFileContents(res, d`
102
+ namespace TestNamespace
103
+ {
104
+ class CustomClassName
105
+ {
106
+
107
+ }
108
+ }
109
+ `);
110
+ });
111
+ it("renders a class with access modifiers", async () => {
112
+ const {
113
+ TestModel
114
+ } = await runner.compile(t.code`
115
+ model ${t.model("TestModel")} {
116
+ }
117
+ `);
118
+ const res = render(_$createComponent(Wrapper, {
119
+ get children() {
120
+ return _$createComponent(ClassDeclaration, {
121
+ type: TestModel,
122
+ "protected": true
123
+ });
124
+ }
125
+ }));
126
+ assertFileContents(res, d`
127
+ namespace TestNamespace
128
+ {
129
+ protected class TestModel
130
+ {
131
+
132
+ }
133
+ }
134
+ `);
135
+ });
136
+ describe("from an interface", () => {
137
+ it("renders an empty class", async () => {
138
+ const {
139
+ TestInterface
140
+ } = await runner.compile(t.code`
141
+ interface ${t.interface("TestInterface")} {
142
+ }
143
+ `);
144
+ const res = render(_$createComponent(Wrapper, {
145
+ get children() {
146
+ return _$createComponent(ClassDeclaration, {
147
+ type: TestInterface
148
+ });
149
+ }
150
+ }));
151
+ assertFileContents(res, d`
152
+ namespace TestNamespace
153
+ {
154
+ class TestInterface
155
+ {
156
+
157
+ }
158
+ }
159
+ `);
160
+ });
161
+ it("renders a class with operations", async () => {
162
+ const {
163
+ TestInterface
164
+ } = await runner.compile(t.code`
165
+ interface ${t.interface("TestInterface")} {
166
+ op getName(id: string): string;
167
+ }
168
+ `);
169
+ const res = render(_$createComponent(Wrapper, {
170
+ get children() {
171
+ return _$createComponent(ClassDeclaration, {
172
+ type: TestInterface
173
+ });
174
+ }
175
+ }));
176
+ assertFileContents(res, d`
177
+ namespace TestNamespace
178
+ {
179
+ class TestInterface
180
+ {
181
+ public abstract string GetName(string id);
182
+ }
183
+ }
184
+ `);
185
+ });
186
+ });
187
+ it("renders a class with model members", async () => {
188
+ const {
189
+ TestModel,
190
+ TestReference
191
+ } = await runner.compile(t.code`
192
+ model ${t.model("TestReference")} { }
193
+ model ${t.model("TestModel")} {
194
+ prop1: TestReference;
195
+ }
196
+ `);
197
+ const res = render(_$createComponent(Wrapper, {
198
+ get children() {
199
+ return [_$createComponent(ClassDeclaration, {
200
+ type: TestReference
201
+ }), _$createIntrinsic("hbr", {}), _$createComponent(ClassDeclaration, {
202
+ type: TestModel
203
+ })];
204
+ }
205
+ }));
206
+ assertFileContents(res, d`
207
+ namespace TestNamespace
208
+ {
209
+ class TestReference
210
+ {
211
+
212
+ }
213
+ class TestModel
214
+ {
215
+ public required TestReference Prop1 { get; set; }
216
+ }
217
+ }
218
+ `);
219
+ });
220
+ it("renders a class with enum members", async () => {
221
+ const {
222
+ TestModel,
223
+ TestEnum
224
+ } = await runner.compile(t.code`
225
+ @test enum ${t.enum("TestEnum")} {
226
+ Value1;
227
+ Value2;
228
+ }
229
+ model ${t.model("TestModel")} {
230
+ @test prop1: TestEnum;
231
+ }
232
+ `);
233
+ const res = render(_$createComponent(Wrapper, {
234
+ get children() {
235
+ return [_$createComponent(EnumDeclaration, {
236
+ type: TestEnum
237
+ }), _$createIntrinsic("hbr", {}), _$createComponent(ClassDeclaration, {
238
+ type: TestModel
239
+ })];
240
+ }
241
+ }));
242
+ assertFileContents(res, d`
243
+ namespace TestNamespace
244
+ {
245
+ enum TestEnum
246
+ {
247
+ Value1,
248
+ Value2
249
+ }
250
+ class TestModel
251
+ {
252
+ public required TestEnum Prop1 { get; set; }
253
+ }
254
+ }
255
+ `);
256
+ });
257
+ it("maps prop: string | null to nullable property", async () => {
258
+ const {
259
+ TestModel
260
+ } = await runner.compile(t.code`
261
+ model ${t.model("TestModel")} {
262
+ prop1: string | null;
263
+ }
264
+ `);
265
+ const res = render(_$createComponent(Wrapper, {
266
+ get children() {
267
+ return _$createComponent(ClassDeclaration, {
268
+ type: TestModel
269
+ });
270
+ }
271
+ }));
272
+ assertFileContents(res, d`
273
+ namespace TestNamespace
274
+ {
275
+ class TestModel
276
+ {
277
+ public required string? Prop1 { get; set; }
278
+ }
279
+ }
280
+ `);
281
+ });
282
+ it("renders a class with string enums", async () => {
283
+ const {
284
+ TestModel,
285
+ TestEnum
286
+ } = await runner.compile(t.code`
287
+ @test enum ${t.enum("TestEnum")} {
288
+ Value1;
289
+ Value2;
290
+ }
291
+ model ${t.model("TestModel")} {
292
+ @test prop1: TestEnum;
293
+ }
294
+ `);
295
+ const res = render(_$createComponent(Wrapper, {
296
+ get children() {
297
+ return [_$createComponent(EnumDeclaration, {
298
+ type: TestEnum
299
+ }), _$createIntrinsic("hbr", {}), _$createComponent(ClassDeclaration, {
300
+ type: TestModel
301
+ })];
302
+ }
303
+ }));
304
+ assertFileContents(res, d`
305
+ namespace TestNamespace
306
+ {
307
+ enum TestEnum
308
+ {
309
+ Value1,
310
+ Value2
311
+ }
312
+ class TestModel
313
+ {
314
+ public required TestEnum Prop1 { get; set; }
315
+ }
316
+ }
317
+ `);
318
+ });
319
+ describe("with doc comments", () => {
320
+ it("renders a model with docs", async () => {
321
+ const {
322
+ TestModel
323
+ } = await runner.compile(t.code`
324
+ @doc("This is a test model")
325
+ model ${t.model("TestModel")} {
326
+ @doc("This is a test property")
327
+ prop1: string;
328
+ }
329
+
330
+ `);
331
+ const res = render(_$createComponent(Wrapper, {
332
+ get children() {
333
+ return _$createComponent(ClassDeclaration, {
334
+ type: TestModel
335
+ });
336
+ }
337
+ }));
338
+ assertFileContents(res, d`
339
+ namespace TestNamespace
340
+ {
341
+ /// <summary>
342
+ /// This is a test model
343
+ /// </summary>
344
+ class TestModel
345
+ {
346
+ /// <summary>
347
+ /// This is a test property
348
+ /// </summary>
349
+ public required string Prop1 { get; set; }
350
+ }
351
+ }
352
+ `);
353
+ });
354
+ it("renders an interface with docs", async () => {
355
+ const {
356
+ TestInterface
357
+ } = await runner.compile(t.code`
358
+ @doc("This is a test interface")
359
+ @test interface ${t.interface("TestInterface")} {
360
+ @doc("This is a test operation")
361
+ @returnsDoc("The name of the item")
362
+ op getName(id: string): string;
363
+ }
364
+ `);
365
+ const res = render(_$createComponent(Wrapper, {
366
+ get children() {
367
+ return _$createComponent(ClassDeclaration, {
368
+ type: TestInterface
369
+ });
370
+ }
371
+ }));
372
+ assertFileContents(res, d`
373
+ namespace TestNamespace
374
+ {
375
+ /// <summary>
376
+ /// This is a test interface
377
+ /// </summary>
378
+ class TestInterface
379
+ {
380
+ /// <summary>
381
+ /// This is a test operation
382
+ /// </summary>
383
+ ///
384
+ /// <returns>
385
+ /// The name of the item
386
+ /// </returns>
387
+ public abstract string GetName(string id);
388
+ }
389
+ }
390
+ `);
391
+ });
392
+ });
@@ -1,9 +1,9 @@
1
- import * as ay from "@alloy-js/core";
1
+ import { type Children } from "@alloy-js/core";
2
2
  import * as cs from "@alloy-js/csharp";
3
- import { Enum, Union } from "@typespec/compiler";
4
- export interface EnumDeclarationProps extends Omit<cs.EnumProps, "name"> {
3
+ import type { Enum, Union } from "@typespec/compiler";
4
+ export interface EnumDeclarationProps extends Omit<cs.EnumDeclarationProps, "name"> {
5
5
  name?: string;
6
6
  type: Union | Enum;
7
7
  }
8
- export declare function EnumDeclaration(props: EnumDeclarationProps): ay.Children;
8
+ export declare function EnumDeclaration(props: EnumDeclarationProps): Children;
9
9
  //# sourceMappingURL=enum-declaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"enum-declaration.d.ts","sourceRoot":"","sources":["../../../../src/csharp/components/enum-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,EAAE,CAAC,QAAQ,CAmCxE"}
1
+ {"version":3,"file":"enum-declaration.d.ts","sourceRoot":"","sources":["../../../../src/csharp/components/enum-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAMtD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,QAAQ,CA0CrE"}
@@ -1,8 +1,9 @@
1
- import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import * as ay from "@alloy-js/core";
1
+ import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { For } from "@alloy-js/core";
3
3
  import * as cs from "@alloy-js/csharp";
4
4
  import { useTsp } from "../../core/index.js";
5
5
  import { reportDiagnostic } from "../../lib.js";
6
+ import { getDocComments } from "./utils/doc-comments.js";
6
7
  import { declarationRefkeys, efRefkey } from "./utils/refkey.js";
7
8
  export function EnumDeclaration(props) {
8
9
  const {
@@ -26,27 +27,29 @@ export function EnumDeclaration(props) {
26
27
  const refkeys = declarationRefkeys(props.refkey, props.type)[0]; // TODO: support multiple refkeys for declarations in alloy
27
28
  const name = props.name ?? cs.useCSharpNamePolicy().getName(props.type.name, "enum");
28
29
  const members = Array.from(type.members.entries());
29
- return _$createComponent(cs.Enum, {
30
+ return [_$createComponent(cs.EnumDeclaration, _$mergeProps({
30
31
  name: name,
31
- refkey: refkeys,
32
- get accessModifier() {
33
- return props.accessModifier ?? "public";
34
- },
32
+ refkey: refkeys
33
+ }, props, {
35
34
  get children() {
36
- return _$createComponent(ay.For, {
35
+ return _$createComponent(For, {
37
36
  each: members,
38
37
  joiner: ",\n",
39
38
  children: ([key, value]) => {
40
- return _$createComponent(cs.EnumMember, {
39
+ return [_$createComponent(cs.DocWhen, {
40
+ get doc() {
41
+ return getDocComments($, value);
42
+ }
43
+ }), _$createComponent(cs.EnumMember, {
41
44
  get name() {
42
45
  return cs.useCSharpNamePolicy().getName(key, "enum-member");
43
46
  },
44
47
  get refkey() {
45
48
  return _$memo(() => !!$.union.is(props.type))() ? efRefkey(props.type.variants.get(key)) : efRefkey(value);
46
49
  }
47
- });
50
+ })];
48
51
  }
49
52
  });
50
53
  }
51
- });
54
+ }))];
52
55
  }