@typespec/emitter-framework 0.9.0-dev.6 → 0.9.0-dev.8
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.
- package/dist/src/core/components/output.d.ts +4 -4
- package/dist/src/core/components/output.d.ts.map +1 -1
- package/dist/src/core/components/output.js +3 -3
- package/dist/src/core/context/name-policy-context.d.ts +2 -2
- package/dist/src/core/context/name-policy-context.d.ts.map +1 -1
- package/dist/src/core/context/tsp-context.d.ts +2 -2
- package/dist/src/core/context/tsp-context.d.ts.map +1 -1
- package/dist/src/core/transport-name-policy.d.ts +1 -1
- package/dist/src/core/transport-name-policy.d.ts.map +1 -1
- package/dist/src/core/write-output.d.ts +2 -2
- package/dist/src/core/write-output.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.d.ts +3 -3
- package/dist/src/csharp/components/class/declaration.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.js +2 -2
- package/dist/src/csharp/components/class/declaration.test.js +100 -115
- package/dist/src/csharp/components/{enum-declaration.d.ts → enum/declaration.d.ts} +4 -4
- package/dist/src/csharp/components/enum/declaration.d.ts.map +1 -0
- package/dist/src/csharp/components/{enum-declaration.js → enum/declaration.js} +6 -6
- package/dist/src/csharp/components/enum/declaration.test.d.ts +2 -0
- package/dist/src/csharp/components/enum/declaration.test.d.ts.map +1 -0
- package/dist/src/csharp/components/enum/declaration.test.js +309 -0
- package/dist/src/csharp/components/index.d.ts +1 -1
- package/dist/src/csharp/components/index.js +1 -1
- package/dist/src/csharp/components/property/property.d.ts +2 -2
- package/dist/src/csharp/components/property/property.d.ts.map +1 -1
- package/dist/src/csharp/components/property/property.test.js +14 -14
- package/dist/src/csharp/components/type-expression.d.ts +3 -3
- package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
- package/dist/src/csharp/components/utils/doc-comments.d.ts +4 -4
- package/dist/src/csharp/components/utils/doc-comments.d.ts.map +1 -1
- package/dist/src/csharp/components/utils/doc-comments.js +2 -2
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/harness.d.ts +2 -2
- package/dist/src/testing/scenario-test/harness.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/test-host.d.ts +2 -2
- package/dist/src/testing/scenario-test/test-host.d.ts.map +1 -1
- package/dist/src/typescript/components/array-expression.d.ts +2 -3
- package/dist/src/typescript/components/array-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/array-expression.js +2 -2
- package/dist/src/typescript/components/arrow-function.d.ts +1 -1
- package/dist/src/typescript/components/arrow-function.d.ts.map +1 -1
- package/dist/src/typescript/components/class-method.d.ts +1 -1
- package/dist/src/typescript/components/class-method.d.ts.map +1 -1
- package/dist/src/typescript/components/enum-declaration.d.ts +6 -6
- package/dist/src/typescript/components/enum-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/enum-declaration.js +2 -2
- package/dist/src/typescript/components/function-declaration.d.ts +1 -1
- package/dist/src/typescript/components/function-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/function-expression.d.ts +1 -1
- package/dist/src/typescript/components/function-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/function-type.d.ts +1 -1
- package/dist/src/typescript/components/function-type.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-declaration.d.ts +4 -4
- package/dist/src/typescript/components/interface-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-declaration.js +3 -4
- package/dist/src/typescript/components/interface-member.d.ts +2 -2
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-method.d.ts +2 -2
- package/dist/src/typescript/components/interface-method.d.ts.map +1 -1
- package/dist/src/typescript/components/record-expression.d.ts +1 -1
- package/dist/src/typescript/components/record-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-alias-declaration.d.ts +1 -1
- package/dist/src/typescript/components/type-alias-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-expression.d.ts +1 -1
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-transform.d.ts +2 -2
- package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
- package/dist/src/typescript/components/union-declaration.d.ts +2 -2
- package/dist/src/typescript/components/union-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/union-expression.d.ts +3 -4
- package/dist/src/typescript/components/union-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/union-expression.js +3 -3
- package/dist/src/typescript/components/value-expression.d.ts +2 -2
- package/dist/src/typescript/components/value-expression.d.ts.map +1 -1
- package/dist/src/typescript/utils/operation.d.ts +2 -2
- package/dist/src/typescript/utils/operation.d.ts.map +1 -1
- package/dist/test/typescript/components/member-expression.test.js +5 -5
- package/dist/test/typescript/test-host.d.ts +1 -1
- package/dist/test/typescript/test-host.d.ts.map +1 -1
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/core/components/output.tsx +9 -5
- package/src/core/context/name-policy-context.ts +2 -2
- package/src/core/context/tsp-context.ts +2 -2
- package/src/core/transport-name-policy.ts +1 -1
- package/src/core/write-output.ts +2 -2
- package/src/csharp/components/class/declaration.test.tsx +107 -169
- package/src/csharp/components/class/declaration.tsx +8 -8
- package/src/csharp/components/enum/declaration.test.tsx +267 -0
- package/src/csharp/components/{enum-declaration.tsx → enum/declaration.tsx} +9 -9
- package/src/csharp/components/index.ts +1 -1
- package/src/csharp/components/property/property.test.tsx +16 -16
- package/src/csharp/components/property/property.tsx +2 -2
- package/src/csharp/components/type-expression.test.tsx +3 -3
- package/src/csharp/components/type-expression.tsx +3 -3
- package/src/csharp/components/utils/doc-comments.tsx +6 -6
- package/src/testing/index.ts +1 -1
- package/src/testing/scenario-test/harness.ts +2 -2
- package/src/testing/scenario-test/test-host.ts +4 -4
- package/src/typescript/components/array-expression.tsx +3 -3
- package/src/typescript/components/arrow-function.tsx +1 -1
- package/src/typescript/components/class-method.tsx +1 -1
- package/src/typescript/components/enum-declaration.tsx +6 -6
- package/src/typescript/components/function-declaration.tsx +1 -1
- package/src/typescript/components/function-expression.tsx +1 -1
- package/src/typescript/components/function-type.tsx +1 -1
- package/src/typescript/components/interface-declaration.tsx +11 -12
- package/src/typescript/components/interface-member.tsx +2 -2
- package/src/typescript/components/interface-method.tsx +2 -2
- package/src/typescript/components/record-expression.tsx +1 -1
- package/src/typescript/components/type-alias-declaration.tsx +1 -1
- package/src/typescript/components/type-declaration.tsx +1 -1
- package/src/typescript/components/type-expression.tsx +2 -2
- package/src/typescript/components/type-transform.tsx +3 -3
- package/src/typescript/components/union-declaration.tsx +2 -2
- package/src/typescript/components/union-expression.tsx +12 -7
- package/src/typescript/components/value-expression.tsx +2 -2
- package/src/typescript/utils/operation.ts +2 -2
- package/test/testing/snippet-extractor-csharp.test.ts +1 -1
- package/test/testing/snippet-extractor-java.test.ts +1 -1
- package/test/testing/snippet-extractor-python.test.ts +1 -1
- package/test/testing/snippet-extractor-typescript.test.ts +1 -1
- package/test/typescript/components/arrow-function.test.tsx +2 -2
- package/test/typescript/components/enum-declaration.test.tsx +1 -1
- package/test/typescript/components/function-declaration.test.tsx +1 -1
- package/test/typescript/components/function-expression.test.tsx +2 -2
- package/test/typescript/components/function-type.test.tsx +2 -2
- package/test/typescript/components/interface-declaration.test.tsx +1 -1
- package/test/typescript/components/interface-method.test.tsx +2 -2
- package/test/typescript/components/member-expression.test.tsx +10 -10
- package/test/typescript/components/type-alias-declaration.test.tsx +1 -1
- package/test/typescript/components/type-transform.test.tsx +2 -2
- package/test/typescript/components/union-declaration.test.tsx +2 -2
- package/test/typescript/components/value-expression.test.tsx +6 -6
- package/test/typescript/test-host.ts +1 -1
- package/test/utils.ts +2 -2
- package/tsconfig.json +1 -0
- package/dist/src/csharp/components/enum-declaration.d.ts.map +0 -1
- package/dist/test/csharp/components/enum-declaration.test.d.ts +0 -2
- package/dist/test/csharp/components/enum-declaration.test.d.ts.map +0 -1
- package/dist/test/csharp/components/enum-declaration.test.js +0 -403
- package/dist/test/csharp/test-host.d.ts +0 -11
- package/dist/test/csharp/test-host.d.ts.map +0 -1
- package/dist/test/csharp/test-host.js +0 -32
- package/dist/test/csharp/utils.d.ts +0 -3
- package/dist/test/csharp/utils.d.ts.map +0 -1
- package/dist/test/csharp/utils.js +0 -6
- package/test/csharp/components/enum-declaration.test.tsx +0 -337
- package/test/csharp/test-host.ts +0 -42
- package/test/csharp/utils.ts +0 -8
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { render } from "@alloy-js/core";
|
|
2
|
-
import { d } from "@alloy-js/core/testing";
|
|
3
|
-
import * as cs from "@alloy-js/csharp";
|
|
4
|
-
import { Namespace, SourceFile } from "@alloy-js/csharp";
|
|
5
|
-
import { Enum } from "@typespec/compiler";
|
|
6
|
-
import { BasicTestRunner } from "@typespec/compiler/testing";
|
|
7
|
-
import { beforeEach, it } from "vitest";
|
|
8
|
-
import { Output } from "../../../src/core/index.js";
|
|
9
|
-
import { EnumDeclaration } from "../../../src/csharp/index.js";
|
|
10
|
-
import { createEmitterFrameworkTestRunner } from "../test-host.js";
|
|
11
|
-
import { assertFileContents } from "../utils.js";
|
|
12
|
-
|
|
13
|
-
let runner: BasicTestRunner;
|
|
14
|
-
|
|
15
|
-
beforeEach(async () => {
|
|
16
|
-
runner = await createEmitterFrameworkTestRunner();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("renders a basic enum declaration", async () => {
|
|
20
|
-
const { TestEnum } = (await runner.compile(`
|
|
21
|
-
@test enum TestEnum {
|
|
22
|
-
Value1;
|
|
23
|
-
Value2;
|
|
24
|
-
Value3;
|
|
25
|
-
}
|
|
26
|
-
`)) as { TestEnum: Enum };
|
|
27
|
-
|
|
28
|
-
const res = render(
|
|
29
|
-
<Output program={runner.program}>
|
|
30
|
-
<Namespace name="TestNamespace">
|
|
31
|
-
<SourceFile path="test.cs">
|
|
32
|
-
<EnumDeclaration type={TestEnum} />
|
|
33
|
-
</SourceFile>
|
|
34
|
-
</Namespace>
|
|
35
|
-
</Output>,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
assertFileContents(
|
|
39
|
-
res,
|
|
40
|
-
d`
|
|
41
|
-
namespace TestNamespace
|
|
42
|
-
{
|
|
43
|
-
enum TestEnum
|
|
44
|
-
{
|
|
45
|
-
Value1,
|
|
46
|
-
Value2,
|
|
47
|
-
Value3
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`,
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("renders an empty enum declaration", async () => {
|
|
55
|
-
const { TestEnum } = (await runner.compile(`
|
|
56
|
-
@test enum TestEnum {}
|
|
57
|
-
`)) as { TestEnum: Enum };
|
|
58
|
-
|
|
59
|
-
const res = render(
|
|
60
|
-
<Output program={runner.program}>
|
|
61
|
-
<Namespace name="TestNamespace">
|
|
62
|
-
<SourceFile path="test.cs">
|
|
63
|
-
<EnumDeclaration type={TestEnum} />
|
|
64
|
-
</SourceFile>
|
|
65
|
-
</Namespace>
|
|
66
|
-
</Output>,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
assertFileContents(
|
|
70
|
-
res,
|
|
71
|
-
d`
|
|
72
|
-
namespace TestNamespace
|
|
73
|
-
{
|
|
74
|
-
enum TestEnum
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
`,
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("can override enum name", async () => {
|
|
84
|
-
const { TestEnum } = (await runner.compile(`
|
|
85
|
-
@test enum TestEnum {
|
|
86
|
-
Value1;
|
|
87
|
-
Value2;
|
|
88
|
-
}
|
|
89
|
-
`)) as { TestEnum: Enum };
|
|
90
|
-
|
|
91
|
-
const res = render(
|
|
92
|
-
<Output program={runner.program}>
|
|
93
|
-
<Namespace name="TestNamespace">
|
|
94
|
-
<SourceFile path="test.cs">
|
|
95
|
-
<EnumDeclaration type={TestEnum} name="CustomEnumName" />
|
|
96
|
-
</SourceFile>
|
|
97
|
-
</Namespace>
|
|
98
|
-
</Output>,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
assertFileContents(
|
|
102
|
-
res,
|
|
103
|
-
d`
|
|
104
|
-
namespace TestNamespace
|
|
105
|
-
{
|
|
106
|
-
enum CustomEnumName
|
|
107
|
-
{
|
|
108
|
-
Value1,
|
|
109
|
-
Value2
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
`,
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("renders an enum with access modifiers", async () => {
|
|
117
|
-
const { TestEnum } = (await runner.compile(`
|
|
118
|
-
@test enum TestEnum {
|
|
119
|
-
Value1;
|
|
120
|
-
Value2;
|
|
121
|
-
}
|
|
122
|
-
`)) as { TestEnum: Enum };
|
|
123
|
-
|
|
124
|
-
const res = render(
|
|
125
|
-
<Output program={runner.program}>
|
|
126
|
-
<Namespace name="TestNamespace">
|
|
127
|
-
<SourceFile path="test.cs">
|
|
128
|
-
<EnumDeclaration type={TestEnum} internal />
|
|
129
|
-
</SourceFile>
|
|
130
|
-
</Namespace>
|
|
131
|
-
</Output>,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
assertFileContents(
|
|
135
|
-
res,
|
|
136
|
-
d`
|
|
137
|
-
namespace TestNamespace
|
|
138
|
-
{
|
|
139
|
-
internal enum TestEnum
|
|
140
|
-
{
|
|
141
|
-
Value1,
|
|
142
|
-
Value2
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
`,
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("renders enum with C# naming conventions", async () => {
|
|
150
|
-
const { TestEnum } = (await runner.compile(`
|
|
151
|
-
@test enum TestEnum {
|
|
152
|
-
value_one;
|
|
153
|
-
value_two;
|
|
154
|
-
value_three;
|
|
155
|
-
}
|
|
156
|
-
`)) as { TestEnum: Enum };
|
|
157
|
-
|
|
158
|
-
const res = render(
|
|
159
|
-
<Output program={runner.program} namePolicy={cs.createCSharpNamePolicy()}>
|
|
160
|
-
<Namespace name="TestNamespace">
|
|
161
|
-
<SourceFile path="test.cs">
|
|
162
|
-
<EnumDeclaration type={TestEnum} />
|
|
163
|
-
</SourceFile>
|
|
164
|
-
</Namespace>
|
|
165
|
-
</Output>,
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
assertFileContents(
|
|
169
|
-
res,
|
|
170
|
-
d`
|
|
171
|
-
namespace TestNamespace
|
|
172
|
-
{
|
|
173
|
-
enum TestEnum
|
|
174
|
-
{
|
|
175
|
-
ValueOne,
|
|
176
|
-
ValueTwo,
|
|
177
|
-
ValueThree
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
`,
|
|
181
|
-
);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("renders enum with single value", async () => {
|
|
185
|
-
const { TestEnum } = (await runner.compile(`
|
|
186
|
-
@test enum TestEnum {
|
|
187
|
-
OnlyValue;
|
|
188
|
-
}
|
|
189
|
-
`)) as { TestEnum: Enum };
|
|
190
|
-
|
|
191
|
-
const res = render(
|
|
192
|
-
<Output program={runner.program}>
|
|
193
|
-
<Namespace name="TestNamespace">
|
|
194
|
-
<SourceFile path="test.cs">
|
|
195
|
-
<EnumDeclaration type={TestEnum} />
|
|
196
|
-
</SourceFile>
|
|
197
|
-
</Namespace>
|
|
198
|
-
</Output>,
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
assertFileContents(
|
|
202
|
-
res,
|
|
203
|
-
d`
|
|
204
|
-
namespace TestNamespace
|
|
205
|
-
{
|
|
206
|
-
enum TestEnum
|
|
207
|
-
{
|
|
208
|
-
OnlyValue
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
`,
|
|
212
|
-
);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("renders enum with numeric-like member names", async () => {
|
|
216
|
-
const { TestEnum } = (await runner.compile(`
|
|
217
|
-
@test enum TestEnum {
|
|
218
|
-
Value0;
|
|
219
|
-
Value1;
|
|
220
|
-
Value10;
|
|
221
|
-
Value100;
|
|
222
|
-
}
|
|
223
|
-
`)) as { TestEnum: Enum };
|
|
224
|
-
|
|
225
|
-
const res = render(
|
|
226
|
-
<Output program={runner.program}>
|
|
227
|
-
<Namespace name="TestNamespace">
|
|
228
|
-
<SourceFile path="test.cs">
|
|
229
|
-
<EnumDeclaration type={TestEnum} />
|
|
230
|
-
</SourceFile>
|
|
231
|
-
</Namespace>
|
|
232
|
-
</Output>,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
assertFileContents(
|
|
236
|
-
res,
|
|
237
|
-
d`
|
|
238
|
-
namespace TestNamespace
|
|
239
|
-
{
|
|
240
|
-
enum TestEnum
|
|
241
|
-
{
|
|
242
|
-
Value0,
|
|
243
|
-
Value1,
|
|
244
|
-
Value10,
|
|
245
|
-
Value100
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
`,
|
|
249
|
-
);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it("renders multiple enums in the same namespace", async () => {
|
|
253
|
-
const { TestEnum1, TestEnum2 } = (await runner.compile(`
|
|
254
|
-
@test enum TestEnum1 {
|
|
255
|
-
Value1;
|
|
256
|
-
Value2;
|
|
257
|
-
}
|
|
258
|
-
@test enum TestEnum2 {
|
|
259
|
-
OptionA;
|
|
260
|
-
OptionB;
|
|
261
|
-
OptionC;
|
|
262
|
-
}
|
|
263
|
-
`)) as { TestEnum1: Enum; TestEnum2: Enum };
|
|
264
|
-
|
|
265
|
-
const res = render(
|
|
266
|
-
<Output program={runner.program}>
|
|
267
|
-
<Namespace name="TestNamespace">
|
|
268
|
-
<SourceFile path="test.cs">
|
|
269
|
-
<EnumDeclaration type={TestEnum1} />
|
|
270
|
-
<hbr />
|
|
271
|
-
<EnumDeclaration type={TestEnum2} />
|
|
272
|
-
</SourceFile>
|
|
273
|
-
</Namespace>
|
|
274
|
-
</Output>,
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
assertFileContents(
|
|
278
|
-
res,
|
|
279
|
-
d`
|
|
280
|
-
namespace TestNamespace
|
|
281
|
-
{
|
|
282
|
-
enum TestEnum1
|
|
283
|
-
{
|
|
284
|
-
Value1,
|
|
285
|
-
Value2
|
|
286
|
-
}
|
|
287
|
-
enum TestEnum2
|
|
288
|
-
{
|
|
289
|
-
OptionA,
|
|
290
|
-
OptionB,
|
|
291
|
-
OptionC
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
`,
|
|
295
|
-
);
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it("renders an enum with doc comments", async () => {
|
|
299
|
-
const { TestEnum } = (await runner.compile(`
|
|
300
|
-
@test enum TestEnum {
|
|
301
|
-
@doc("This is value one")
|
|
302
|
-
Value1;
|
|
303
|
-
/** This is value two */
|
|
304
|
-
Value2;
|
|
305
|
-
}
|
|
306
|
-
`)) as { TestEnum: Enum };
|
|
307
|
-
|
|
308
|
-
const res = render(
|
|
309
|
-
<Output program={runner.program}>
|
|
310
|
-
<Namespace name="TestNamespace">
|
|
311
|
-
<SourceFile path="test.cs">
|
|
312
|
-
<EnumDeclaration type={TestEnum} />
|
|
313
|
-
</SourceFile>
|
|
314
|
-
</Namespace>
|
|
315
|
-
</Output>,
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
assertFileContents(
|
|
319
|
-
res,
|
|
320
|
-
d`
|
|
321
|
-
namespace TestNamespace
|
|
322
|
-
{
|
|
323
|
-
enum TestEnum
|
|
324
|
-
{
|
|
325
|
-
/// <summary>
|
|
326
|
-
/// This is value one
|
|
327
|
-
/// </summary>
|
|
328
|
-
Value1,
|
|
329
|
-
/// <summary>
|
|
330
|
-
/// This is value two
|
|
331
|
-
/// </summary>
|
|
332
|
-
Value2
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
`,
|
|
336
|
-
);
|
|
337
|
-
});
|
package/test/csharp/test-host.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Program } from "@typespec/compiler";
|
|
2
|
-
import {
|
|
3
|
-
createTestHost,
|
|
4
|
-
createTestWrapper,
|
|
5
|
-
expectDiagnosticEmpty,
|
|
6
|
-
TypeSpecTestLibrary,
|
|
7
|
-
} from "@typespec/compiler/testing";
|
|
8
|
-
import { HttpTestLibrary } from "@typespec/http/testing";
|
|
9
|
-
|
|
10
|
-
export async function createTypespecCliTestHost(
|
|
11
|
-
options: { libraries: "Http"[] } = { libraries: [] },
|
|
12
|
-
) {
|
|
13
|
-
const libraries: TypeSpecTestLibrary[] = [];
|
|
14
|
-
if (options.libraries.includes("Http")) {
|
|
15
|
-
libraries.push(HttpTestLibrary);
|
|
16
|
-
}
|
|
17
|
-
return createTestHost({
|
|
18
|
-
libraries,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function createEmitterFrameworkTestRunner(options: { autoUsings?: string[] } = {}) {
|
|
23
|
-
const host = await createTypespecCliTestHost();
|
|
24
|
-
return createTestWrapper(host, {
|
|
25
|
-
autoUsings: options.autoUsings,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function getProgram(
|
|
30
|
-
code: string,
|
|
31
|
-
options: { libraries: "Http"[] } = { libraries: [] },
|
|
32
|
-
): Promise<Program> {
|
|
33
|
-
const host = await createTypespecCliTestHost(options);
|
|
34
|
-
const wrapper = createTestWrapper(host, {
|
|
35
|
-
compilerOptions: {
|
|
36
|
-
noEmit: true,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
const [_, diagnostics] = await wrapper.compileAndDiagnose(code);
|
|
40
|
-
expectDiagnosticEmpty(diagnostics);
|
|
41
|
-
return wrapper.program;
|
|
42
|
-
}
|
package/test/csharp/utils.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OutputDirectory } from "@alloy-js/core";
|
|
2
|
-
import { assert } from "vitest";
|
|
3
|
-
|
|
4
|
-
export function assertFileContents(res: OutputDirectory, contents: string) {
|
|
5
|
-
const testFile = res.contents.find((file) => file.path === "test.cs")!;
|
|
6
|
-
assert(testFile, "test.cs file not rendered");
|
|
7
|
-
assert.equal(testFile.contents, contents);
|
|
8
|
-
}
|