@alloy-js/csharp 0.18.0-dev.3 → 0.18.0-dev.5
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/components/ClassDeclaration.d.ts +47 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -0
- package/dist/src/components/{Class.js → ClassDeclaration.js} +33 -8
- package/dist/src/components/ClassMethod.d.ts +2 -4
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +2 -2
- package/dist/src/components/EnumDeclaration.d.ts +34 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -0
- package/dist/src/components/{Enum.js → EnumDeclaration.js} +25 -5
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -2
- package/dist/src/components/stc/index.d.ts +2 -2
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +2 -2
- package/dist/src/modifiers.d.ts +17 -4
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +9 -29
- package/dist/test/class-method.test.js +16 -14
- package/dist/test/class.test.js +35 -35
- package/dist/test/enum.test.js +12 -12
- package/dist/test/namespace.test.js +8 -8
- package/dist/test/projectdirectory.test.js +8 -8
- package/dist/test/sourcefile.test.js +4 -4
- package/dist/test/using.test.js +9 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/{Class.tsx → ClassDeclaration.tsx} +45 -16
- package/src/components/ClassMethod.tsx +6 -10
- package/src/components/{Enum.tsx → EnumDeclaration.tsx} +30 -6
- package/src/components/index.ts +2 -2
- package/src/components/stc/index.ts +2 -2
- package/src/modifiers.ts +36 -39
- package/temp/api.json +407 -266
- package/test/class-method.test.tsx +8 -14
- package/test/class.test.tsx +35 -56
- package/test/enum.test.tsx +11 -11
- package/test/namespace.test.tsx +4 -4
- package/test/projectdirectory.test.tsx +4 -4
- package/test/sourcefile.test.tsx +2 -2
- package/test/using.test.tsx +9 -9
- package/dist/src/components/Class.d.ts +0 -26
- package/dist/src/components/Class.d.ts.map +0 -1
- package/dist/src/components/Enum.d.ts +0 -15
- package/dist/src/components/Enum.d.ts.map +0 -1
package/dist/test/class.test.js
CHANGED
|
@@ -5,8 +5,8 @@ import { expect, it } from "vitest";
|
|
|
5
5
|
import * as csharp from "../src/index.js";
|
|
6
6
|
import * as utils from "./utils.js";
|
|
7
7
|
it("declares class with no members", () => {
|
|
8
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
9
|
-
|
|
8
|
+
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
9
|
+
"public": true,
|
|
10
10
|
name: "TestClass"
|
|
11
11
|
}));
|
|
12
12
|
expect(res).toBe(coretest.d`
|
|
@@ -17,18 +17,18 @@ it("declares class with no members", () => {
|
|
|
17
17
|
`);
|
|
18
18
|
});
|
|
19
19
|
it("declares class with some members", () => {
|
|
20
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
21
|
-
|
|
20
|
+
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
21
|
+
"public": true,
|
|
22
22
|
name: "TestClass",
|
|
23
23
|
get children() {
|
|
24
24
|
return _$createComponent(core.StatementList, {
|
|
25
25
|
get children() {
|
|
26
26
|
return [_$createComponent(csharp.ClassMember, {
|
|
27
|
-
|
|
27
|
+
"public": true,
|
|
28
28
|
name: "MemberOne",
|
|
29
29
|
type: "string"
|
|
30
30
|
}), _$createComponent(csharp.ClassMember, {
|
|
31
|
-
|
|
31
|
+
"private": true,
|
|
32
32
|
name: "MemberTwo",
|
|
33
33
|
type: "int"
|
|
34
34
|
})];
|
|
@@ -48,18 +48,18 @@ it("declares class with some members", () => {
|
|
|
48
48
|
`);
|
|
49
49
|
});
|
|
50
50
|
it("declares class with some methods", () => {
|
|
51
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
52
|
-
|
|
51
|
+
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
52
|
+
"public": true,
|
|
53
53
|
name: "TestClass",
|
|
54
54
|
get children() {
|
|
55
55
|
return _$createComponent(core.List, {
|
|
56
56
|
get children() {
|
|
57
57
|
return [_$createComponent(csharp.ClassMethod, {
|
|
58
|
-
|
|
58
|
+
"public": true,
|
|
59
59
|
name: "MethodOne"
|
|
60
60
|
}), _$createComponent(csharp.ClassMethod, {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
"private": true,
|
|
62
|
+
virtual: true,
|
|
63
63
|
name: "MethodTwo"
|
|
64
64
|
})];
|
|
65
65
|
}
|
|
@@ -99,8 +99,8 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
99
99
|
return _$createComponent(csharp.SourceFile, {
|
|
100
100
|
path: "Test.cs",
|
|
101
101
|
get children() {
|
|
102
|
-
return [_$createComponent(csharp.
|
|
103
|
-
|
|
102
|
+
return [_$createComponent(csharp.EnumDeclaration, {
|
|
103
|
+
"public": true,
|
|
104
104
|
name: "TestEnum",
|
|
105
105
|
refkey: enumTypeRefkey,
|
|
106
106
|
get children() {
|
|
@@ -116,24 +116,24 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.
|
|
120
|
-
|
|
119
|
+
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassDeclaration, {
|
|
120
|
+
"public": true,
|
|
121
121
|
name: "TestInput",
|
|
122
122
|
refkey: inputTypeRefkey
|
|
123
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.
|
|
124
|
-
|
|
123
|
+
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassDeclaration, {
|
|
124
|
+
"public": true,
|
|
125
125
|
name: "TestResult",
|
|
126
126
|
refkey: testResultTypeRefkey
|
|
127
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.
|
|
128
|
-
|
|
127
|
+
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassDeclaration, {
|
|
128
|
+
"public": true,
|
|
129
129
|
name: "TestClass",
|
|
130
130
|
get children() {
|
|
131
131
|
return [_$createComponent(csharp.ClassMember, {
|
|
132
|
-
|
|
132
|
+
"private": true,
|
|
133
133
|
name: "MemberOne",
|
|
134
134
|
type: enumTypeRefkey
|
|
135
135
|
}), ";", _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassMethod, {
|
|
136
|
-
|
|
136
|
+
"public": true,
|
|
137
137
|
name: "MethodOne",
|
|
138
138
|
parameters: params,
|
|
139
139
|
returns: testResultTypeRefkey,
|
|
@@ -175,19 +175,19 @@ it("declares class with generic parameters", () => {
|
|
|
175
175
|
T: core.refkey(),
|
|
176
176
|
U: core.refkey()
|
|
177
177
|
};
|
|
178
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
179
|
-
|
|
178
|
+
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
179
|
+
"public": true,
|
|
180
180
|
name: "TestClass",
|
|
181
181
|
typeParameters: typeParameters,
|
|
182
182
|
get children() {
|
|
183
183
|
return [_$createComponent(csharp.ClassMember, {
|
|
184
|
-
|
|
184
|
+
"public": true,
|
|
185
185
|
name: "memberOne",
|
|
186
186
|
get type() {
|
|
187
187
|
return typeParameters.T;
|
|
188
188
|
}
|
|
189
189
|
}), ";", _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassMember, {
|
|
190
|
-
|
|
190
|
+
"private": true,
|
|
191
191
|
name: "memberTwo",
|
|
192
192
|
get type() {
|
|
193
193
|
return typeParameters.U;
|
|
@@ -207,8 +207,8 @@ it("declares class with generic parameters", () => {
|
|
|
207
207
|
`);
|
|
208
208
|
});
|
|
209
209
|
it("declares class with invalid members", () => {
|
|
210
|
-
const decl = _$createComponent(csharp.
|
|
211
|
-
|
|
210
|
+
const decl = _$createComponent(csharp.ClassDeclaration, {
|
|
211
|
+
"public": true,
|
|
212
212
|
name: "TestClass",
|
|
213
213
|
get children() {
|
|
214
214
|
return [_$createComponent(csharp.EnumMember, {
|
|
@@ -221,12 +221,12 @@ it("declares class with invalid members", () => {
|
|
|
221
221
|
expect(() => utils.toSourceText(decl)).toThrow("can't define an enum member outside of an enum-decl scope");
|
|
222
222
|
});
|
|
223
223
|
it("declares class with constructor", () => {
|
|
224
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
225
|
-
|
|
224
|
+
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
225
|
+
"public": true,
|
|
226
226
|
name: "TestClass",
|
|
227
227
|
get children() {
|
|
228
228
|
return _$createComponent(csharp.ClassConstructor, {
|
|
229
|
-
|
|
229
|
+
"public": true
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
}));
|
|
@@ -254,22 +254,22 @@ it("declares class with constructor params and assigns values to fields", () =>
|
|
|
254
254
|
type: "int",
|
|
255
255
|
refkey: paramSizeRefkey
|
|
256
256
|
}];
|
|
257
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
258
|
-
|
|
257
|
+
const res = utils.toSourceText(_$createComponent(csharp.ClassDeclaration, {
|
|
258
|
+
"public": true,
|
|
259
259
|
name: "TestClass",
|
|
260
260
|
get children() {
|
|
261
261
|
return [_$createComponent(csharp.ClassMember, {
|
|
262
|
-
|
|
262
|
+
"private": true,
|
|
263
263
|
name: "name",
|
|
264
264
|
type: "string",
|
|
265
265
|
refkey: thisNameRefkey
|
|
266
266
|
}), ";", _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassMember, {
|
|
267
|
-
|
|
267
|
+
"private": true,
|
|
268
268
|
name: "size",
|
|
269
269
|
type: "int",
|
|
270
270
|
refkey: thisSizeRefkey
|
|
271
271
|
}), ";", _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassConstructor, {
|
|
272
|
-
|
|
272
|
+
"public": true,
|
|
273
273
|
parameters: ctorParams,
|
|
274
274
|
get children() {
|
|
275
275
|
return [thisNameRefkey, " = ", paramNameRefkey, ";", _$createIntrinsic("hbr", {}), thisSizeRefkey, " = ", paramSizeRefkey, ";"];
|
package/dist/test/enum.test.js
CHANGED
|
@@ -5,8 +5,8 @@ import { expect, it } from "vitest";
|
|
|
5
5
|
import * as csharp from "../src/index.js";
|
|
6
6
|
import * as utils from "./utils.js";
|
|
7
7
|
it("declares enum with no members", () => {
|
|
8
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
9
|
-
|
|
8
|
+
const res = utils.toSourceText(_$createComponent(csharp.EnumDeclaration, {
|
|
9
|
+
"public": true,
|
|
10
10
|
name: "TestEnum"
|
|
11
11
|
}));
|
|
12
12
|
expect(res).toBe(coretest.d`
|
|
@@ -17,8 +17,8 @@ it("declares enum with no members", () => {
|
|
|
17
17
|
`);
|
|
18
18
|
});
|
|
19
19
|
it("declares enum with members", () => {
|
|
20
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
21
|
-
|
|
20
|
+
const res = utils.toSourceText(_$createComponent(csharp.EnumDeclaration, {
|
|
21
|
+
"public": true,
|
|
22
22
|
name: "TestEnum",
|
|
23
23
|
get children() {
|
|
24
24
|
return [_$createComponent(csharp.EnumMember, {
|
|
@@ -40,8 +40,8 @@ it("declares enum with members", () => {
|
|
|
40
40
|
`);
|
|
41
41
|
});
|
|
42
42
|
it("applies naming policy to enum and members", () => {
|
|
43
|
-
const res = utils.toSourceText(_$createComponent(csharp.
|
|
44
|
-
|
|
43
|
+
const res = utils.toSourceText(_$createComponent(csharp.EnumDeclaration, {
|
|
44
|
+
"public": true,
|
|
45
45
|
name: "testEnum",
|
|
46
46
|
get children() {
|
|
47
47
|
return [_$createComponent(csharp.EnumMember, {
|
|
@@ -73,8 +73,8 @@ it("can reference things by refkey", () => {
|
|
|
73
73
|
return _$createComponent(csharp.SourceFile, {
|
|
74
74
|
path: "Test.cs",
|
|
75
75
|
get children() {
|
|
76
|
-
return [_$createComponent(csharp.
|
|
77
|
-
|
|
76
|
+
return [_$createComponent(csharp.EnumDeclaration, {
|
|
77
|
+
"public": true,
|
|
78
78
|
name: "TestEnum",
|
|
79
79
|
refkey: enumRK,
|
|
80
80
|
get children() {
|
|
@@ -116,8 +116,8 @@ it("can reference things by refkey across files", () => {
|
|
|
116
116
|
return [_$createComponent(csharp.SourceFile, {
|
|
117
117
|
path: "Test.cs",
|
|
118
118
|
get children() {
|
|
119
|
-
return [_$createComponent(csharp.
|
|
120
|
-
|
|
119
|
+
return [_$createComponent(csharp.EnumDeclaration, {
|
|
120
|
+
"public": true,
|
|
121
121
|
name: "TestEnum",
|
|
122
122
|
get children() {
|
|
123
123
|
return [_$createComponent(csharp.EnumMember, {
|
|
@@ -131,8 +131,8 @@ it("can reference things by refkey across files", () => {
|
|
|
131
131
|
}), _$createComponent(csharp.SourceFile, {
|
|
132
132
|
path: "Other.cs",
|
|
133
133
|
get children() {
|
|
134
|
-
return [_$createComponent(csharp.
|
|
135
|
-
|
|
134
|
+
return [_$createComponent(csharp.EnumDeclaration, {
|
|
135
|
+
"public": true,
|
|
136
136
|
name: "OtherEnum",
|
|
137
137
|
refkey: enumRK,
|
|
138
138
|
get children() {
|
|
@@ -12,16 +12,16 @@ it("defines multiple namespaces and source files with unique content", () => {
|
|
|
12
12
|
return [_$createComponent(csharp.SourceFile, {
|
|
13
13
|
path: "Model1.cs",
|
|
14
14
|
get children() {
|
|
15
|
-
return _$createComponent(csharp.
|
|
16
|
-
|
|
15
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
16
|
+
"public": true,
|
|
17
17
|
name: "Model1"
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}), _$createComponent(csharp.SourceFile, {
|
|
21
21
|
path: "Model2.cs",
|
|
22
22
|
get children() {
|
|
23
|
-
return _$createComponent(csharp.
|
|
24
|
-
|
|
23
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
24
|
+
"public": true,
|
|
25
25
|
name: "Model2"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
@@ -33,16 +33,16 @@ it("defines multiple namespaces and source files with unique content", () => {
|
|
|
33
33
|
return [_$createComponent(csharp.SourceFile, {
|
|
34
34
|
path: "Model3.cs",
|
|
35
35
|
get children() {
|
|
36
|
-
return _$createComponent(csharp.
|
|
37
|
-
|
|
36
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
37
|
+
"public": true,
|
|
38
38
|
name: "Model3"
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}), _$createComponent(csharp.SourceFile, {
|
|
42
42
|
path: "Model4.cs",
|
|
43
43
|
get children() {
|
|
44
|
-
return _$createComponent(csharp.
|
|
45
|
-
|
|
44
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
45
|
+
"public": true,
|
|
46
46
|
name: "Model4"
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -18,16 +18,16 @@ it("defines a project directory file with multiple source files", () => {
|
|
|
18
18
|
return [_$createComponent(csharp.SourceFile, {
|
|
19
19
|
path: "Test1.cs",
|
|
20
20
|
get children() {
|
|
21
|
-
return _$createComponent(csharp.
|
|
22
|
-
|
|
21
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
22
|
+
"public": true,
|
|
23
23
|
name: "TestClass1"
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}), _$createComponent(csharp.SourceFile, {
|
|
27
27
|
path: "Test2.cs",
|
|
28
28
|
get children() {
|
|
29
|
-
return _$createComponent(csharp.
|
|
30
|
-
|
|
29
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
30
|
+
"public": true,
|
|
31
31
|
name: "TestClass2"
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -82,16 +82,16 @@ it("defines a project directory file with multiple source files and a custom TFM
|
|
|
82
82
|
return [_$createComponent(csharp.SourceFile, {
|
|
83
83
|
path: "Test1.cs",
|
|
84
84
|
get children() {
|
|
85
|
-
return _$createComponent(csharp.
|
|
86
|
-
|
|
85
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
86
|
+
"public": true,
|
|
87
87
|
name: "TestClass1"
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
}), _$createComponent(csharp.SourceFile, {
|
|
91
91
|
path: "Test2.cs",
|
|
92
92
|
get children() {
|
|
93
|
-
return _$createComponent(csharp.
|
|
94
|
-
|
|
93
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
94
|
+
"public": true,
|
|
95
95
|
name: "TestClass2"
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -12,16 +12,16 @@ it("defines multiple source files with unique content", () => {
|
|
|
12
12
|
return [_$createComponent(csharp.SourceFile, {
|
|
13
13
|
path: "Test1.cs",
|
|
14
14
|
get children() {
|
|
15
|
-
return _$createComponent(csharp.
|
|
16
|
-
|
|
15
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
16
|
+
"public": true,
|
|
17
17
|
name: "TestClass1"
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}), _$createComponent(csharp.SourceFile, {
|
|
21
21
|
path: "Test2.cs",
|
|
22
22
|
get children() {
|
|
23
|
-
return _$createComponent(csharp.
|
|
24
|
-
|
|
23
|
+
return _$createComponent(csharp.ClassDeclaration, {
|
|
24
|
+
"public": true,
|
|
25
25
|
name: "TestClass2"
|
|
26
26
|
});
|
|
27
27
|
}
|
package/dist/test/using.test.js
CHANGED
|
@@ -63,16 +63,16 @@ it("adds using statement across namespaces", () => {
|
|
|
63
63
|
return _$createComponent(csharp.SourceFile, {
|
|
64
64
|
path: "Models.cs",
|
|
65
65
|
get children() {
|
|
66
|
-
return [_$createComponent(csharp.
|
|
67
|
-
|
|
66
|
+
return [_$createComponent(csharp.ClassDeclaration, {
|
|
67
|
+
"public": true,
|
|
68
68
|
name: "Input",
|
|
69
69
|
refkey: inputTypeRefkey
|
|
70
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.
|
|
71
|
-
|
|
70
|
+
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassDeclaration, {
|
|
71
|
+
"public": true,
|
|
72
72
|
name: "Output",
|
|
73
73
|
refkey: outputTypeRefkey
|
|
74
|
-
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.
|
|
75
|
-
|
|
74
|
+
}), _$createIntrinsic("hbr", {}), _$createComponent(csharp.EnumDeclaration, {
|
|
75
|
+
"public": true,
|
|
76
76
|
name: "TestEnum",
|
|
77
77
|
get children() {
|
|
78
78
|
return [_$createComponent(csharp.EnumMember, {
|
|
@@ -93,12 +93,12 @@ it("adds using statement across namespaces", () => {
|
|
|
93
93
|
path: "Client.cs",
|
|
94
94
|
using: ["System"],
|
|
95
95
|
get children() {
|
|
96
|
-
return [_$createComponent(csharp.
|
|
97
|
-
|
|
96
|
+
return [_$createComponent(csharp.ClassDeclaration, {
|
|
97
|
+
"public": true,
|
|
98
98
|
name: "Client",
|
|
99
99
|
get children() {
|
|
100
100
|
return _$createComponent(csharp.ClassMethod, {
|
|
101
|
-
|
|
101
|
+
"public": true,
|
|
102
102
|
name: "MethodOne",
|
|
103
103
|
parameters: params,
|
|
104
104
|
returns: outputTypeRefkey
|