@alloy-js/csharp 0.18.0-dev.9 → 0.18.0
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/CHANGELOG.md +31 -0
- package/dist/src/components/ClassDeclaration.d.ts +39 -2
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +35 -34
- package/dist/src/components/ClassMethod.d.ts +33 -1
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +22 -7
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +1 -0
- package/dist/src/components/attributes/attributes.d.ts +39 -0
- package/dist/src/components/attributes/attributes.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.js +62 -0
- package/dist/src/components/attributes/attributes.test.d.ts +2 -0
- package/dist/src/components/attributes/attributes.test.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +75 -0
- package/dist/src/components/index.d.ts +7 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +8 -2
- package/dist/src/components/interface/declaration.d.ts +32 -1
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +18 -25
- package/dist/src/components/interface/declaration.test.js +102 -0
- package/dist/src/components/interface/method.d.ts +33 -1
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +22 -7
- package/dist/src/components/interface/method.test.js +169 -0
- package/dist/src/components/interface/property.d.ts +36 -1
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +18 -4
- package/dist/src/components/interface/property.test.js +24 -0
- package/dist/src/components/parameters/parameters.d.ts +19 -0
- package/dist/src/components/parameters/parameters.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.js +43 -0
- package/dist/src/components/property/property.d.ts +80 -0
- package/dist/src/components/property/property.d.ts.map +1 -0
- package/dist/src/components/property/property.js +76 -0
- package/dist/src/components/property/property.test.d.ts +2 -0
- package/dist/src/components/property/property.test.d.ts.map +1 -0
- package/dist/src/components/property/property.test.js +242 -0
- package/dist/src/components/record/declaration.d.ts +35 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -0
- package/dist/src/components/record/declaration.js +90 -0
- package/dist/src/components/record/declaration.test.d.ts +2 -0
- package/dist/src/components/record/declaration.test.d.ts.map +1 -0
- package/dist/src/components/record/declaration.test.js +94 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +8 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.js +44 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +2 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +67 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts +20 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter.js +22 -0
- package/dist/src/components/type-parameters/type-parameters.d.ts +17 -0
- package/dist/src/components/type-parameters/type-parameters.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.js +54 -0
- package/dist/src/components/type-parameters/type-parameters.test.d.ts +2 -0
- package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.test.js +48 -0
- package/dist/src/components/var/declaration.d.ts +35 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -0
- package/dist/src/components/var/declaration.js +40 -0
- package/dist/src/components/var/declaration.test.d.ts +2 -0
- package/dist/src/components/var/declaration.test.d.ts.map +1 -0
- package/dist/src/components/var/declaration.test.js +73 -0
- package/dist/src/name-policy.d.ts +1 -1
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +1 -0
- package/dist/test/class-declaration.test.d.ts +2 -0
- package/dist/test/class-declaration.test.d.ts.map +1 -0
- package/dist/test/{class.test.js → class-declaration.test.js} +161 -33
- package/dist/test/project-directory.test.d.ts +2 -0
- package/dist/test/project-directory.test.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/ClassDeclaration.tsx +65 -33
- package/src/components/ClassMethod.tsx +46 -4
- package/src/components/SourceFile.tsx +1 -0
- package/src/components/attributes/attributes.test.tsx +61 -0
- package/src/components/attributes/attributes.tsx +100 -0
- package/src/components/index.ts +7 -1
- package/src/components/interface/declaration.test.tsx +102 -0
- package/src/components/interface/declaration.tsx +43 -27
- package/src/components/interface/method.test.tsx +173 -0
- package/src/components/interface/method.tsx +45 -5
- package/src/components/interface/property.test.tsx +21 -0
- package/src/components/interface/property.tsx +43 -6
- package/src/components/parameters/parameters.tsx +74 -0
- package/src/components/property/property.test.tsx +209 -0
- package/src/components/property/property.tsx +172 -0
- package/src/components/record/declaration.test.tsx +73 -0
- package/src/components/record/declaration.tsx +109 -0
- package/src/components/type-parameters/type-parameter-constraints.test.tsx +93 -0
- package/src/components/type-parameters/type-parameter-constraints.tsx +46 -0
- package/src/components/type-parameters/type-parameter.tsx +35 -0
- package/src/components/type-parameters/type-parameters.test.tsx +46 -0
- package/src/components/type-parameters/type-parameters.tsx +63 -0
- package/src/components/var/declaration.test.tsx +59 -0
- package/src/components/var/declaration.tsx +47 -0
- package/src/name-policy.ts +3 -0
- package/temp/api.json +4722 -2384
- package/test/{class.test.tsx → class-declaration.test.tsx} +144 -26
- package/dist/src/components/Parameters.d.ts +0 -13
- package/dist/src/components/Parameters.d.ts.map +0 -1
- package/dist/src/components/Parameters.js +0 -34
- package/dist/test/class.test.d.ts +0 -2
- package/dist/test/class.test.d.ts.map +0 -1
- package/dist/test/projectdirectory.test.d.ts +0 -2
- package/dist/test/projectdirectory.test.d.ts.map +0 -1
- package/src/components/Parameters.tsx +0 -51
- /package/dist/test/{projectdirectory.test.js → project-directory.test.js} +0 -0
- /package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, mergeProps as _$mergeProps, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as core from "@alloy-js/core";
|
|
3
|
+
import { List, refkey } from "@alloy-js/core";
|
|
3
4
|
import * as coretest from "@alloy-js/core/testing";
|
|
4
5
|
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { Attribute } from "../src/components/attributes/attributes.js";
|
|
5
7
|
import * as csharp from "../src/index.js";
|
|
6
|
-
import { ClassDeclaration } from "../src/index.js";
|
|
8
|
+
import { ClassDeclaration, ClassMember, Property, SourceFile } from "../src/index.js";
|
|
7
9
|
import * as utils from "./utils.js";
|
|
8
10
|
it("declares class with no members", () => {
|
|
9
11
|
expect(_$createComponent(utils.TestNamespace, {
|
|
@@ -58,6 +60,45 @@ describe("modifiers", () => {
|
|
|
58
60
|
`);
|
|
59
61
|
});
|
|
60
62
|
});
|
|
63
|
+
describe("base", () => {
|
|
64
|
+
it("define base class", () => {
|
|
65
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
66
|
+
get children() {
|
|
67
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
68
|
+
name: "TestClass",
|
|
69
|
+
baseType: "Foo"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
})).toRenderTo(`
|
|
73
|
+
class TestClass : Foo;
|
|
74
|
+
`);
|
|
75
|
+
});
|
|
76
|
+
it("define multiple interface types", () => {
|
|
77
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
78
|
+
get children() {
|
|
79
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
80
|
+
name: "TestClass",
|
|
81
|
+
interfaceTypes: ["Foo", "Bar"]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
})).toRenderTo(`
|
|
85
|
+
class TestClass : Foo, Bar;
|
|
86
|
+
`);
|
|
87
|
+
});
|
|
88
|
+
it("define base class and multiple interface types", () => {
|
|
89
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
90
|
+
get children() {
|
|
91
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
92
|
+
name: "TestClass",
|
|
93
|
+
baseType: "BaseClass",
|
|
94
|
+
interfaceTypes: ["Foo", "Bar"]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
})).toRenderTo(`
|
|
98
|
+
class TestClass : BaseClass, Foo, Bar;
|
|
99
|
+
`);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
61
102
|
it("declares class with some members", () => {
|
|
62
103
|
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
63
104
|
"public": true,
|
|
@@ -212,41 +253,86 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
212
253
|
}
|
|
213
254
|
`);
|
|
214
255
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
256
|
+
describe("with type parameters", () => {
|
|
257
|
+
it("reference parameters", () => {
|
|
258
|
+
const typeParameters = [{
|
|
259
|
+
name: "T",
|
|
260
|
+
refkey: refkey()
|
|
261
|
+
}, {
|
|
262
|
+
name: "U",
|
|
263
|
+
refkey: refkey()
|
|
264
|
+
}];
|
|
265
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
266
|
+
get children() {
|
|
267
|
+
return _$createComponent(SourceFile, {
|
|
268
|
+
path: "Test.cs",
|
|
269
|
+
get children() {
|
|
270
|
+
return _$createComponent(ClassDeclaration, {
|
|
271
|
+
"public": true,
|
|
272
|
+
name: "TestClass",
|
|
273
|
+
typeParameters: typeParameters,
|
|
274
|
+
get children() {
|
|
275
|
+
return _$createComponent(List, {
|
|
276
|
+
get children() {
|
|
277
|
+
return [_$createComponent(Property, {
|
|
278
|
+
name: "PropA",
|
|
279
|
+
get type() {
|
|
280
|
+
return typeParameters[0].refkey;
|
|
281
|
+
},
|
|
282
|
+
get: true,
|
|
283
|
+
set: true
|
|
284
|
+
}), _$createComponent(Property, {
|
|
285
|
+
name: "PropB",
|
|
286
|
+
get type() {
|
|
287
|
+
return typeParameters[1].refkey;
|
|
288
|
+
},
|
|
289
|
+
get: true,
|
|
290
|
+
set: true
|
|
291
|
+
})];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
})).toRenderTo(`
|
|
300
|
+
namespace TestCode
|
|
301
|
+
{
|
|
243
302
|
public class TestClass<T, U>
|
|
244
303
|
{
|
|
245
|
-
|
|
246
|
-
|
|
304
|
+
T PropA { get; set; }
|
|
305
|
+
U PropB { get; set; }
|
|
247
306
|
}
|
|
248
|
-
|
|
249
|
-
|
|
307
|
+
}
|
|
308
|
+
`);
|
|
309
|
+
});
|
|
310
|
+
it("defines with constraints", () => {
|
|
311
|
+
const typeParameters = [{
|
|
312
|
+
name: "T",
|
|
313
|
+
constraints: "IFoo"
|
|
314
|
+
}, {
|
|
315
|
+
name: "U",
|
|
316
|
+
constraints: "IBar"
|
|
317
|
+
}];
|
|
318
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
319
|
+
get children() {
|
|
320
|
+
return _$createComponent(ClassDeclaration, {
|
|
321
|
+
"public": true,
|
|
322
|
+
name: "TestClass",
|
|
323
|
+
typeParameters: typeParameters,
|
|
324
|
+
children: "// Body"
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
})).toRenderTo(`
|
|
328
|
+
public class TestClass<T, U>
|
|
329
|
+
where T : IFoo
|
|
330
|
+
where U : IBar
|
|
331
|
+
{
|
|
332
|
+
// Body
|
|
333
|
+
}
|
|
334
|
+
`);
|
|
335
|
+
});
|
|
250
336
|
});
|
|
251
337
|
it("declares class with invalid members", () => {
|
|
252
338
|
const decl = _$createComponent(csharp.ClassDeclaration, {
|
|
@@ -350,4 +436,46 @@ it("specify doc comment", () => {
|
|
|
350
436
|
/// This is a test
|
|
351
437
|
class Test;
|
|
352
438
|
`);
|
|
439
|
+
});
|
|
440
|
+
it("supports class member doc comments", () => {
|
|
441
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
442
|
+
get children() {
|
|
443
|
+
return _$createComponent(ClassDeclaration, {
|
|
444
|
+
name: "Test",
|
|
445
|
+
doc: "This is a test",
|
|
446
|
+
get children() {
|
|
447
|
+
return _$createComponent(ClassMember, {
|
|
448
|
+
name: "Member",
|
|
449
|
+
"public": true,
|
|
450
|
+
type: "int",
|
|
451
|
+
doc: "This is a member"
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
})).toRenderTo(`
|
|
457
|
+
/// This is a test
|
|
458
|
+
class Test
|
|
459
|
+
{
|
|
460
|
+
/// This is a member
|
|
461
|
+
public int Member
|
|
462
|
+
}
|
|
463
|
+
`);
|
|
464
|
+
});
|
|
465
|
+
it("specify attributes", () => {
|
|
466
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
467
|
+
get children() {
|
|
468
|
+
return _$createComponent(ClassDeclaration, {
|
|
469
|
+
name: "Test",
|
|
470
|
+
get attributes() {
|
|
471
|
+
return [_$createComponent(Attribute, {
|
|
472
|
+
name: "Test"
|
|
473
|
+
})];
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
})).toRenderTo(`
|
|
478
|
+
[Test]
|
|
479
|
+
class Test;
|
|
480
|
+
`);
|
|
353
481
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-directory.test.d.ts","sourceRoot":"","sources":["../../test/project-directory.test.tsx"],"names":[],"mappings":""}
|