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

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 (67) hide show
  1. package/dist/src/csharp/components/class/declaration.d.ts +13 -0
  2. package/dist/src/csharp/components/class/declaration.d.ts.map +1 -0
  3. package/dist/src/csharp/components/{class-declaration.js → class/declaration.js} +35 -41
  4. package/dist/src/csharp/components/class/declaration.test.d.ts +2 -0
  5. package/dist/src/csharp/components/class/declaration.test.d.ts.map +1 -0
  6. package/dist/src/csharp/components/class/declaration.test.js +392 -0
  7. package/dist/src/csharp/components/enum-declaration.d.ts +1 -1
  8. package/dist/src/csharp/components/enum-declaration.d.ts.map +1 -1
  9. package/dist/src/csharp/components/enum-declaration.js +12 -9
  10. package/dist/src/csharp/components/index.d.ts +2 -1
  11. package/dist/src/csharp/components/index.d.ts.map +1 -1
  12. package/dist/src/csharp/components/index.js +2 -1
  13. package/dist/src/csharp/components/property/property.d.ts +15 -0
  14. package/dist/src/csharp/components/property/property.d.ts.map +1 -0
  15. package/dist/src/csharp/components/property/property.js +85 -0
  16. package/dist/src/csharp/components/property/property.test.d.ts +2 -0
  17. package/dist/src/csharp/components/property/property.test.d.ts.map +1 -0
  18. package/dist/src/csharp/components/property/property.test.js +117 -0
  19. package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
  20. package/dist/src/csharp/components/type-expression.js +15 -1
  21. package/dist/src/csharp/components/type-expression.test.d.ts +2 -0
  22. package/dist/src/csharp/components/type-expression.test.d.ts.map +1 -0
  23. package/dist/src/csharp/components/type-expression.test.js +128 -0
  24. package/dist/src/csharp/components/utils/doc-comments.d.ts +14 -0
  25. package/dist/src/csharp/components/utils/doc-comments.d.ts.map +1 -0
  26. package/dist/src/csharp/components/utils/doc-comments.js +67 -0
  27. package/dist/src/typescript/components/arrow-function.d.ts +1 -1
  28. package/dist/src/typescript/components/arrow-function.d.ts.map +1 -1
  29. package/dist/src/typescript/components/arrow-function.js +2 -1
  30. package/dist/src/typescript/components/function-expression.d.ts +1 -1
  31. package/dist/src/typescript/components/function-expression.d.ts.map +1 -1
  32. package/dist/src/typescript/components/function-expression.js +2 -1
  33. package/dist/src/typescript/components/function-type.d.ts +1 -1
  34. package/dist/src/typescript/components/function-type.d.ts.map +1 -1
  35. package/dist/src/typescript/components/function-type.js +2 -1
  36. package/dist/test/csharp/components/enum-declaration.test.js +57 -9
  37. package/dist/test/test-host.d.ts +2 -0
  38. package/dist/test/test-host.d.ts.map +1 -0
  39. package/dist/test/test-host.js +5 -0
  40. package/dist/test/vitest.setup.d.ts +2 -0
  41. package/dist/test/vitest.setup.d.ts.map +1 -0
  42. package/dist/test/vitest.setup.js +1 -0
  43. package/package.json +10 -7
  44. package/src/csharp/components/class/declaration.test.tsx +401 -0
  45. package/src/csharp/components/class/declaration.tsx +86 -0
  46. package/src/csharp/components/enum-declaration.tsx +23 -15
  47. package/src/csharp/components/index.ts +2 -1
  48. package/src/csharp/components/property/property.test.tsx +97 -0
  49. package/src/csharp/components/property/property.tsx +62 -0
  50. package/src/csharp/components/type-expression.test.tsx +133 -0
  51. package/src/csharp/components/type-expression.tsx +10 -3
  52. package/src/csharp/components/utils/doc-comments.tsx +58 -0
  53. package/src/typescript/components/arrow-function.tsx +1 -1
  54. package/src/typescript/components/function-expression.tsx +1 -1
  55. package/src/typescript/components/function-type.tsx +1 -1
  56. package/test/csharp/components/enum-declaration.test.tsx +50 -9
  57. package/test/test-host.ts +4 -0
  58. package/test/vitest.setup.ts +1 -0
  59. package/tsconfig.json +2 -1
  60. package/vitest.config.ts +2 -1
  61. package/dist/src/csharp/components/class-declaration.d.ts +0 -9
  62. package/dist/src/csharp/components/class-declaration.d.ts.map +0 -1
  63. package/dist/test/csharp/components/class-declaration.test.d.ts +0 -2
  64. package/dist/test/csharp/components/class-declaration.test.d.ts.map +0 -1
  65. package/dist/test/csharp/components/class-declaration.test.js +0 -421
  66. package/src/csharp/components/class-declaration.tsx +0 -87
  67. package/test/csharp/components/class-declaration.test.tsx +0 -344
@@ -0,0 +1,85 @@
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as cs from "@alloy-js/csharp";
3
+ import { Attribute } from "@alloy-js/csharp";
4
+ import { resolveEncodedName } from "@typespec/compiler";
5
+ import { useTsp } from "../../../core/index.js";
6
+ import { TypeExpression } from "../type-expression.js";
7
+ import { getDocComments } from "../utils/doc-comments.js";
8
+ /**
9
+ * Create a C# property declaration from a TypeSpec property type.
10
+ */
11
+ export function Property(props) {
12
+ const result = preprocessPropertyType(props.type.type);
13
+ const {
14
+ $
15
+ } = useTsp();
16
+ return _$createComponent(cs.Property, {
17
+ get name() {
18
+ return props.type.name;
19
+ },
20
+ get type() {
21
+ return _$createComponent(TypeExpression, {
22
+ get type() {
23
+ return result.type;
24
+ }
25
+ });
26
+ },
27
+ "public": true,
28
+ get required() {
29
+ return !props.type.optional;
30
+ },
31
+ get nullable() {
32
+ return result.nullable;
33
+ },
34
+ get doc() {
35
+ return getDocComments($, props.type);
36
+ },
37
+ get attributes() {
38
+ return _$memo(() => !!props.jsonAttributes)() ? [_$createComponent(JsonNameAttribute, {
39
+ get type() {
40
+ return props.type;
41
+ }
42
+ })] : undefined;
43
+ },
44
+ get: true,
45
+ set: true
46
+ });
47
+ }
48
+ function JsonNameAttribute(props) {
49
+ const {
50
+ program
51
+ } = useTsp();
52
+ const jsonName = resolveEncodedName(program, props.type, "application/json");
53
+ return _$createComponent(Attribute, {
54
+ name: "System.Text.Json.JsonPropertyName",
55
+ get args() {
56
+ return [JSON.stringify(jsonName)];
57
+ }
58
+ });
59
+ }
60
+ function preprocessPropertyType(type) {
61
+ const {
62
+ $
63
+ } = useTsp();
64
+ 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) {
69
+ return {
70
+ type: nonNullVariant.type,
71
+ nullable: true
72
+ };
73
+ } else {
74
+ return {
75
+ type,
76
+ nullable: false
77
+ };
78
+ }
79
+ } else {
80
+ return {
81
+ type,
82
+ nullable: false
83
+ };
84
+ }
85
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=property.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.test.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/property/property.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { Tester } from "#test/test-host.js";
3
+ import { ClassDeclaration, createCSharpNamePolicy, Namespace, SourceFile } from "@alloy-js/csharp";
4
+ import { t } from "@typespec/compiler/testing";
5
+ import { beforeEach, describe, expect, it } from "vitest";
6
+ import { Output } from "../../../core/components/output.js";
7
+ import { Property } from "./property.js";
8
+ let tester;
9
+ beforeEach(async () => {
10
+ tester = await Tester.createInstance();
11
+ });
12
+ function Wrapper(props) {
13
+ const policy = createCSharpNamePolicy();
14
+ return _$createComponent(Output, {
15
+ get program() {
16
+ return tester.program;
17
+ },
18
+ namePolicy: policy,
19
+ get children() {
20
+ return _$createComponent(Namespace, {
21
+ name: "TestNamespace",
22
+ get children() {
23
+ return _$createComponent(SourceFile, {
24
+ path: "test.cs",
25
+ get children() {
26
+ return _$createComponent(ClassDeclaration, {
27
+ name: "Test",
28
+ get children() {
29
+ return props.children;
30
+ }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ });
36
+ }
37
+ });
38
+ }
39
+ it("maps prop: string | null to nullable property", async () => {
40
+ const {
41
+ prop1
42
+ } = await tester.compile(t.code`
43
+ model TestModel {
44
+ ${t.modelProperty("prop1")}: string | null;
45
+ }
46
+ `);
47
+ expect(_$createComponent(Wrapper, {
48
+ get children() {
49
+ return _$createComponent(Property, {
50
+ type: prop1
51
+ });
52
+ }
53
+ })).toRenderTo(`
54
+ namespace TestNamespace
55
+ {
56
+ class Test
57
+ {
58
+ public required string? Prop1 { get; set; }
59
+ }
60
+ }
61
+ `);
62
+ });
63
+ describe("jsonAttributes", () => {
64
+ it("adds [JsonNameAttribute]", async () => {
65
+ const {
66
+ prop1
67
+ } = await tester.compile(t.code`
68
+ model TestModel {
69
+ ${t.modelProperty("prop1")}: string;
70
+ }
71
+ `);
72
+ expect(_$createComponent(Wrapper, {
73
+ get children() {
74
+ return _$createComponent(Property, {
75
+ type: prop1,
76
+ jsonAttributes: true
77
+ });
78
+ }
79
+ })).toRenderTo(`
80
+ namespace TestNamespace
81
+ {
82
+ class Test
83
+ {
84
+ [System.Text.Json.JsonPropertyName("prop1")]
85
+ public required string Prop1 { get; set; }
86
+ }
87
+ }
88
+ `);
89
+ });
90
+ it("adds [JsonNameAttribute] respecting encodedName", async () => {
91
+ const {
92
+ prop1
93
+ } = await tester.compile(t.code`
94
+ model TestModel {
95
+ @encodedName("application/json", "prop_1")
96
+ ${t.modelProperty("prop1")}: string;
97
+ }
98
+ `);
99
+ expect(_$createComponent(Wrapper, {
100
+ get children() {
101
+ return _$createComponent(Property, {
102
+ type: prop1,
103
+ jsonAttributes: true
104
+ });
105
+ }
106
+ })).toRenderTo(`
107
+ namespace TestNamespace
108
+ {
109
+ class Test
110
+ {
111
+ [System.Text.Json.JsonPropertyName("prop_1")]
112
+ public required string Prop1 { get; set; }
113
+ }
114
+ }
115
+ `);
116
+ });
117
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"type-expression.d.ts","sourceRoot":"","sources":["../../../../src/csharp/components/type-expression.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKrD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,QAAQ,CASnE;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":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAe,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAKrD,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,5 +1,7 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { code } from "@alloy-js/core";
2
3
  import { Reference } from "@alloy-js/csharp";
4
+ import { getTypeName } from "@typespec/compiler";
3
5
  import { useTsp } from "../../core/index.js";
4
6
  import { reportTypescriptDiagnostic } from "../../typescript/lib.js";
5
7
  import { efRefkey } from "./utils/refkey.js";
@@ -16,8 +18,20 @@ export function TypeExpression(props) {
16
18
  }
17
19
  if ($.scalar.is(props.type)) {
18
20
  return getScalarIntrinsicExpression($, props.type);
21
+ } else if ($.array.is(props.type)) {
22
+ return code`${_$createComponent(TypeExpression, {
23
+ get type() {
24
+ return props.type.indexer.value;
25
+ }
26
+ })}[]`;
27
+ } else if ($.record.is(props.type)) {
28
+ return code`IDictionary<string, ${_$createComponent(TypeExpression, {
29
+ get type() {
30
+ return props.type.indexer.value;
31
+ }
32
+ })}>`;
19
33
  }
20
- throw new Error("not implemented");
34
+ throw new Error(`Unsupported type for TypeExpression: ${props.type.kind} (${getTypeName(props.type)})`);
21
35
  }
22
36
  const intrinsicNameToCSharpType = new Map([
23
37
  // Core types
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type-expression.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-expression.test.d.ts","sourceRoot":"","sources":["../../../../src/csharp/components/type-expression.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,128 @@
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";
8
+ import { Output } from "../../core/index.js";
9
+ import { ClassDeclaration } from "./class/declaration.js";
10
+ import { TypeExpression } from "./type-expression.js";
11
+ let runner;
12
+ beforeEach(async () => {
13
+ runner = await createEmitterFrameworkTestRunner();
14
+ });
15
+ function Wrapper(props) {
16
+ return _$createComponent(Output, {
17
+ get program() {
18
+ return runner.program;
19
+ },
20
+ get children() {
21
+ return _$createComponent(Namespace, {
22
+ name: "TestNamespace",
23
+ get children() {
24
+ return _$createComponent(SourceFile, {
25
+ path: "test.ts",
26
+ get children() {
27
+ return props.children;
28
+ }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ });
34
+ }
35
+ async function compileType(ref) {
36
+ const {
37
+ test
38
+ } = await runner.compile(`
39
+ model Test {
40
+ @test test: ${ref};
41
+ }
42
+ `);
43
+ return test.type;
44
+ }
45
+ describe("map scalar to c# built-in types", () => {
46
+ it.each([["string", "string"], ["int32", "int"], ["int64", "long"]])("%s => %s", async (tspType, csType) => {
47
+ const type = await compileType(tspType);
48
+ const res = render(_$createComponent(Wrapper, {
49
+ get children() {
50
+ return _$createComponent(TypeExpression, {
51
+ type: type
52
+ });
53
+ }
54
+ }));
55
+ assertFileContents(res, d`
56
+ namespace TestNamespace
57
+ {
58
+ ${csType}
59
+ }
60
+ `);
61
+ });
62
+ });
63
+ it("maps array to c# array", async () => {
64
+ const type = await compileType("int32[]");
65
+ const res = render(_$createComponent(Wrapper, {
66
+ get children() {
67
+ return _$createComponent(TypeExpression, {
68
+ type: type
69
+ });
70
+ }
71
+ }));
72
+ assertFileContents(res, d`
73
+ namespace TestNamespace
74
+ {
75
+ int[]
76
+ }
77
+ `);
78
+ });
79
+ describe("Record map to IDictionary", () => {
80
+ it("for primitive types", async () => {
81
+ const type = await compileType("Record<int32>");
82
+ const res = render(_$createComponent(Wrapper, {
83
+ get children() {
84
+ return _$createComponent(TypeExpression, {
85
+ type: type
86
+ });
87
+ }
88
+ }));
89
+ assertFileContents(res, d`
90
+ namespace TestNamespace
91
+ {
92
+ IDictionary<string, int>
93
+ }
94
+ `);
95
+ });
96
+ it("for models", async () => {
97
+ const {
98
+ test,
99
+ Pet
100
+ } = await runner.compile(`
101
+ model Test {
102
+ @test test: Record<Pet>;
103
+ }
104
+ @test model Pet {}
105
+ `);
106
+ const res = render(_$createComponent(Wrapper, {
107
+ get children() {
108
+ return [_$createComponent(ClassDeclaration, {
109
+ type: Pet
110
+ }), _$createIntrinsic("hbr", {}), _$createComponent(TypeExpression, {
111
+ get type() {
112
+ return test.type;
113
+ }
114
+ })];
115
+ }
116
+ }));
117
+ assertFileContents(res, d`
118
+ namespace TestNamespace
119
+ {
120
+ class Pet
121
+ {
122
+
123
+ }
124
+ IDictionary<string, Pet>
125
+ }
126
+ `);
127
+ });
128
+ });
@@ -0,0 +1,14 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import { Type } from "@typespec/compiler";
3
+ import { Typekit } from "@typespec/compiler/typekit";
4
+ /**
5
+ * Helper to render a doc string for a given TypeSpec type.
6
+ *
7
+ * This is not a JSX component as it needs to return undefined if there is no doc.
8
+ *
9
+ * @param $ The Typekit instance
10
+ * @param type The TypeSpec type to generate documentation for
11
+ * @returns A DocSummary component containing the rendered doc string, or undefined if no doc is available.
12
+ */
13
+ export declare function getDocComments($: Typekit, type: Type): ay.Children;
14
+ //# sourceMappingURL=doc-comments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doc-comments.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/utils/doc-comments.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAiB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,QAAQ,CA2ClE"}
@@ -0,0 +1,67 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as ay from "@alloy-js/core";
3
+ import * as cs from "@alloy-js/csharp";
4
+ import { getReturnsDoc } from "@typespec/compiler";
5
+ /**
6
+ * Helper to render a doc string for a given TypeSpec type.
7
+ *
8
+ * This is not a JSX component as it needs to return undefined if there is no doc.
9
+ *
10
+ * @param $ The Typekit instance
11
+ * @param type The TypeSpec type to generate documentation for
12
+ * @returns A DocSummary component containing the rendered doc string, or undefined if no doc is available.
13
+ */
14
+ export function getDocComments($, type) {
15
+ const typeDoc = $.type.getDoc(type);
16
+ if (!typeDoc) {
17
+ return undefined;
18
+ }
19
+ const docElements = [];
20
+
21
+ // Add main type documentation
22
+ docElements.push(_$createComponent(cs.DocSummary, {
23
+ get children() {
24
+ return _$createComponent(cs.DocFromMarkdown, {
25
+ markdown: typeDoc
26
+ });
27
+ }
28
+ }));
29
+
30
+ // Add operation-specific documentation if applicable
31
+ if ($.operation.is(type)) {
32
+ // Add parameter documentation
33
+ const paramDocs = [];
34
+ for (const param of type.parameters.properties.values()) {
35
+ const paramDoc = $.type.getDoc(param);
36
+ if (paramDoc) {
37
+ paramDocs.push(_$createComponent(cs.DocParam, {
38
+ get name() {
39
+ return param.name;
40
+ },
41
+ get children() {
42
+ return _$createComponent(cs.DocFromMarkdown, {
43
+ markdown: paramDoc
44
+ });
45
+ }
46
+ }));
47
+ }
48
+ }
49
+ docElements.push(...paramDocs);
50
+
51
+ // Add return documentation
52
+ const returnDoc = getReturnsDoc($.program, type);
53
+ if (returnDoc) {
54
+ docElements.push(_$createComponent(cs.DocReturns, {
55
+ get children() {
56
+ return _$createComponent(cs.DocFromMarkdown, {
57
+ markdown: returnDoc
58
+ });
59
+ }
60
+ }));
61
+ }
62
+ }
63
+ return _$createComponent(ay.List, {
64
+ doubleHardline: true,
65
+ children: docElements
66
+ });
67
+ }
@@ -13,5 +13,5 @@ export interface ArrowFunctionProps extends ts.ArrowFunctionProps {
13
13
  * function by converting from a TypeSpec Operation. Any other props provided
14
14
  * will take precedence.
15
15
  */
16
- export declare function ArrowFunction(props: Readonly<ArrowFunctionProps>): import("@alloy-js/core/jsx-runtime").Children;
16
+ export declare function ArrowFunction(props: Readonly<ArrowFunctionProps>): import("@alloy-js/core").Children;
17
17
  //# sourceMappingURL=arrow-function.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"arrow-function.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/arrow-function.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,kBAAkB;IAC/D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC,iDAkBhE"}
1
+ {"version":3,"file":"arrow-function.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/arrow-function.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,kBAAmB,SAAQ,EAAE,CAAC,kBAAkB;IAC/D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,kBAAkB,CAAC,qCAkBhE"}
@@ -1,4 +1,5 @@
1
- import { splitProps, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { splitProps } from "@alloy-js/core";
2
3
  import * as ts from "@alloy-js/typescript";
3
4
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
4
5
  import { TypeExpression } from "./type-expression.js";
@@ -13,5 +13,5 @@ export interface FunctionExpressionProps extends ts.FunctionExpressionProps {
13
13
  * function expression by converting from a TypeSpec Operation. Any other props
14
14
  * provided will take precedence.
15
15
  */
16
- export declare function FunctionExpression(props: Readonly<FunctionExpressionProps>): import("@alloy-js/core/jsx-runtime").Children;
16
+ export declare function FunctionExpression(props: Readonly<FunctionExpressionProps>): import("@alloy-js/core").Children;
17
17
  //# sourceMappingURL=function-expression.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"function-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,uBAAwB,SAAQ,EAAE,CAAC,uBAAuB;IACzE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,iDAoB1E"}
1
+ {"version":3,"file":"function-expression.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,uBAAwB,SAAQ,EAAE,CAAC,uBAAuB;IACzE,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,qCAoB1E"}
@@ -1,4 +1,5 @@
1
- import { splitProps, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { splitProps } from "@alloy-js/core";
2
3
  import * as ts from "@alloy-js/typescript";
3
4
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
4
5
  import { TypeExpression } from "./type-expression.js";
@@ -13,5 +13,5 @@ export interface FunctionTypeProps extends ts.FunctionTypeProps {
13
13
  * by converting from a TypeSpec Operation. Any other props provided will take
14
14
  * precedence.
15
15
  */
16
- export declare function FunctionType(props: Readonly<FunctionTypeProps>): import("@alloy-js/core/jsx-runtime").Children;
16
+ export declare function FunctionType(props: Readonly<FunctionTypeProps>): import("@alloy-js/core").Children;
17
17
  //# sourceMappingURL=function-type.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"function-type.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-type.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,iBAAkB,SAAQ,EAAE,CAAC,iBAAiB;IAC7D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AACD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,iDAkB9D"}
1
+ {"version":3,"file":"function-type.d.ts","sourceRoot":"","sources":["../../../../src/typescript/components/function-type.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,MAAM,WAAW,iBAAkB,SAAQ,EAAE,CAAC,iBAAiB;IAC7D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;CACnD;AACD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,qCAkB9D"}
@@ -1,4 +1,5 @@
1
- import { splitProps, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { splitProps } from "@alloy-js/core";
2
3
  import * as ts from "@alloy-js/typescript";
3
4
  import { buildParameterDescriptors, getReturnType } from "../utils/operation.js";
4
5
  import { TypeExpression } from "./type-expression.js";
@@ -45,7 +45,7 @@ it("renders a basic enum declaration", async () => {
45
45
  assertFileContents(res, d`
46
46
  namespace TestNamespace
47
47
  {
48
- public enum TestEnum
48
+ enum TestEnum
49
49
  {
50
50
  Value1,
51
51
  Value2,
@@ -83,7 +83,7 @@ it("renders an empty enum declaration", async () => {
83
83
  assertFileContents(res, d`
84
84
  namespace TestNamespace
85
85
  {
86
- public enum TestEnum
86
+ enum TestEnum
87
87
  {
88
88
 
89
89
  }
@@ -123,7 +123,7 @@ it("can override enum name", async () => {
123
123
  assertFileContents(res, d`
124
124
  namespace TestNamespace
125
125
  {
126
- public enum CustomEnumName
126
+ enum CustomEnumName
127
127
  {
128
128
  Value1,
129
129
  Value2
@@ -153,7 +153,7 @@ it("renders an enum with access modifiers", async () => {
153
153
  get children() {
154
154
  return _$createComponent(EnumDeclaration, {
155
155
  type: TestEnum,
156
- accessModifier: "internal"
156
+ internal: true
157
157
  });
158
158
  }
159
159
  });
@@ -208,7 +208,7 @@ it("renders enum with C# naming conventions", async () => {
208
208
  assertFileContents(res, d`
209
209
  namespace TestNamespace
210
210
  {
211
- public enum TestEnum
211
+ enum TestEnum
212
212
  {
213
213
  ValueOne,
214
214
  ValueTwo,
@@ -248,7 +248,7 @@ it("renders enum with single value", async () => {
248
248
  assertFileContents(res, d`
249
249
  namespace TestNamespace
250
250
  {
251
- public enum TestEnum
251
+ enum TestEnum
252
252
  {
253
253
  OnlyValue
254
254
  }
@@ -289,7 +289,7 @@ it("renders enum with numeric-like member names", async () => {
289
289
  assertFileContents(res, d`
290
290
  namespace TestNamespace
291
291
  {
292
- public enum TestEnum
292
+ enum TestEnum
293
293
  {
294
294
  Value0,
295
295
  Value1,
@@ -339,12 +339,12 @@ it("renders multiple enums in the same namespace", async () => {
339
339
  assertFileContents(res, d`
340
340
  namespace TestNamespace
341
341
  {
342
- public enum TestEnum1
342
+ enum TestEnum1
343
343
  {
344
344
  Value1,
345
345
  Value2
346
346
  }
347
- public enum TestEnum2
347
+ enum TestEnum2
348
348
  {
349
349
  OptionA,
350
350
  OptionB,
@@ -352,4 +352,52 @@ it("renders multiple enums in the same namespace", async () => {
352
352
  }
353
353
  }
354
354
  `);
355
+ });
356
+ it("renders an enum with doc comments", async () => {
357
+ const {
358
+ TestEnum
359
+ } = await runner.compile(`
360
+ @test enum TestEnum {
361
+ @doc("This is value one")
362
+ Value1;
363
+ /** This is value two */
364
+ Value2;
365
+ }
366
+ `);
367
+ const res = render(_$createComponent(Output, {
368
+ get program() {
369
+ return runner.program;
370
+ },
371
+ get children() {
372
+ return _$createComponent(Namespace, {
373
+ name: "TestNamespace",
374
+ get children() {
375
+ return _$createComponent(SourceFile, {
376
+ path: "test.cs",
377
+ get children() {
378
+ return _$createComponent(EnumDeclaration, {
379
+ type: TestEnum
380
+ });
381
+ }
382
+ });
383
+ }
384
+ });
385
+ }
386
+ }));
387
+ assertFileContents(res, d`
388
+ namespace TestNamespace
389
+ {
390
+ enum TestEnum
391
+ {
392
+ /// <summary>
393
+ /// This is value one
394
+ /// </summary>
395
+ Value1,
396
+ /// <summary>
397
+ /// This is value two
398
+ /// </summary>
399
+ Value2
400
+ }
401
+ }
402
+ `);
355
403
  });
@@ -0,0 +1,2 @@
1
+ export declare const Tester: import("@typespec/compiler/testing").Tester;
2
+ //# sourceMappingURL=test-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-host.d.ts","sourceRoot":"","sources":["../../test/test-host.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,6CAA0E,CAAC"}