@typespec/emitter-framework 0.11.0-dev.0 → 0.11.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 (212) hide show
  1. package/dist/src/core/components/index.d.ts +2 -0
  2. package/dist/src/core/components/index.d.ts.map +1 -1
  3. package/dist/src/core/components/index.js +4 -1
  4. package/dist/src/core/components/index.js.map +1 -0
  5. package/dist/src/core/components/output.js +2 -1
  6. package/dist/src/core/components/output.js.map +1 -0
  7. package/dist/src/core/components/overrides/component-overrides.d.ts +64 -0
  8. package/dist/src/core/components/overrides/component-overrides.d.ts.map +1 -0
  9. package/dist/src/core/components/overrides/component-overrides.js +41 -0
  10. package/dist/src/core/components/overrides/component-overrides.js.map +1 -0
  11. package/dist/src/core/components/overrides/config.d.ts +28 -0
  12. package/dist/src/core/components/overrides/config.d.ts.map +1 -0
  13. package/dist/src/core/components/overrides/config.js +55 -0
  14. package/dist/src/core/components/overrides/config.js.map +1 -0
  15. package/dist/src/core/components/overrides/context.d.ts +11 -0
  16. package/dist/src/core/components/overrides/context.d.ts.map +1 -0
  17. package/dist/src/core/components/overrides/context.js +9 -0
  18. package/dist/src/core/components/overrides/context.js.map +1 -0
  19. package/dist/src/core/context/index.js +2 -1
  20. package/dist/src/core/context/index.js.map +1 -0
  21. package/dist/src/core/context/name-policy-context.js +2 -1
  22. package/dist/src/core/context/name-policy-context.js.map +1 -0
  23. package/dist/src/core/context/tsp-context.js +2 -1
  24. package/dist/src/core/context/tsp-context.js.map +1 -0
  25. package/dist/src/core/index.js +2 -1
  26. package/dist/src/core/index.js.map +1 -0
  27. package/dist/src/core/transport-name-policy.js +2 -1
  28. package/dist/src/core/transport-name-policy.js.map +1 -0
  29. package/dist/src/core/write-output.d.ts.map +1 -1
  30. package/dist/src/core/write-output.js +4 -3
  31. package/dist/src/core/write-output.js.map +1 -0
  32. package/dist/src/csharp/components/class/declaration.d.ts +1 -1
  33. package/dist/src/csharp/components/class/declaration.d.ts.map +1 -1
  34. package/dist/src/csharp/components/class/declaration.js +14 -5
  35. package/dist/src/csharp/components/class/declaration.js.map +1 -0
  36. package/dist/src/csharp/components/class/declaration.test.js +125 -92
  37. package/dist/src/csharp/components/class/declaration.test.js.map +1 -0
  38. package/dist/src/csharp/components/enum/declaration.js +2 -1
  39. package/dist/src/csharp/components/enum/declaration.js.map +1 -0
  40. package/dist/src/csharp/components/enum/declaration.test.js +52 -88
  41. package/dist/src/csharp/components/enum/declaration.test.js.map +1 -0
  42. package/dist/src/csharp/components/index.js +2 -1
  43. package/dist/src/csharp/components/index.js.map +1 -0
  44. package/dist/src/csharp/components/property/property.d.ts.map +1 -1
  45. package/dist/src/csharp/components/property/property.js +40 -14
  46. package/dist/src/csharp/components/property/property.js.map +1 -0
  47. package/dist/src/csharp/components/property/property.test.js +129 -29
  48. package/dist/src/csharp/components/property/property.test.js.map +1 -0
  49. package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
  50. package/dist/src/csharp/components/type-expression.js +34 -6
  51. package/dist/src/csharp/components/type-expression.js.map +1 -0
  52. package/dist/src/csharp/components/type-expression.test.js +87 -54
  53. package/dist/src/csharp/components/type-expression.test.js.map +1 -0
  54. package/dist/src/csharp/components/utils/doc-comments.js +2 -1
  55. package/dist/src/csharp/components/utils/doc-comments.js.map +1 -0
  56. package/dist/src/csharp/components/utils/nullable-util.d.ts +4 -0
  57. package/dist/src/csharp/components/utils/nullable-util.d.ts.map +1 -0
  58. package/dist/src/csharp/components/utils/nullable-util.js +27 -0
  59. package/dist/src/csharp/components/utils/nullable-util.js.map +1 -0
  60. package/dist/src/csharp/components/utils/refkey.js +2 -1
  61. package/dist/src/csharp/components/utils/refkey.js.map +1 -0
  62. package/dist/src/csharp/index.js +2 -1
  63. package/dist/src/csharp/index.js.map +1 -0
  64. package/dist/src/lib.js +2 -1
  65. package/dist/src/lib.js.map +1 -0
  66. package/dist/src/testing/index.js +2 -1
  67. package/dist/src/testing/index.js.map +1 -0
  68. package/dist/src/testing/scenario-test/code-block-expectation.js +2 -1
  69. package/dist/src/testing/scenario-test/code-block-expectation.js.map +1 -0
  70. package/dist/src/testing/scenario-test/code-block-expectation.test.js +2 -1
  71. package/dist/src/testing/scenario-test/code-block-expectation.test.js.map +1 -0
  72. package/dist/src/testing/scenario-test/harness.js +8 -2
  73. package/dist/src/testing/scenario-test/harness.js.map +1 -0
  74. package/dist/src/testing/scenario-test/index.js +2 -1
  75. package/dist/src/testing/scenario-test/index.js.map +1 -0
  76. package/dist/src/testing/scenario-test/snippet-extractor.js +2 -1
  77. package/dist/src/testing/scenario-test/snippet-extractor.js.map +1 -0
  78. package/dist/src/typescript/components/array-expression.js +2 -1
  79. package/dist/src/typescript/components/array-expression.js.map +1 -0
  80. package/dist/src/typescript/components/arrow-function.js +2 -1
  81. package/dist/src/typescript/components/arrow-function.js.map +1 -0
  82. package/dist/src/typescript/components/class-method.js +2 -1
  83. package/dist/src/typescript/components/class-method.js.map +1 -0
  84. package/dist/src/typescript/components/enum-declaration.js +2 -1
  85. package/dist/src/typescript/components/enum-declaration.js.map +1 -0
  86. package/dist/src/typescript/components/function-declaration.js +2 -1
  87. package/dist/src/typescript/components/function-declaration.js.map +1 -0
  88. package/dist/src/typescript/components/function-expression.js +2 -1
  89. package/dist/src/typescript/components/function-expression.js.map +1 -0
  90. package/dist/src/typescript/components/function-type.js +2 -1
  91. package/dist/src/typescript/components/function-type.js.map +1 -0
  92. package/dist/src/typescript/components/index.js +2 -1
  93. package/dist/src/typescript/components/index.js.map +1 -0
  94. package/dist/src/typescript/components/interface-declaration.js +2 -1
  95. package/dist/src/typescript/components/interface-declaration.js.map +1 -0
  96. package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
  97. package/dist/src/typescript/components/interface-member.js +13 -20
  98. package/dist/src/typescript/components/interface-member.js.map +1 -0
  99. package/dist/src/typescript/components/interface-method.js +2 -1
  100. package/dist/src/typescript/components/interface-method.js.map +1 -0
  101. package/dist/src/typescript/components/record-expression.js +2 -1
  102. package/dist/src/typescript/components/record-expression.js.map +1 -0
  103. package/dist/src/typescript/components/static-serializers.js +2 -1
  104. package/dist/src/typescript/components/static-serializers.js.map +1 -0
  105. package/dist/src/typescript/components/type-alias-declaration.js +2 -1
  106. package/dist/src/typescript/components/type-alias-declaration.js.map +1 -0
  107. package/dist/src/typescript/components/type-declaration.js +2 -1
  108. package/dist/src/typescript/components/type-declaration.js.map +1 -0
  109. package/dist/src/typescript/components/type-expression.d.ts +0 -1
  110. package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
  111. package/dist/src/typescript/components/type-expression.js +13 -12
  112. package/dist/src/typescript/components/type-expression.js.map +1 -0
  113. package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
  114. package/dist/src/typescript/components/type-transform.js +5 -4
  115. package/dist/src/typescript/components/type-transform.js.map +1 -0
  116. package/dist/src/typescript/components/union/declaration.js +2 -1
  117. package/dist/src/typescript/components/union/declaration.js.map +1 -0
  118. package/dist/src/typescript/components/union/declaration.test.js +2 -1
  119. package/dist/src/typescript/components/union/declaration.test.js.map +1 -0
  120. package/dist/src/typescript/components/union/expression.js +2 -1
  121. package/dist/src/typescript/components/union/expression.js.map +1 -0
  122. package/dist/src/typescript/components/union/expression.test.js +2 -1
  123. package/dist/src/typescript/components/union/expression.test.js.map +1 -0
  124. package/dist/src/typescript/components/value-expression.js +2 -1
  125. package/dist/src/typescript/components/value-expression.js.map +1 -0
  126. package/dist/src/typescript/index.js +2 -1
  127. package/dist/src/typescript/index.js.map +1 -0
  128. package/dist/src/typescript/lib.js +2 -1
  129. package/dist/src/typescript/lib.js.map +1 -0
  130. package/dist/src/typescript/utils/index.js +2 -1
  131. package/dist/src/typescript/utils/index.js.map +1 -0
  132. package/dist/src/typescript/utils/operation.js +2 -1
  133. package/dist/src/typescript/utils/operation.js.map +1 -0
  134. package/dist/src/typescript/utils/refkey.js +2 -1
  135. package/dist/src/typescript/utils/refkey.js.map +1 -0
  136. package/dist/test/test-host.js +2 -1
  137. package/dist/test/test-host.js.map +1 -0
  138. package/dist/test/testing/snippet-extractor-csharp.test.js +2 -1
  139. package/dist/test/testing/snippet-extractor-csharp.test.js.map +1 -0
  140. package/dist/test/testing/snippet-extractor-java.test.js +2 -1
  141. package/dist/test/testing/snippet-extractor-java.test.js.map +1 -0
  142. package/dist/test/testing/snippet-extractor-python.test.js +2 -1
  143. package/dist/test/testing/snippet-extractor-python.test.js.map +1 -0
  144. package/dist/test/testing/snippet-extractor-typescript.test.js +2 -1
  145. package/dist/test/testing/snippet-extractor-typescript.test.js.map +1 -0
  146. package/dist/test/typescript/components/arrow-function.test.js +18 -22
  147. package/dist/test/typescript/components/arrow-function.test.js.map +1 -0
  148. package/dist/test/typescript/components/component-override.test.d.ts +2 -0
  149. package/dist/test/typescript/components/component-override.test.d.ts.map +1 -0
  150. package/dist/test/typescript/components/component-override.test.js +78 -0
  151. package/dist/test/typescript/components/component-override.test.js.map +1 -0
  152. package/dist/test/typescript/components/enum-declaration.test.js +2 -1
  153. package/dist/test/typescript/components/enum-declaration.test.js.map +1 -0
  154. package/dist/test/typescript/components/function-declaration.test.js +3 -2
  155. package/dist/test/typescript/components/function-declaration.test.js.map +1 -0
  156. package/dist/test/typescript/components/function-expression.test.js +18 -22
  157. package/dist/test/typescript/components/function-expression.test.js.map +1 -0
  158. package/dist/test/typescript/components/function-type.test.js +18 -22
  159. package/dist/test/typescript/components/function-type.test.js.map +1 -0
  160. package/dist/test/typescript/components/interface-declaration.test.js +3 -2
  161. package/dist/test/typescript/components/interface-declaration.test.js.map +1 -0
  162. package/dist/test/typescript/components/interface-method.test.js +37 -45
  163. package/dist/test/typescript/components/interface-method.test.js.map +1 -0
  164. package/dist/test/typescript/components/member-expression.test.js +2 -1
  165. package/dist/test/typescript/components/member-expression.test.js.map +1 -0
  166. package/dist/test/typescript/components/type-alias-declaration.test.js +8 -5
  167. package/dist/test/typescript/components/type-alias-declaration.test.js.map +1 -0
  168. package/dist/test/typescript/components/type-transform.test.js +29 -27
  169. package/dist/test/typescript/components/type-transform.test.js.map +1 -0
  170. package/dist/test/typescript/components/value-expression.test.js +3 -2
  171. package/dist/test/typescript/components/value-expression.test.js.map +1 -0
  172. package/dist/test/typescript/utils.js +2 -1
  173. package/dist/test/typescript/utils.js.map +1 -0
  174. package/dist/test/utils.d.ts +1 -0
  175. package/dist/test/utils.d.ts.map +1 -1
  176. package/dist/test/utils.js +13 -3
  177. package/dist/test/utils.js.map +1 -0
  178. package/dist/test/vitest.setup.js +2 -1
  179. package/dist/test/vitest.setup.js.map +1 -0
  180. package/package.json +9 -13
  181. package/src/core/components/index.tsx +2 -0
  182. package/src/core/components/overrides/component-overrides.tsx +134 -0
  183. package/src/core/components/overrides/config.ts +85 -0
  184. package/src/core/components/overrides/context.ts +14 -0
  185. package/src/core/write-output.ts +2 -2
  186. package/src/csharp/components/class/declaration.test.tsx +114 -88
  187. package/src/csharp/components/class/declaration.tsx +13 -3
  188. package/src/csharp/components/enum/declaration.test.tsx +47 -78
  189. package/src/csharp/components/property/property.test.tsx +108 -25
  190. package/src/csharp/components/property/property.tsx +43 -11
  191. package/src/csharp/components/type-expression.test.tsx +84 -69
  192. package/src/csharp/components/type-expression.tsx +31 -5
  193. package/src/csharp/components/utils/nullable-util.ts +25 -0
  194. package/src/testing/scenario-test/harness.ts +6 -1
  195. package/src/typescript/components/interface-member.tsx +8 -14
  196. package/src/typescript/components/type-expression.tsx +7 -8
  197. package/src/typescript/components/type-transform.tsx +3 -7
  198. package/test/typescript/components/arrow-function.test.tsx +23 -42
  199. package/test/typescript/components/component-override.test.tsx +71 -0
  200. package/test/typescript/components/function-declaration.test.tsx +2 -1
  201. package/test/typescript/components/function-expression.test.tsx +23 -42
  202. package/test/typescript/components/function-type.test.tsx +22 -40
  203. package/test/typescript/components/interface-declaration.test.tsx +1 -1
  204. package/test/typescript/components/interface-method.test.tsx +50 -92
  205. package/test/typescript/components/type-alias-declaration.test.tsx +8 -6
  206. package/test/typescript/components/type-transform.test.tsx +37 -37
  207. package/test/typescript/components/value-expression.test.tsx +1 -1
  208. package/test/utils.ts +10 -3
  209. package/dist/test/typescript/test-host.d.ts +0 -16
  210. package/dist/test/typescript/test-host.d.ts.map +0 -1
  211. package/dist/test/typescript/test-host.js +0 -40
  212. package/test/typescript/test-host.ts +0 -49
@@ -1,18 +1,44 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import * as cs from "@alloy-js/csharp";
3
3
  import { Attribute } from "@alloy-js/csharp";
4
- import { resolveEncodedName } from "@typespec/compiler";
4
+ import { getProperty, resolveEncodedName } from "@typespec/compiler";
5
5
  import { useTsp } from "../../../core/index.js";
6
6
  import { TypeExpression } from "../type-expression.js";
7
7
  import { getDocComments } from "../utils/doc-comments.js";
8
+ import { getNullableUnionInnerType } from "../utils/nullable-util.js";
8
9
  /**
9
10
  * Create a C# property declaration from a TypeSpec property type.
10
11
  */
11
12
  export function Property(props) {
12
- const result = preprocessPropertyType(props.type.type);
13
+ const result = preprocessPropertyType(props.type);
13
14
  const {
14
15
  $
15
16
  } = useTsp();
17
+ let overrideType = "";
18
+ let isVirtual = false;
19
+ if (props.type.model) {
20
+ if (props.type.model.baseModel) {
21
+ const base = props.type.model.baseModel;
22
+ const baseProperty = getProperty(base, props.type.name);
23
+ if (baseProperty) {
24
+ const baseResult = preprocessPropertyType(baseProperty);
25
+ if (baseResult.nullable === result.nullable && baseResult.type === result.type) {
26
+ overrideType = "override";
27
+ } else {
28
+ overrideType = "new";
29
+ }
30
+ }
31
+ }
32
+ if (overrideType === "" && props.type.model.derivedModels && props.type.model.derivedModels.length > 0) {
33
+ isVirtual = props.type.model.derivedModels.some(derived => {
34
+ const derivedProperty = derived.properties.get(props.type.name);
35
+ if (derivedProperty) {
36
+ const derivedResult = preprocessPropertyType(derivedProperty);
37
+ return derivedResult.nullable === result.nullable && derivedResult.type === result.type;
38
+ }
39
+ });
40
+ }
41
+ }
16
42
  return _$createComponent(cs.Property, {
17
43
  get name() {
18
44
  return props.type.name;
@@ -24,7 +50,10 @@ export function Property(props) {
24
50
  }
25
51
  });
26
52
  },
53
+ override: overrideType === "override",
54
+ "new": overrideType === "new",
27
55
  "public": true,
56
+ virtual: isVirtual,
28
57
  get required() {
29
58
  return !props.type.optional;
30
59
  },
@@ -57,29 +86,26 @@ function JsonNameAttribute(props) {
57
86
  }
58
87
  });
59
88
  }
60
- function preprocessPropertyType(type) {
61
- const {
62
- $
63
- } = useTsp();
89
+ function preprocessPropertyType(prop) {
90
+ const type = prop.type;
64
91
  if (type.kind === "Union") {
65
- const variants = type.variants;
66
- const nonNullVariant = [...variants.values()].find(v => v.type !== $.intrinsic.null);
67
- const nullVariant = [...variants.values()].find(v => v.type !== $.intrinsic.null);
68
- if (nonNullVariant && nullVariant && variants.size === 2) {
92
+ const innerType = getNullableUnionInnerType(type);
93
+ if (innerType) {
69
94
  return {
70
- type: nonNullVariant.type,
95
+ type: innerType,
71
96
  nullable: true
72
97
  };
73
98
  } else {
74
99
  return {
75
100
  type,
76
- nullable: false
101
+ nullable: prop.optional
77
102
  };
78
103
  }
79
104
  } else {
80
105
  return {
81
106
  type,
82
- nullable: false
107
+ nullable: prop.optional
83
108
  };
84
109
  }
85
- }
110
+ }
111
+ //# sourceMappingURL=property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["cs","Attribute","getProperty","resolveEncodedName","useTsp","TypeExpression","getDocComments","getNullableUnionInnerType","Property","props","result","preprocessPropertyType","type","$","overrideType","isVirtual","model","baseModel","base","baseProperty","name","baseResult","nullable","derivedModels","length","some","derived","derivedProperty","properties","get","derivedResult","_$createComponent","override","virtual","required","optional","doc","attributes","_$memo","jsonAttributes","JsonNameAttribute","undefined","set","program","jsonName","args","JSON","stringify","prop","kind","innerType"],"sources":["../../../../../src/csharp/components/property/property.tsx"],"sourcesContent":[null],"mappings":";AACA,OAAO,KAAKA,EAAE,MAAM,kBAAkB;AACtC,SAASC,SAAS,QAAQ,kBAAkB;AAC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C;EAAQ,CAAC,GAAGvC,MAAM,CAAC,CAAC;EAC5B,MAAMwC,QAAQ,GAAGzC,kBAAkB,CAACwC,OAAO,EAAElC,KAAK,CAACG,IAAI,EAAE,kBAAkB,CAAC;EAC5E,OAAAmB,iBAAA,CAAQ9B,SAAS;IAACmB,IAAI;IAAA,IAAqCyB,IAAIA,CAAA;MAAA,OAAE,CAACC,IAAI,CAACC,SAAS,CAACH,QAAQ,CAAC,CAAC;IAAA;EAAA;AAC7F;AAEA,SAASjC,sBAAsBA,CAACqC,IAAmB,EAAqC;EACtF,MAAMpC,IAAI,GAAGoC,IAAI,CAACpC,IAAI;EAEtB,IAAIA,IAAI,CAACqC,IAAI,KAAK,OAAO,EAAE;IACzB,MAAMC,SAAS,GAAG3C,yBAAyB,CAACK,IAAI,CAAC;IACjD,IAAIsC,SAAS,EAAE;MACb,OAAO;QAAEtC,IAAI,EAAEsC,SAAS;QAAE5B,QAAQ,EAAE;MAAK,CAAC;IAC5C,CAAC,MAAM;MACL,OAAO;QAAEV,IAAI;QAAEU,QAAQ,EAAE0B,IAAI,CAACb;MAAS,CAAC;IAC1C;EACF,CAAC,MAAM;IACL,OAAO;MAAEvB,IAAI;MAAEU,QAAQ,EAAE0B,IAAI,CAACb;IAAS,CAAC;EAC1C;AACF","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import { Tester } from "#test/test-host.js";
3
- import { ClassDeclaration, createCSharpNamePolicy, Namespace, SourceFile } from "@alloy-js/csharp";
3
+ import { List } from "@alloy-js/core";
4
+ import { ClassDeclaration, createCSharpNamePolicy, SourceFile } from "@alloy-js/csharp";
4
5
  import { t } from "@typespec/compiler/testing";
5
6
  import { beforeEach, describe, expect, it } from "vitest";
6
7
  import { Output } from "../../../core/components/output.js";
@@ -17,18 +18,13 @@ function Wrapper(props) {
17
18
  },
18
19
  namePolicy: policy,
19
20
  get children() {
20
- return _$createComponent(Namespace, {
21
- name: "TestNamespace",
21
+ return _$createComponent(SourceFile, {
22
+ path: "test.cs",
22
23
  get children() {
23
- return _$createComponent(SourceFile, {
24
- path: "test.cs",
24
+ return _$createComponent(ClassDeclaration, {
25
+ name: "Test",
25
26
  get children() {
26
- return _$createComponent(ClassDeclaration, {
27
- name: "Test",
28
- get children() {
29
- return props.children;
30
- }
31
- });
27
+ return props.children;
32
28
  }
33
29
  });
34
30
  }
@@ -51,12 +47,51 @@ it("maps prop: string | null to nullable property", async () => {
51
47
  });
52
48
  }
53
49
  })).toRenderTo(`
54
- namespace TestNamespace
50
+ class Test
55
51
  {
56
- class Test
57
- {
58
- public required string? Prop1 { get; set; }
59
- }
52
+ public required string? Prop1 { get; set; }
53
+ }
54
+ `);
55
+ });
56
+ it("maps optional properties to nullable properties", async () => {
57
+ const {
58
+ prop1
59
+ } = await tester.compile(t.code`
60
+ model TestModel {
61
+ ${t.modelProperty("prop1")}?: string;
62
+ }
63
+ `);
64
+ expect(_$createComponent(Wrapper, {
65
+ get children() {
66
+ return _$createComponent(Property, {
67
+ type: prop1
68
+ });
69
+ }
70
+ })).toRenderTo(`
71
+ class Test
72
+ {
73
+ public string? Prop1 { get; set; }
74
+ }
75
+ `);
76
+ });
77
+ it("maps optional and nullable properties to nullable properties", async () => {
78
+ const {
79
+ prop1
80
+ } = await tester.compile(t.code`
81
+ model TestModel {
82
+ ${t.modelProperty("prop1")}?: string | null;
83
+ }
84
+ `);
85
+ expect(_$createComponent(Wrapper, {
86
+ get children() {
87
+ return _$createComponent(Property, {
88
+ type: prop1
89
+ });
90
+ }
91
+ })).toRenderTo(`
92
+ class Test
93
+ {
94
+ public string? Prop1 { get; set; }
60
95
  }
61
96
  `);
62
97
  });
@@ -77,13 +112,10 @@ describe("jsonAttributes", () => {
77
112
  });
78
113
  }
79
114
  })).toRenderTo(`
80
- namespace TestNamespace
115
+ class Test
81
116
  {
82
- class Test
83
- {
84
- [System.Text.Json.JsonPropertyName("prop1")]
85
- public required string Prop1 { get; set; }
86
- }
117
+ [System.Text.Json.JsonPropertyName("prop1")]
118
+ public required string Prop1 { get; set; }
87
119
  }
88
120
  `);
89
121
  });
@@ -104,14 +136,82 @@ describe("jsonAttributes", () => {
104
136
  });
105
137
  }
106
138
  })).toRenderTo(`
107
- namespace TestNamespace
139
+ class Test
140
+ {
141
+ [System.Text.Json.JsonPropertyName("prop_1")]
142
+ public required string Prop1 { get; set; }
143
+ }
144
+ `);
145
+ });
146
+ it("inherit prop: override, new", async () => {
147
+ const r = await tester.compile(t.code`
148
+ model TestModel extends BaseModel {
149
+ ${t.modelProperty("prop1")}: string;
150
+ ${t.modelProperty("prop2")}: string | null;
151
+ }
152
+ model BaseModel {
153
+ prop1: string | null;
154
+ prop2: string | null;
155
+ }
156
+ `);
157
+ expect(_$createComponent(Wrapper, {
158
+ get children() {
159
+ return _$createComponent(List, {
160
+ get children() {
161
+ return [_$createComponent(Property, {
162
+ get type() {
163
+ return r.prop1;
164
+ }
165
+ }), _$createComponent(Property, {
166
+ get type() {
167
+ return r.prop2;
168
+ }
169
+ })];
170
+ }
171
+ });
172
+ }
173
+ })).toRenderTo(`
174
+ class Test
108
175
  {
109
- class Test
110
- {
111
- [System.Text.Json.JsonPropertyName("prop_1")]
112
- public required string Prop1 { get; set; }
176
+ public new required string Prop1 { get; set; }
177
+ public override required string? Prop2 { get; set; }
178
+ }
179
+ `);
180
+ });
181
+ it("inherit prop: virtual", async () => {
182
+ const r = await tester.compile(t.code`
183
+ model TestModel extends BaseModel {
184
+ prop1: string;
185
+ prop2: string | null;
186
+ }
187
+ model BaseModel {
188
+ ${t.modelProperty("prop1")}: string | null;
189
+ ${t.modelProperty("prop2")}: string | null;
190
+ }
191
+ `);
192
+ expect(_$createComponent(Wrapper, {
193
+ get children() {
194
+ return _$createComponent(List, {
195
+ get children() {
196
+ return [_$createComponent(Property, {
197
+ get type() {
198
+ return r.prop1;
199
+ }
200
+ }), _$createComponent(Property, {
201
+ get type() {
202
+ return r.prop2;
203
+ }
204
+ })];
113
205
  }
206
+ });
114
207
  }
115
- `);
208
+ })).toRenderTo(`
209
+ class Test
210
+ {
211
+ public required string? Prop1 { get; set; }
212
+ public virtual required string? Prop2 { get; set; }
213
+ }
214
+ `);
116
215
  });
117
- });
216
+ });
217
+ //# sourceMappingURL=property.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Tester","List","ClassDeclaration","createCSharpNamePolicy","SourceFile","t","beforeEach","describe","expect","it","Output","Property","tester","createInstance","Wrapper","props","policy","_$createComponent","program","namePolicy","children","path","name","prop1","compile","code","modelProperty","type","toRenderTo","jsonAttributes","r","prop2"],"sources":["../../../../../src/csharp/components/property/property.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,IAAI,QAAuB,gBAAgB;AACpD,SAASC,gBAAgB,EAAEC,sBAAsB,EAAEC,UAAU,QAAQ,kBAAkB;AACvF,SAASC,CAAC,QAA6B,4BAA4B;AACnE,SAASC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,MAAM;AACf,SAASC,QAAQ;AAEjB,IAAIC,MAAsB;AAE1BN,UAAU,CAAC,YAAY;EACrBM,MAAM,GAAG,MAAMZ,MAAM,CAACa,cAAc,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,SAASC,OAAOA,CAACC,KAA6B,EAAE;EAC9C,MAAMC,MAAM,GAAGb,sBAAsB,CAAC,CAAC;EACvC,OAAAc,iBAAA,CACGP,MAAM;IAAA,IAACQ,OAAOA,CAAA;MAAA,OAAEN,MAAM,CAACM,OAAO;IAAA;IAAEC,UAAU,EAAEH,MAAM;IAAA,IAAAI,SAAA;MAAA,OAAAH,iBAAA,CAChDb,UAAU;QAACiB,IAAI;QAAA,IAAAD,SAAA;UAAA,OAAAH,iBAAA,CACbf,gBAAgB;YAACoB,IAAI;YAAA,IAAAF,SAAA;cAAA,OAASL,KAAK,CAACK,Q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CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"type-expression.d.ts","sourceRoot":"","sources":["../../../../src/csharp/components/type-expression.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAe,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAK1D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,QAAQ,CAgBnE;AAED,QAAA,MAAM,yBAAyB,4BAqC7B,CAAC;AAEH,wBAAgB,4BAA4B,CAC1C,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,MAAM,GAAG,aAAa,GAC3B,MAAM,GAAG,IAAI,CAoBf;AA0BD,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
1
+ {"version":3,"file":"type-expression.d.ts","sourceRoot":"","sources":["../../../../src/csharp/components/type-expression.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,IAAI,EACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAM1D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,QAAQ,CAmCnE;AAED,QAAA,MAAM,yBAAyB,4BAqC7B,CAAC;AAEH,wBAAgB,4BAA4B,CAC1C,CAAC,EAAE,OAAO,EACV,IAAI,EAAE,MAAM,GAAG,aAAa,GAC3B,MAAM,GAAG,IAAI,CAoBf;AAyBD,OAAO,EAAE,yBAAyB,EAAE,CAAC"}
@@ -1,18 +1,36 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { Experimental_OverridableComponent } from "#core/index.js";
2
3
  import { code } from "@alloy-js/core";
3
4
  import { Reference } from "@alloy-js/csharp";
4
- import { getTypeName } from "@typespec/compiler";
5
+ import { getTypeName, isVoidType } from "@typespec/compiler";
5
6
  import { useTsp } from "../../core/index.js";
6
7
  import { reportTypescriptDiagnostic } from "../../typescript/lib.js";
8
+ import { getNullableUnionInnerType } from "./utils/nullable-util.js";
7
9
  import { efRefkey } from "./utils/refkey.js";
8
10
  export function TypeExpression(props) {
11
+ if (props.type.kind === "Union") {
12
+ const nullabletype = getNullableUnionInnerType(props.type);
13
+ if (nullabletype) {
14
+ return code`${_$createComponent(TypeExpression, {
15
+ type: nullabletype
16
+ })}?`;
17
+ }
18
+ }
9
19
  const {
10
20
  $
11
21
  } = useTsp();
12
22
  if (isDeclaration($, props.type)) {
13
- return _$createComponent(Reference, {
14
- get refkey() {
15
- return efRefkey(props.type);
23
+ return _$createComponent(Experimental_OverridableComponent, {
24
+ reference: true,
25
+ get type() {
26
+ return props.type;
27
+ },
28
+ get children() {
29
+ return _$createComponent(Reference, {
30
+ get refkey() {
31
+ return efRefkey(props.type);
32
+ }
33
+ });
16
34
  }
17
35
  });
18
36
  }
@@ -30,6 +48,15 @@ export function TypeExpression(props) {
30
48
  return props.type.indexer.value;
31
49
  }
32
50
  })}>`;
51
+ } else if ($.literal.isString(props.type)) {
52
+ // c# doesn't have literal types, so we map them to their corresponding C# types in general
53
+ return code`string`;
54
+ } else if ($.literal.isNumeric(props.type)) {
55
+ return Number.isInteger(props.type.value) ? code`int` : code`double`;
56
+ } else if ($.literal.isBoolean(props.type)) {
57
+ return code`bool`;
58
+ } else if (isVoidType(props.type)) {
59
+ return code`void`;
33
60
  }
34
61
  throw new Error(`Unsupported type for TypeExpression: ${props.type.kind} (${getTypeName(props.type)})`);
35
62
  }
@@ -133,11 +160,12 @@ function isDeclaration($, type) {
133
160
  if ($.array.is(type) || $.record.is(type)) {
134
161
  return false;
135
162
  }
136
- return Boolean(type.name);
163
+ return true;
137
164
  case "Union":
138
165
  return Boolean(type.name);
139
166
  default:
140
167
  return false;
141
168
  }
142
169
  }
143
- export { intrinsicNameToCSharpType };
170
+ export { intrinsicNameToCSharpType };
171
+ //# sourceMappingURL=type-expression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Experimental_OverridableComponent","code","Reference","getTypeName","isVoidType","useTsp","reportTypescriptDiagnostic","getNullableUnionInnerType","efRefkey","TypeExpression","props","type","kind","nullabletype","_$createComponent","$","isDeclaration","reference","children","refkey","scalar","is","getScalarIntrinsicExpression","array","indexer","value","record","literal","isString","isNumeric","Number","isInteger","isBoolean","Error","intrinsicNameToCSharpType","Map","intrinsicName","isUtcDateTime","extendsUtcDateTime","getStdBase","name","csType","get","program","target","Boolean"],"sources":["../../../../src/csharp/components/type-expression.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,iCAAiC,QAAQ,gBAAgB;AAClE,SAASC,IAAI,QAAuB,gBAAgB;AACpD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SACEC,WAAW,EACXC,UAAU,QAIL,oBAAoB;AAE3B,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,0BAA0B,QAAQ,yBAAyB;AACpE,SAASC,yBAAyB,QAAQ,0BAA0B;AACpE,SAASC,QAAQ,QAAQ,mBAAmB;AAM5C,OAAO,SAASC,cAAcA,CAACC,KAA0B,EAAY;EACnE,IAAIA,KAAK,CAACC,IAAI,CAACC,IAAI,KAAK,OAAO,EAAE;IAC/B,MAAMC,YAAY,GAAGN,yBAAyB,CAACG,KAAK,CAACC,IAAI,CAAC;IAC1D,IAAIE,YAAY,EAAE;MAChB,OAAOZ,IAAI,GAAAa,iBAAA,CAAKL,cAAc;QAACE,IAAI,EAAEE;MAAY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AAE,+BAA+B;MAAE2C,MAAM,EAAEjC;IAAK,CAAC,CAAC;IAC9F,OAAO,QAAQ,CAAC,CAAC;EACnB;EAEA,OAAO8B,MAAM;AACf;AAEA,SAASzB,aAAaA,CAACD,CAAU,EAAEJ,IAAU,EAAW;EACtD,QAAQA,IAAI,CAACC,IAAI;IACf,KAAK,WAAW;IAChB,KAAK,WAAW;IAChB,KAAK,MAAM;IACX,KAAK,WAAW;IAChB,KAAK,YAAY;MACf,OAAO,IAAI;IACb,KAAK,cAAc;MACjB,OAAO,KAAK;IAEd,KAAK,OAAO;MACV,IAAIG,CAAC,CAACQ,KAAK,CAACF,EAAE,CAACV,IAAI,CAAC,IAAII,CAAC,CAACW,MAAM,CAACL,EAAE,CAACV,IAAI,CAAC,EAAE;QACzC,OAAO,KAAK;MACd;MACA,OAAO,IAAI;IACb,KAAK,OAAO;MACV,OAAOkC,OAAO,CAAClC,IAAI,CAAC6B,IAAI,CAAC;IAC3B;MACE,OAAO,KAAK;EAChB;AACF;AAEA,SAASN,yBAAyB","ignoreList":[]}
@@ -1,16 +1,14 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { render } from "@alloy-js/core";
3
- import { d } from "@alloy-js/core/testing";
4
- import { Namespace, SourceFile } from "@alloy-js/csharp";
5
- import { beforeEach, describe, it } from "vitest";
6
- import { createEmitterFrameworkTestRunner } from "../../../test/typescript/test-host.js";
7
- import { assertFileContents } from "../../../test/utils.js";
2
+ import { Tester } from "#test/test-host.js";
3
+ import { SourceFile } from "@alloy-js/csharp";
4
+ import { t } from "@typespec/compiler/testing";
5
+ import { beforeEach, describe, expect, it } from "vitest";
8
6
  import { Output } from "../../core/index.js";
9
7
  import { ClassDeclaration } from "./class/declaration.js";
10
8
  import { TypeExpression } from "./type-expression.js";
11
9
  let runner;
12
10
  beforeEach(async () => {
13
- runner = await createEmitterFrameworkTestRunner();
11
+ runner = await Tester.createInstance();
14
12
  });
15
13
  function Wrapper(props) {
16
14
  return _$createComponent(Output, {
@@ -18,15 +16,10 @@ function Wrapper(props) {
18
16
  return runner.program;
19
17
  },
20
18
  get children() {
21
- return _$createComponent(Namespace, {
22
- name: "TestNamespace",
19
+ return _$createComponent(SourceFile, {
20
+ path: "test.ts",
23
21
  get children() {
24
- return _$createComponent(SourceFile, {
25
- path: "test.ts",
26
- get children() {
27
- return props.children;
28
- }
29
- });
22
+ return props.children;
30
23
  }
31
24
  });
32
25
  }
@@ -45,65 +38,53 @@ async function compileType(ref) {
45
38
  describe("map scalar to c# built-in types", () => {
46
39
  it.each([["string", "string"], ["int32", "int"], ["int64", "long"]])("%s => %s", async (tspType, csType) => {
47
40
  const type = await compileType(tspType);
48
- const res = render(_$createComponent(Wrapper, {
41
+ expect(_$createComponent(Wrapper, {
49
42
  get children() {
50
43
  return _$createComponent(TypeExpression, {
51
44
  type: type
52
45
  });
53
46
  }
54
- }));
55
- assertFileContents(res, d`
56
- namespace TestNamespace
57
- {
58
- ${csType}
59
- }
47
+ })).toRenderTo(`
48
+ ${csType}
60
49
  `);
61
50
  });
62
51
  });
63
52
  it("maps array to c# array", async () => {
64
53
  const type = await compileType("int32[]");
65
- const res = render(_$createComponent(Wrapper, {
54
+ expect(_$createComponent(Wrapper, {
66
55
  get children() {
67
56
  return _$createComponent(TypeExpression, {
68
57
  type: type
69
58
  });
70
59
  }
71
- }));
72
- assertFileContents(res, d`
73
- namespace TestNamespace
74
- {
75
- int[]
76
- }
77
- `);
60
+ })).toRenderTo(`
61
+ int[]
62
+ `);
78
63
  });
79
64
  describe("Record map to IDictionary", () => {
80
65
  it("for primitive types", async () => {
81
66
  const type = await compileType("Record<int32>");
82
- const res = render(_$createComponent(Wrapper, {
67
+ expect(_$createComponent(Wrapper, {
83
68
  get children() {
84
69
  return _$createComponent(TypeExpression, {
85
70
  type: type
86
71
  });
87
72
  }
88
- }));
89
- assertFileContents(res, d`
90
- namespace TestNamespace
91
- {
92
- IDictionary<string, int>
93
- }
94
- `);
73
+ })).toRenderTo(`
74
+ IDictionary<string, int>
75
+ `);
95
76
  });
96
77
  it("for models", async () => {
97
78
  const {
98
79
  test,
99
80
  Pet
100
- } = await runner.compile(`
81
+ } = await runner.compile(t.code`
101
82
  model Test {
102
- @test test: Record<Pet>;
83
+ ${t.modelProperty("test")}: Record<Pet>;
103
84
  }
104
- @test model Pet {}
85
+ @test model ${t.model("Pet")} {}
105
86
  `);
106
- const res = render(_$createComponent(Wrapper, {
87
+ expect(_$createComponent(Wrapper, {
107
88
  get children() {
108
89
  return [_$createComponent(ClassDeclaration, {
109
90
  type: Pet
@@ -113,16 +94,68 @@ describe("Record map to IDictionary", () => {
113
94
  }
114
95
  })];
115
96
  }
116
- }));
117
- assertFileContents(res, d`
118
- namespace TestNamespace
119
- {
120
- class Pet
121
- {
122
-
123
- }
124
- IDictionary<string, Pet>
125
- }
126
- `);
97
+ })).toRenderTo(`
98
+ class Pet
99
+ {
100
+
101
+ }
102
+ IDictionary<string, Pet>
103
+ `);
104
+ });
105
+ });
106
+ describe("Nullable union", () => {
107
+ it("nullable boolean", async () => {
108
+ const {
109
+ Pet
110
+ } = await runner.compile(t.code`
111
+ @test model ${t.model("Pet")} {
112
+ @test name: boolean | null;
113
+ }
114
+ `);
115
+ expect(_$createComponent(Wrapper, {
116
+ get children() {
117
+ return _$createComponent(ClassDeclaration, {
118
+ type: Pet
119
+ });
120
+ }
121
+ })).toRenderTo(`
122
+ class Pet
123
+ {
124
+ public required bool? name { get; set; }
125
+ }
126
+ `);
127
+ });
128
+ });
129
+ describe("Literal types", () => {
130
+ it("literal types (string, int, double, bool)", async () => {
131
+ const {
132
+ Pet
133
+ } = await runner.compile(t.code`
134
+ @test model ${t.model("Pet")} {
135
+ @test boolName: true;
136
+ @test intName: 42;
137
+ @test doubleName: 3.14;
138
+ @test stringName: "Hello";
139
+ }
140
+ `);
141
+ expect(_$createComponent(Wrapper, {
142
+ get children() {
143
+ return _$createComponent(ClassDeclaration, {
144
+ type: Pet
145
+ });
146
+ }
147
+ })).toRenderTo(`
148
+ class Pet
149
+ {
150
+ public required bool boolName { get; set; }
151
+
152
+ public required int intName { get; set; }
153
+
154
+ public required double doubleName { get; set; }
155
+
156
+ public required string stringName { get; set; }
157
+ }
158
+ `);
127
159
  });
128
- });
160
+ });
161
+ //# sourceMappingURL=type-expression.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Tester","SourceFile","t","beforeEach","describe","expect","it","Output","ClassDeclaration","TypeExpression","runner","createInstance","Wrapper","props","_$createComponent","program","children","path","compileType","ref","test","compile","type","each","tspType","csType","toRenderTo","Pet","code","modelProperty","model","_$createIntrinsic"],"sources":["../../../../src/csharp/components/type-expression.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,oBAAoB;AAE3C,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,CAAC,QAA6B,4BAA4B;AACnE,SAASC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,gBAAgB,QAAQ,wBAAwB;AACzD,SAASC,cAAc;AAEvB,IAAIC,MAAsB;AAE1BP,UAAU,CAAC,YAAY;EACrBO,MAAM,GAAG,MAAMV,MAAM,CAACW,cAAc,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,SAASC,OAAOA,CAACC,KAA6B,EAAE;EAC9C,OAAAC,iBAAA,CACGP,MAAM;IAAA,IAACQ,OAAOA,CAAA;MAAA,OAAEL,MAAM,CAACK,OAAO;IAAA;IAAA,IAAAC,SAAA;MAAA,OAAAF,iBAAA,CAC5Bb,UAAU;QAACgB,IAAI;QAAA,IAAAD,SAAA;UAAA,OAAYH,KAAK,CAACG,QAAQ;QAAA;MAAA;IAAA;EAAA;AAGhD;AAEA,eAAeE,WAAWA,CAACC,GAAW,EAAE;EACtC,MAAM;IAAEC;EAAK,CAAC,GAAG,MAAMV,M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M;EAC9BE,EAAE,CAAC,2CAA2C,EAAE,YAAY;IAC1D,MAAM;MAAEqB;IAAI,CAAC,GAAG,MAAMjB,MAAM,CAACW,OAAO,CAACnB,CAAC,CAAC0B,IAAI;AAC/C,oBAAoB1B,CAAC,CAAC4B,KAAK,CAAC,KAAK,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;IAEFzB,MAAM,CAAAS,iBAAA,CACHF,OAAO;MAAA,IAAAI,SAAA;QAAA,OAAAF,iBAAA,CACLN,gBAAgB;UAACc,IAAI,EAAEK;QAAG;MAAA;IAAA,EAE/B,CAAC,CAACD,UAAU,CAAC;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -64,4 +64,5 @@ export function getDocComments($, type) {
64
64
  doubleHardline: true,
65
65
  children: docElements
66
66
  });
67
- }
67
+ }
68
+ //# sourceMappingURL=doc-comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["List","cs","getReturnsDoc","getDocComments","$","type","typeDoc","getDoc","undefined","docElements","push","_$createComponent","DocSummary","children","DocFromMarkdown","markdown","operation","is","paramDocs","param","parameters","properties","values","paramDoc","DocParam","name","returnDoc","program","DocReturns","doubleHardline"],"sources":["../../../../../src/csharp/components/utils/doc-comments.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAwBA,IAAI,QAAQ,gBAAgB;AACpD,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,SAASC,aAAa,QAAmB,oBAAoB;AAG7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,CAAU,EAAEC,IAAU,EAAY;EAC/D,MAAMC,OAAO,GAAGF,CAAC,CAACC,IAAI,CAACE,MAAM,CAACF,IAAI,CAAC;EACnC,IAAI,CAACC,OAAO,EAAE;IACZ,OAAOE,SAAS;EAClB;EAEA,MA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+1,4 @@
1
+ import type { Type, Union } from "@typespec/compiler";
2
+ /** Get the inner type if the union is a nullable, otherwise return undefined */
3
+ export declare function getNullableUnionInnerType(u: Union): Type | undefined;
4
+ //# sourceMappingURL=nullable-util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nullable-util.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/utils/nullable-util.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEtD,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAoBpE"}