@typespec/emitter-framework 0.9.0-dev.2 → 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.
- package/dist/src/csharp/components/class/declaration.d.ts +13 -0
- package/dist/src/csharp/components/class/declaration.d.ts.map +1 -0
- package/dist/src/csharp/components/{class-declaration.js → class/declaration.js} +35 -41
- package/dist/src/csharp/components/class/declaration.test.d.ts +2 -0
- package/dist/src/csharp/components/class/declaration.test.d.ts.map +1 -0
- package/dist/src/csharp/components/class/declaration.test.js +392 -0
- package/dist/src/csharp/components/enum-declaration.d.ts +1 -1
- package/dist/src/csharp/components/enum-declaration.d.ts.map +1 -1
- package/dist/src/csharp/components/enum-declaration.js +12 -9
- package/dist/src/csharp/components/index.d.ts +3 -1
- package/dist/src/csharp/components/index.d.ts.map +1 -1
- package/dist/src/csharp/components/index.js +4 -2
- package/dist/src/csharp/components/property/property.d.ts +15 -0
- package/dist/src/csharp/components/property/property.d.ts.map +1 -0
- package/dist/src/csharp/components/property/property.js +85 -0
- package/dist/src/csharp/components/property/property.test.d.ts +2 -0
- package/dist/src/csharp/components/property/property.test.d.ts.map +1 -0
- package/dist/src/csharp/components/property/property.test.js +117 -0
- package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
- package/dist/src/csharp/components/type-expression.js +15 -1
- package/dist/src/csharp/components/type-expression.test.d.ts +2 -0
- package/dist/src/csharp/components/type-expression.test.d.ts.map +1 -0
- package/dist/src/csharp/components/type-expression.test.js +128 -0
- package/dist/src/csharp/components/utils/doc-comments.d.ts +14 -0
- package/dist/src/csharp/components/utils/doc-comments.d.ts.map +1 -0
- package/dist/src/csharp/components/utils/doc-comments.js +67 -0
- 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/arrow-function.js +2 -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-expression.js +2 -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/function-type.js +2 -1
- package/dist/test/csharp/components/enum-declaration.test.js +57 -9
- package/dist/test/test-host.d.ts +2 -0
- package/dist/test/test-host.d.ts.map +1 -0
- package/dist/test/test-host.js +5 -0
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +1 -0
- package/package.json +13 -7
- package/src/csharp/components/class/declaration.test.tsx +401 -0
- package/src/csharp/components/class/declaration.tsx +86 -0
- package/src/csharp/components/enum-declaration.tsx +23 -15
- package/src/csharp/components/index.ts +3 -1
- package/src/csharp/components/property/property.test.tsx +97 -0
- package/src/csharp/components/property/property.tsx +62 -0
- package/src/csharp/components/type-expression.test.tsx +133 -0
- package/src/csharp/components/type-expression.tsx +10 -3
- package/src/csharp/components/utils/doc-comments.tsx +58 -0
- package/src/typescript/components/arrow-function.tsx +1 -1
- package/src/typescript/components/function-expression.tsx +1 -1
- package/src/typescript/components/function-type.tsx +1 -1
- package/test/csharp/components/enum-declaration.test.tsx +50 -9
- package/test/test-host.ts +4 -0
- package/test/vitest.setup.ts +1 -0
- package/tsconfig.json +2 -1
- package/vitest.config.ts +2 -1
- package/dist/src/csharp/components/class-declaration.d.ts +0 -9
- package/dist/src/csharp/components/class-declaration.d.ts.map +0 -1
- package/dist/test/csharp/components/class-declaration.test.d.ts +0 -2
- package/dist/test/csharp/components/class-declaration.test.d.ts.map +0 -1
- package/dist/test/csharp/components/class-declaration.test.js +0 -421
- package/src/csharp/components/class-declaration.tsx +0 -87
- package/test/csharp/components/class-declaration.test.tsx +0 -344
|
@@ -1,421 +0,0 @@
|
|
|
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 * as cs from "@alloy-js/csharp";
|
|
5
|
-
import { Namespace, SourceFile } from "@alloy-js/csharp";
|
|
6
|
-
import { beforeEach, describe, it } from "vitest";
|
|
7
|
-
import { Output } from "../../../src/core/index.js";
|
|
8
|
-
import { ClassDeclaration, EnumDeclaration } from "../../../src/csharp/index.js";
|
|
9
|
-
import { createEmitterFrameworkTestRunner } from "../test-host.js";
|
|
10
|
-
import { assertFileContents } from "../utils.js";
|
|
11
|
-
let runner;
|
|
12
|
-
beforeEach(async () => {
|
|
13
|
-
runner = await createEmitterFrameworkTestRunner();
|
|
14
|
-
});
|
|
15
|
-
it("renders an empty class declaration", async () => {
|
|
16
|
-
const {
|
|
17
|
-
TestModel
|
|
18
|
-
} = await runner.compile(`
|
|
19
|
-
@test model TestModel {}
|
|
20
|
-
`);
|
|
21
|
-
const res = render(_$createComponent(Output, {
|
|
22
|
-
get program() {
|
|
23
|
-
return runner.program;
|
|
24
|
-
},
|
|
25
|
-
get children() {
|
|
26
|
-
return _$createComponent(Namespace, {
|
|
27
|
-
name: "TestNamespace",
|
|
28
|
-
get children() {
|
|
29
|
-
return _$createComponent(SourceFile, {
|
|
30
|
-
path: "test.cs",
|
|
31
|
-
get children() {
|
|
32
|
-
return _$createComponent(ClassDeclaration, {
|
|
33
|
-
type: TestModel
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}));
|
|
41
|
-
assertFileContents(res, d`
|
|
42
|
-
namespace TestNamespace
|
|
43
|
-
{
|
|
44
|
-
class TestModel
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`);
|
|
50
|
-
});
|
|
51
|
-
it("renders a class declaration with properties", async () => {
|
|
52
|
-
const {
|
|
53
|
-
TestModel
|
|
54
|
-
} = await runner.compile(`
|
|
55
|
-
@test model TestModel {
|
|
56
|
-
@test Prop1: string;
|
|
57
|
-
@test Prop2: int32;
|
|
58
|
-
}
|
|
59
|
-
`);
|
|
60
|
-
const res = render(_$createComponent(Output, {
|
|
61
|
-
get program() {
|
|
62
|
-
return runner.program;
|
|
63
|
-
},
|
|
64
|
-
get children() {
|
|
65
|
-
return _$createComponent(Namespace, {
|
|
66
|
-
name: "TestNamespace",
|
|
67
|
-
get children() {
|
|
68
|
-
return _$createComponent(SourceFile, {
|
|
69
|
-
path: "test.cs",
|
|
70
|
-
get children() {
|
|
71
|
-
return _$createComponent(ClassDeclaration, {
|
|
72
|
-
type: TestModel
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
assertFileContents(res, d`
|
|
81
|
-
namespace TestNamespace
|
|
82
|
-
{
|
|
83
|
-
class TestModel
|
|
84
|
-
{
|
|
85
|
-
public string Prop1
|
|
86
|
-
{
|
|
87
|
-
get;
|
|
88
|
-
set;
|
|
89
|
-
}
|
|
90
|
-
public int Prop2
|
|
91
|
-
{
|
|
92
|
-
get;
|
|
93
|
-
set;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`);
|
|
98
|
-
});
|
|
99
|
-
it("can override class name", async () => {
|
|
100
|
-
const {
|
|
101
|
-
TestModel
|
|
102
|
-
} = await runner.compile(`
|
|
103
|
-
@test model TestModel {}
|
|
104
|
-
`);
|
|
105
|
-
const res = render(_$createComponent(Output, {
|
|
106
|
-
get program() {
|
|
107
|
-
return runner.program;
|
|
108
|
-
},
|
|
109
|
-
get children() {
|
|
110
|
-
return _$createComponent(Namespace, {
|
|
111
|
-
name: "TestNamespace",
|
|
112
|
-
get children() {
|
|
113
|
-
return _$createComponent(SourceFile, {
|
|
114
|
-
path: "test.cs",
|
|
115
|
-
get children() {
|
|
116
|
-
return _$createComponent(ClassDeclaration, {
|
|
117
|
-
type: TestModel,
|
|
118
|
-
name: "CustomClassName"
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}));
|
|
126
|
-
assertFileContents(res, d`
|
|
127
|
-
namespace TestNamespace
|
|
128
|
-
{
|
|
129
|
-
class CustomClassName
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
`);
|
|
135
|
-
});
|
|
136
|
-
it("renders a class with access modifiers", async () => {
|
|
137
|
-
const {
|
|
138
|
-
TestModel
|
|
139
|
-
} = await runner.compile(`
|
|
140
|
-
@test model TestModel {
|
|
141
|
-
}
|
|
142
|
-
`);
|
|
143
|
-
const res = render(_$createComponent(Output, {
|
|
144
|
-
get program() {
|
|
145
|
-
return runner.program;
|
|
146
|
-
},
|
|
147
|
-
get children() {
|
|
148
|
-
return _$createComponent(Namespace, {
|
|
149
|
-
name: "TestNamespace",
|
|
150
|
-
get children() {
|
|
151
|
-
return _$createComponent(SourceFile, {
|
|
152
|
-
path: "test.cs",
|
|
153
|
-
get children() {
|
|
154
|
-
return _$createComponent(ClassDeclaration, {
|
|
155
|
-
type: TestModel,
|
|
156
|
-
accessModifier: "protected"
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}));
|
|
164
|
-
assertFileContents(res, d`
|
|
165
|
-
namespace TestNamespace
|
|
166
|
-
{
|
|
167
|
-
protected class TestModel
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
`);
|
|
173
|
-
});
|
|
174
|
-
describe("from an interface", () => {
|
|
175
|
-
it("renders an empty class", async () => {
|
|
176
|
-
const {
|
|
177
|
-
TestInterface
|
|
178
|
-
} = await runner.compile(`
|
|
179
|
-
@test interface TestInterface {
|
|
180
|
-
}
|
|
181
|
-
`);
|
|
182
|
-
const res = render(_$createComponent(Output, {
|
|
183
|
-
get program() {
|
|
184
|
-
return runner.program;
|
|
185
|
-
},
|
|
186
|
-
get children() {
|
|
187
|
-
return _$createComponent(Namespace, {
|
|
188
|
-
name: "TestNamespace",
|
|
189
|
-
get children() {
|
|
190
|
-
return _$createComponent(SourceFile, {
|
|
191
|
-
path: "test.cs",
|
|
192
|
-
get children() {
|
|
193
|
-
return _$createComponent(ClassDeclaration, {
|
|
194
|
-
type: TestInterface
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}));
|
|
202
|
-
assertFileContents(res, d`
|
|
203
|
-
namespace TestNamespace
|
|
204
|
-
{
|
|
205
|
-
class TestInterface
|
|
206
|
-
{
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
`);
|
|
211
|
-
});
|
|
212
|
-
it("renders a class with operations", async () => {
|
|
213
|
-
const {
|
|
214
|
-
TestInterface
|
|
215
|
-
} = await runner.compile(`
|
|
216
|
-
@test interface TestInterface {
|
|
217
|
-
op getName(id: string): string;
|
|
218
|
-
}
|
|
219
|
-
`);
|
|
220
|
-
const res = render(_$createComponent(Output, {
|
|
221
|
-
get program() {
|
|
222
|
-
return runner.program;
|
|
223
|
-
},
|
|
224
|
-
get namePolicy() {
|
|
225
|
-
return cs.createCSharpNamePolicy();
|
|
226
|
-
},
|
|
227
|
-
get children() {
|
|
228
|
-
return _$createComponent(Namespace, {
|
|
229
|
-
name: "TestNamespace",
|
|
230
|
-
get children() {
|
|
231
|
-
return _$createComponent(SourceFile, {
|
|
232
|
-
path: "test.cs",
|
|
233
|
-
get children() {
|
|
234
|
-
return _$createComponent(ClassDeclaration, {
|
|
235
|
-
type: TestInterface
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}));
|
|
243
|
-
assertFileContents(res, d`
|
|
244
|
-
namespace TestNamespace
|
|
245
|
-
{
|
|
246
|
-
class TestInterface
|
|
247
|
-
{
|
|
248
|
-
public abstract string GetName(string id) {}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
`);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
it("renders a class with model members", async () => {
|
|
255
|
-
const {
|
|
256
|
-
TestModel,
|
|
257
|
-
TestReference
|
|
258
|
-
} = await runner.compile(`
|
|
259
|
-
@test model TestReference {
|
|
260
|
-
}
|
|
261
|
-
@test model TestModel {
|
|
262
|
-
@test prop1: TestReference;
|
|
263
|
-
}
|
|
264
|
-
`);
|
|
265
|
-
const res = render(_$createComponent(Output, {
|
|
266
|
-
get program() {
|
|
267
|
-
return runner.program;
|
|
268
|
-
},
|
|
269
|
-
get namePolicy() {
|
|
270
|
-
return cs.createCSharpNamePolicy();
|
|
271
|
-
},
|
|
272
|
-
get children() {
|
|
273
|
-
return _$createComponent(Namespace, {
|
|
274
|
-
name: "TestNamespace",
|
|
275
|
-
get children() {
|
|
276
|
-
return _$createComponent(SourceFile, {
|
|
277
|
-
path: "test.cs",
|
|
278
|
-
get children() {
|
|
279
|
-
return [_$createComponent(ClassDeclaration, {
|
|
280
|
-
type: TestReference
|
|
281
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(ClassDeclaration, {
|
|
282
|
-
type: TestModel
|
|
283
|
-
})];
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
}));
|
|
290
|
-
assertFileContents(res, d`
|
|
291
|
-
namespace TestNamespace
|
|
292
|
-
{
|
|
293
|
-
class TestReference
|
|
294
|
-
{
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
class TestModel
|
|
298
|
-
{
|
|
299
|
-
public TestReference Prop1
|
|
300
|
-
{
|
|
301
|
-
get;
|
|
302
|
-
set;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
`);
|
|
307
|
-
});
|
|
308
|
-
it("renders a class with enum members", async () => {
|
|
309
|
-
const {
|
|
310
|
-
TestModel,
|
|
311
|
-
TestEnum
|
|
312
|
-
} = await runner.compile(`
|
|
313
|
-
@test enum TestEnum {
|
|
314
|
-
Value1;
|
|
315
|
-
Value2;
|
|
316
|
-
}
|
|
317
|
-
@test model TestModel {
|
|
318
|
-
@test prop1: TestEnum;
|
|
319
|
-
}
|
|
320
|
-
`);
|
|
321
|
-
const res = render(_$createComponent(Output, {
|
|
322
|
-
get program() {
|
|
323
|
-
return runner.program;
|
|
324
|
-
},
|
|
325
|
-
get namePolicy() {
|
|
326
|
-
return cs.createCSharpNamePolicy();
|
|
327
|
-
},
|
|
328
|
-
get children() {
|
|
329
|
-
return _$createComponent(Namespace, {
|
|
330
|
-
name: "TestNamespace",
|
|
331
|
-
get children() {
|
|
332
|
-
return _$createComponent(SourceFile, {
|
|
333
|
-
path: "test.cs",
|
|
334
|
-
get children() {
|
|
335
|
-
return [_$createComponent(EnumDeclaration, {
|
|
336
|
-
type: TestEnum
|
|
337
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(ClassDeclaration, {
|
|
338
|
-
type: TestModel
|
|
339
|
-
})];
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}));
|
|
346
|
-
assertFileContents(res, d`
|
|
347
|
-
namespace TestNamespace
|
|
348
|
-
{
|
|
349
|
-
public enum TestEnum
|
|
350
|
-
{
|
|
351
|
-
Value1,
|
|
352
|
-
Value2
|
|
353
|
-
}
|
|
354
|
-
class TestModel
|
|
355
|
-
{
|
|
356
|
-
public TestEnum Prop1
|
|
357
|
-
{
|
|
358
|
-
get;
|
|
359
|
-
set;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
`);
|
|
364
|
-
});
|
|
365
|
-
it("renders a class with string enums", async () => {
|
|
366
|
-
const {
|
|
367
|
-
TestModel,
|
|
368
|
-
TestEnum
|
|
369
|
-
} = await runner.compile(`
|
|
370
|
-
@test enum TestEnum {
|
|
371
|
-
Value1;
|
|
372
|
-
Value2;
|
|
373
|
-
}
|
|
374
|
-
@test model TestModel {
|
|
375
|
-
@test prop1: TestEnum;
|
|
376
|
-
}
|
|
377
|
-
`);
|
|
378
|
-
const res = render(_$createComponent(Output, {
|
|
379
|
-
get program() {
|
|
380
|
-
return runner.program;
|
|
381
|
-
},
|
|
382
|
-
get namePolicy() {
|
|
383
|
-
return cs.createCSharpNamePolicy();
|
|
384
|
-
},
|
|
385
|
-
get children() {
|
|
386
|
-
return _$createComponent(Namespace, {
|
|
387
|
-
name: "TestNamespace",
|
|
388
|
-
get children() {
|
|
389
|
-
return _$createComponent(SourceFile, {
|
|
390
|
-
path: "test.cs",
|
|
391
|
-
get children() {
|
|
392
|
-
return [_$createComponent(EnumDeclaration, {
|
|
393
|
-
type: TestEnum
|
|
394
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(ClassDeclaration, {
|
|
395
|
-
type: TestModel
|
|
396
|
-
})];
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
}));
|
|
403
|
-
assertFileContents(res, d`
|
|
404
|
-
namespace TestNamespace
|
|
405
|
-
{
|
|
406
|
-
public enum TestEnum
|
|
407
|
-
{
|
|
408
|
-
Value1,
|
|
409
|
-
Value2
|
|
410
|
-
}
|
|
411
|
-
class TestModel
|
|
412
|
-
{
|
|
413
|
-
public TestEnum Prop1
|
|
414
|
-
{
|
|
415
|
-
get;
|
|
416
|
-
set;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
`);
|
|
421
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import * as ay from "@alloy-js/core";
|
|
2
|
-
import * as cs from "@alloy-js/csharp";
|
|
3
|
-
import { Interface, Model } from "@typespec/compiler";
|
|
4
|
-
import { useTsp } from "../../core/index.js";
|
|
5
|
-
import { TypeExpression } from "./type-expression.jsx";
|
|
6
|
-
import { declarationRefkeys } from "./utils/refkey.js";
|
|
7
|
-
|
|
8
|
-
export interface ClassDeclarationProps extends Omit<cs.ClassProps, "name"> {
|
|
9
|
-
name?: string;
|
|
10
|
-
type: Model | Interface;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ClassPropertiesProps {
|
|
14
|
-
type: Model;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ClassMethodsProps {
|
|
18
|
-
type: Interface;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function ClassDeclaration(props: ClassDeclarationProps): ay.Children {
|
|
22
|
-
const { $ } = useTsp();
|
|
23
|
-
|
|
24
|
-
const namePolicy = cs.useCSharpNamePolicy();
|
|
25
|
-
const className = props.name ?? namePolicy.getName(props.type.name, "class");
|
|
26
|
-
|
|
27
|
-
const refkeys = declarationRefkeys(props.refkey, props.type)[0]; // TODO: support multiple refkeys for declarations in alloy
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<>
|
|
31
|
-
<cs.Class name={className} accessModifier={props.accessModifier} refkey={refkeys}>
|
|
32
|
-
{$.model.is(props.type) && <ClassProperties type={props.type} />}
|
|
33
|
-
{props.type.kind === "Interface" && <ClassMethods type={props.type} />}
|
|
34
|
-
</cs.Class>
|
|
35
|
-
</>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function ClassProperties(props: ClassPropertiesProps): ay.Children {
|
|
40
|
-
const namePolicy = cs.useCSharpNamePolicy();
|
|
41
|
-
|
|
42
|
-
const classProperties: ay.Children = [];
|
|
43
|
-
for (const [name, prop] of props.type.properties) {
|
|
44
|
-
classProperties.push(
|
|
45
|
-
<>
|
|
46
|
-
<cs.ClassMember
|
|
47
|
-
name={namePolicy.getName(name, "class-member-public")}
|
|
48
|
-
type={<TypeExpression type={prop.type} />}
|
|
49
|
-
accessModifier="public"
|
|
50
|
-
/>{" "}
|
|
51
|
-
<ay.Block newline>
|
|
52
|
-
<ay.StatementList children={["get", "set"]} />
|
|
53
|
-
</ay.Block>
|
|
54
|
-
</>,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<ay.For each={classProperties} hardline>
|
|
60
|
-
{(c) => c}
|
|
61
|
-
</ay.For>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function ClassMethods(props: ClassMethodsProps): ay.Children {
|
|
66
|
-
const namePolicy = cs.useCSharpNamePolicy();
|
|
67
|
-
|
|
68
|
-
const abstractMethods: ay.Children = [];
|
|
69
|
-
for (const [name, prop] of props.type.operations) {
|
|
70
|
-
abstractMethods.push(
|
|
71
|
-
<cs.ClassMethod
|
|
72
|
-
name={namePolicy.getName(name, "class-method")}
|
|
73
|
-
methodModifier="abstract"
|
|
74
|
-
parameters={[...prop.parameters.properties.entries()].map(([name, prop]) => {
|
|
75
|
-
return {
|
|
76
|
-
name: namePolicy.getName(name, "type-parameter"),
|
|
77
|
-
type: <TypeExpression type={prop.type} />,
|
|
78
|
-
};
|
|
79
|
-
})}
|
|
80
|
-
accessModifier="public"
|
|
81
|
-
returns={<TypeExpression type={prop.returnType} />}
|
|
82
|
-
/>,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return <>{abstractMethods}</>;
|
|
87
|
-
}
|