@alloy-js/csharp 0.20.0-dev.3 → 0.20.0-dev.4
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/Declaration.d.ts +2 -2
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +3 -13
- package/dist/src/components/Reference.d.ts.map +1 -1
- package/dist/src/components/Reference.js +5 -1
- package/dist/src/components/SourceFile.d.ts +8 -9
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +69 -45
- package/dist/src/components/UsingDirective.d.ts +5 -1
- package/dist/src/components/UsingDirective.d.ts.map +1 -1
- package/dist/src/components/UsingDirective.js +3 -1
- package/dist/src/components/class/declaration.d.ts +2 -2
- package/dist/src/components/class/declaration.d.ts.map +1 -1
- package/dist/src/components/class/declaration.js +18 -32
- package/dist/src/components/class/declaration.test.js +171 -193
- package/dist/src/components/constructor/constructor.d.ts.map +1 -1
- package/dist/src/components/constructor/constructor.js +11 -16
- package/dist/src/components/constructor/constructor.test.js +10 -19
- package/dist/src/components/{EnumDeclaration.d.ts → enum/declaration.d.ts} +6 -11
- package/dist/src/components/enum/declaration.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.js +54 -0
- package/dist/src/components/enum/declaration.ref.test.d.ts +2 -0
- package/dist/src/components/enum/declaration.ref.test.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.ref.test.js +120 -0
- package/dist/src/components/enum/declaration.test.d.ts +2 -0
- package/dist/src/components/enum/declaration.test.d.ts.map +1 -0
- package/dist/src/components/enum/declaration.test.js +39 -0
- package/dist/src/components/enum/member.d.ts +7 -0
- package/dist/src/components/enum/member.d.ts.map +1 -0
- package/dist/src/components/enum/member.js +29 -0
- package/dist/src/components/enum/member.test.d.ts +2 -0
- package/dist/src/components/enum/member.test.d.ts.map +1 -0
- package/dist/src/components/enum/member.test.js +28 -0
- package/dist/src/components/field/field.d.ts.map +1 -1
- package/dist/src/components/field/field.js +9 -14
- package/dist/src/components/field/field.test.js +7 -7
- package/dist/src/components/index.d.ts +5 -2
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +5 -2
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +19 -21
- package/dist/src/components/interface/declaration.test.js +26 -35
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +7 -15
- package/dist/src/components/interface/method.test.js +38 -47
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +21 -36
- package/dist/src/components/interface/property.test.js +11 -11
- package/dist/src/components/lexical-scope.d.ts +8 -0
- package/dist/src/components/lexical-scope.d.ts.map +1 -0
- package/dist/src/components/lexical-scope.js +24 -0
- package/dist/src/components/method/method.d.ts +5 -2
- package/dist/src/components/method/method.d.ts.map +1 -1
- package/dist/src/components/method/method.js +7 -13
- package/dist/src/components/method/method.test.js +11 -11
- package/dist/src/components/method-scope.d.ts +8 -0
- package/dist/src/components/method-scope.d.ts.map +1 -0
- package/dist/src/components/method-scope.js +24 -0
- package/dist/src/components/namespace-scopes.d.ts +13 -0
- package/dist/src/components/namespace-scopes.d.ts.map +1 -0
- package/dist/src/components/namespace-scopes.js +44 -0
- package/dist/src/components/namespace.d.ts +7 -0
- package/dist/src/components/namespace.d.ts.map +1 -0
- package/dist/src/components/namespace.js +46 -0
- package/dist/src/components/namespace.ref.test.d.ts +2 -0
- package/dist/src/components/namespace.ref.test.d.ts.map +1 -0
- package/dist/src/components/namespace.ref.test.js +181 -0
- package/dist/src/components/namespace.test.d.ts.map +1 -0
- package/dist/src/components/namespace.test.js +78 -0
- package/dist/src/components/parameters/parameters.d.ts +2 -2
- package/dist/src/components/parameters/parameters.d.ts.map +1 -1
- package/dist/src/components/parameters/parameters.js +12 -11
- package/dist/src/components/parameters/parameters.test.d.ts +2 -0
- package/dist/src/components/parameters/parameters.test.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.test.js +87 -0
- package/dist/src/components/property/property.d.ts.map +1 -1
- package/dist/src/components/property/property.js +21 -36
- package/dist/src/components/property/property.test.js +14 -14
- package/dist/src/components/record/declaration.d.ts.map +1 -1
- package/dist/src/components/record/declaration.js +8 -12
- package/dist/src/components/record/declaration.test.js +6 -13
- package/dist/src/components/struct/declaration.d.ts.map +1 -1
- package/dist/src/components/struct/declaration.js +4 -6
- package/dist/src/components/struct/declaration.test.js +30 -39
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -1
- package/dist/src/components/type-parameters/type-parameter.js +7 -10
- package/dist/src/components/type-parameters/type-parameters.test.js +3 -3
- package/dist/src/components/var/declaration.d.ts.map +1 -1
- package/dist/src/components/var/declaration.js +6 -8
- package/dist/src/components/var/declaration.test.js +11 -20
- package/dist/src/contexts/global-namespace.d.ts +5 -0
- package/dist/src/contexts/global-namespace.d.ts.map +1 -0
- package/dist/src/contexts/global-namespace.js +24 -0
- package/dist/src/contexts/namespace.d.ts +8 -0
- package/dist/src/contexts/namespace.d.ts.map +1 -0
- package/dist/src/contexts/namespace.js +5 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/modifiers.d.ts +11 -0
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/scopes/class.d.ts +10 -0
- package/dist/src/scopes/class.d.ts.map +1 -0
- package/dist/src/scopes/class.js +10 -0
- package/dist/src/scopes/contexts.d.ts +9 -0
- package/dist/src/scopes/contexts.d.ts.map +1 -0
- package/dist/src/scopes/contexts.js +33 -0
- package/dist/src/scopes/csharp.d.ts +8 -0
- package/dist/src/scopes/csharp.d.ts.map +1 -0
- package/dist/src/scopes/csharp.js +11 -0
- package/dist/src/scopes/factories.d.ts +9 -0
- package/dist/src/scopes/factories.d.ts.map +1 -0
- package/dist/src/scopes/factories.js +23 -0
- package/dist/src/scopes/index.d.ts +10 -0
- package/dist/src/scopes/index.d.ts.map +1 -0
- package/dist/src/scopes/index.js +9 -0
- package/dist/src/scopes/lexical.d.ts +7 -0
- package/dist/src/scopes/lexical.d.ts.map +1 -0
- package/dist/src/scopes/lexical.js +7 -0
- package/dist/src/scopes/method.d.ts +9 -0
- package/dist/src/scopes/method.d.ts.map +1 -0
- package/dist/src/scopes/method.js +13 -0
- package/dist/src/scopes/named-type.d.ts +22 -0
- package/dist/src/scopes/named-type.d.ts.map +1 -0
- package/dist/src/scopes/named-type.js +32 -0
- package/dist/src/scopes/namespace.d.ts +11 -0
- package/dist/src/scopes/namespace.d.ts.map +1 -0
- package/dist/src/scopes/namespace.js +38 -0
- package/dist/src/scopes/source-file.d.ts +16 -0
- package/dist/src/scopes/source-file.d.ts.map +1 -0
- package/dist/src/scopes/source-file.js +43 -0
- package/dist/src/symbols/csharp.d.ts +76 -0
- package/dist/src/symbols/csharp.d.ts.map +1 -0
- package/dist/src/symbols/csharp.js +222 -0
- package/dist/src/symbols/factories.d.ts +25 -0
- package/dist/src/symbols/factories.d.ts.map +1 -0
- package/dist/src/symbols/factories.js +86 -0
- package/dist/src/symbols/index.d.ts +5 -2
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +6 -3
- package/dist/src/symbols/method.d.ts +13 -0
- package/dist/src/symbols/method.d.ts.map +1 -0
- package/dist/src/symbols/method.js +15 -0
- package/dist/src/symbols/named-type.d.ts +19 -0
- package/dist/src/symbols/named-type.d.ts.map +1 -0
- package/dist/src/symbols/named-type.js +30 -0
- package/dist/src/symbols/namespace.d.ts +22 -0
- package/dist/src/symbols/namespace.d.ts.map +1 -0
- package/dist/src/symbols/namespace.js +44 -0
- package/dist/src/symbols/reference.d.ts +2 -2
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +36 -43
- package/dist/test/project-directory.test.js +12 -16
- package/dist/test/sourcefile.test.js +7 -19
- package/dist/test/using.test.js +18 -16
- package/dist/test/utils.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
- package/src/components/Declaration.tsx +3 -6
- package/src/components/Reference.tsx +3 -1
- package/src/components/SourceFile.tsx +68 -55
- package/src/components/UsingDirective.tsx +12 -2
- package/src/components/class/declaration.test.tsx +120 -143
- package/src/components/class/declaration.tsx +19 -32
- package/src/components/constructor/constructor.test.tsx +10 -16
- package/src/components/constructor/constructor.tsx +13 -27
- package/src/components/enum/declaration.ref.test.tsx +93 -0
- package/src/components/enum/declaration.test.tsx +34 -0
- package/src/components/enum/declaration.tsx +65 -0
- package/src/components/enum/member.test.tsx +24 -0
- package/src/components/enum/member.tsx +36 -0
- package/src/components/field/field.test.tsx +7 -7
- package/src/components/field/field.tsx +12 -14
- package/src/components/index.ts +5 -2
- package/src/components/interface/declaration.test.tsx +26 -32
- package/src/components/interface/declaration.tsx +16 -18
- package/src/components/interface/method.test.tsx +38 -44
- package/src/components/interface/method.tsx +7 -19
- package/src/components/interface/property.test.tsx +11 -11
- package/src/components/interface/property.tsx +15 -33
- package/src/components/lexical-scope.tsx +29 -0
- package/src/components/method/method.test.tsx +11 -11
- package/src/components/method/method.tsx +12 -18
- package/src/components/method-scope.tsx +27 -0
- package/src/components/namespace-scopes.tsx +44 -0
- package/src/components/namespace.ref.test.tsx +139 -0
- package/src/components/namespace.test.tsx +52 -0
- package/src/components/namespace.tsx +45 -0
- package/src/components/parameters/parameters.test.tsx +71 -0
- package/src/components/parameters/parameters.tsx +9 -16
- package/src/components/property/property.test.tsx +14 -14
- package/src/components/property/property.tsx +17 -38
- package/src/components/record/declaration.test.tsx +5 -12
- package/src/components/record/declaration.tsx +10 -11
- package/src/components/struct/declaration.test.tsx +16 -22
- package/src/components/struct/declaration.tsx +4 -6
- package/src/components/type-parameters/type-parameter.tsx +14 -11
- package/src/components/type-parameters/type-parameters.test.tsx +4 -4
- package/src/components/var/declaration.test.tsx +8 -14
- package/src/components/var/declaration.tsx +12 -6
- package/src/contexts/global-namespace.ts +29 -0
- package/src/contexts/namespace.ts +13 -0
- package/src/index.ts +1 -0
- package/src/modifiers.ts +14 -0
- package/src/scopes/class.ts +12 -0
- package/src/scopes/contexts.ts +45 -0
- package/src/scopes/csharp.ts +18 -0
- package/src/scopes/factories.ts +45 -0
- package/src/scopes/index.ts +9 -0
- package/src/scopes/lexical.ts +10 -0
- package/src/scopes/method.ts +22 -0
- package/src/scopes/named-type.ts +44 -0
- package/src/scopes/namespace.ts +59 -0
- package/src/scopes/source-file.ts +67 -0
- package/src/symbols/csharp.ts +307 -0
- package/src/symbols/factories.ts +199 -0
- package/src/symbols/index.ts +5 -2
- package/src/symbols/method.ts +26 -0
- package/src/symbols/named-type.ts +54 -0
- package/src/symbols/namespace.ts +62 -0
- package/src/symbols/reference.ts +47 -50
- package/temp/api.json +6251 -2454
- package/test/project-directory.test.tsx +12 -16
- package/test/sourcefile.test.tsx +7 -21
- package/test/using.test.tsx +18 -16
- package/test/utils.tsx +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
- package/dist/src/components/EnumDeclaration.js +0 -82
- package/dist/src/components/Namespace.d.ts +0 -11
- package/dist/src/components/Namespace.d.ts.map +0 -1
- package/dist/src/components/Namespace.js +0 -33
- package/dist/src/symbols/csharp-output-symbol.d.ts +0 -8
- package/dist/src/symbols/csharp-output-symbol.d.ts.map +0 -1
- package/dist/src/symbols/csharp-output-symbol.js +0 -19
- package/dist/src/symbols/scopes.d.ts +0 -20
- package/dist/src/symbols/scopes.d.ts.map +0 -1
- package/dist/src/symbols/scopes.js +0 -42
- package/dist/test/enum.test.d.ts +0 -2
- package/dist/test/enum.test.d.ts.map +0 -1
- package/dist/test/enum.test.js +0 -178
- package/dist/test/namespace.test.d.ts.map +0 -1
- package/dist/test/namespace.test.js +0 -81
- package/src/components/EnumDeclaration.tsx +0 -98
- package/src/components/Namespace.tsx +0 -35
- package/src/symbols/csharp-output-symbol.ts +0 -22
- package/src/symbols/scopes.ts +0 -61
- package/test/enum.test.tsx +0 -149
- package/test/namespace.test.tsx +0 -55
- /package/dist/{test → src/components}/namespace.test.d.ts +0 -0
|
@@ -3,7 +3,6 @@ import { Children } from "@alloy-js/core/jsx-runtime";
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import { TestNamespace } from "../../../test/utils.jsx";
|
|
5
5
|
import { Attribute } from "../attributes/attributes.jsx";
|
|
6
|
-
import { SourceFile } from "../SourceFile.jsx";
|
|
7
6
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
8
7
|
import { InterfaceDeclaration } from "./declaration.jsx";
|
|
9
8
|
import { InterfaceMethod } from "./method.jsx";
|
|
@@ -28,7 +27,7 @@ describe("modifiers", () => {
|
|
|
28
27
|
).toRenderTo(`
|
|
29
28
|
public interface TestInterface
|
|
30
29
|
{
|
|
31
|
-
|
|
30
|
+
${accessModifier} void MethodOne();
|
|
32
31
|
}
|
|
33
32
|
`);
|
|
34
33
|
},
|
|
@@ -44,7 +43,7 @@ describe("modifiers", () => {
|
|
|
44
43
|
).toRenderTo(`
|
|
45
44
|
public interface TestInterface
|
|
46
45
|
{
|
|
47
|
-
|
|
46
|
+
${methodModifier} void MethodOne();
|
|
48
47
|
}
|
|
49
48
|
`);
|
|
50
49
|
});
|
|
@@ -58,7 +57,7 @@ describe("modifiers", () => {
|
|
|
58
57
|
).toRenderTo(`
|
|
59
58
|
public interface TestInterface
|
|
60
59
|
{
|
|
61
|
-
|
|
60
|
+
public new Task MethodOne();
|
|
62
61
|
}
|
|
63
62
|
`);
|
|
64
63
|
});
|
|
@@ -72,7 +71,7 @@ it("applies PascalCase naming policy", () => {
|
|
|
72
71
|
).toRenderTo(`
|
|
73
72
|
public interface TestInterface
|
|
74
73
|
{
|
|
75
|
-
|
|
74
|
+
void MethodOne();
|
|
76
75
|
}
|
|
77
76
|
`);
|
|
78
77
|
});
|
|
@@ -102,7 +101,7 @@ it("defines params and return type", () => {
|
|
|
102
101
|
expect(res).toRenderTo(`
|
|
103
102
|
public interface TestInterface
|
|
104
103
|
{
|
|
105
|
-
|
|
104
|
+
public string MethodOne(int intParam, string stringParam);
|
|
106
105
|
}
|
|
107
106
|
`);
|
|
108
107
|
});
|
|
@@ -128,7 +127,7 @@ it("defines optional param", () => {
|
|
|
128
127
|
expect(res).toRenderTo(`
|
|
129
128
|
public interface TestInterface
|
|
130
129
|
{
|
|
131
|
-
|
|
130
|
+
public string MethodOne(int? intParam);
|
|
132
131
|
}
|
|
133
132
|
`);
|
|
134
133
|
});
|
|
@@ -154,7 +153,7 @@ it("defines optional param with default", () => {
|
|
|
154
153
|
expect(res).toRenderTo(`
|
|
155
154
|
public interface TestInterface
|
|
156
155
|
{
|
|
157
|
-
|
|
156
|
+
public string MethodOne(int intParam = 12);
|
|
158
157
|
}
|
|
159
158
|
`);
|
|
160
159
|
});
|
|
@@ -169,8 +168,8 @@ it("specify doc comment", () => {
|
|
|
169
168
|
).toRenderTo(`
|
|
170
169
|
interface Test
|
|
171
170
|
{
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
/// This is a test
|
|
172
|
+
void Method();
|
|
174
173
|
}
|
|
175
174
|
`);
|
|
176
175
|
});
|
|
@@ -183,8 +182,8 @@ it("specify attributes", () => {
|
|
|
183
182
|
).toRenderTo(`
|
|
184
183
|
public interface TestInterface
|
|
185
184
|
{
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
[Test]
|
|
186
|
+
void Test();
|
|
188
187
|
}
|
|
189
188
|
`);
|
|
190
189
|
});
|
|
@@ -204,30 +203,25 @@ describe("with type parameters", () => {
|
|
|
204
203
|
|
|
205
204
|
expect(
|
|
206
205
|
<TestNamespace>
|
|
207
|
-
<
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
</InterfaceDeclaration>
|
|
222
|
-
</SourceFile>
|
|
206
|
+
<InterfaceDeclaration public name="TestInterface">
|
|
207
|
+
<InterfaceMethod
|
|
208
|
+
name="Test"
|
|
209
|
+
public
|
|
210
|
+
typeParameters={typeParameters}
|
|
211
|
+
parameters={[
|
|
212
|
+
{
|
|
213
|
+
name: "paramA",
|
|
214
|
+
type: typeParameters[0].refkey,
|
|
215
|
+
},
|
|
216
|
+
]}
|
|
217
|
+
returns={typeParameters[0].refkey}
|
|
218
|
+
/>
|
|
219
|
+
</InterfaceDeclaration>
|
|
223
220
|
</TestNamespace>,
|
|
224
221
|
).toRenderTo(`
|
|
225
|
-
|
|
222
|
+
public interface TestInterface
|
|
226
223
|
{
|
|
227
|
-
public
|
|
228
|
-
{
|
|
229
|
-
public T Test<T, U>(T paramA);
|
|
230
|
-
}
|
|
224
|
+
public T Test<T, U>(T paramA);
|
|
231
225
|
}
|
|
232
226
|
`);
|
|
233
227
|
});
|
|
@@ -253,12 +247,12 @@ describe("with type parameters", () => {
|
|
|
253
247
|
).toRenderTo(`
|
|
254
248
|
public interface TestInterface
|
|
255
249
|
{
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
250
|
+
public void Test<T, U>()
|
|
251
|
+
where T : IFoo
|
|
252
|
+
where U : IBar
|
|
253
|
+
{
|
|
254
|
+
// Body
|
|
255
|
+
}
|
|
262
256
|
}
|
|
263
257
|
`);
|
|
264
258
|
});
|
|
@@ -274,19 +268,19 @@ describe("formatting", () => {
|
|
|
274
268
|
parameters={[
|
|
275
269
|
{
|
|
276
270
|
name: "message",
|
|
277
|
-
type: "Some.Quite.Long.Type.That.Will.Split",
|
|
271
|
+
type: "Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width",
|
|
278
272
|
},
|
|
279
273
|
]}
|
|
280
274
|
typeParameters={["T"]}
|
|
281
|
-
returns="Some.Quite.Long.Type.That.Will.Split"
|
|
275
|
+
returns="Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width"
|
|
282
276
|
/>
|
|
283
277
|
</Wrapper>,
|
|
284
278
|
).toRenderTo(`
|
|
285
279
|
public interface TestInterface
|
|
286
280
|
{
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
281
|
+
public Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width Handle<T>(
|
|
282
|
+
Some.Quite.Long.Type.That.Will.Split.At.One.Hundred.Chars.Line.Width message
|
|
283
|
+
);
|
|
290
284
|
}
|
|
291
285
|
`);
|
|
292
286
|
});
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Block,
|
|
3
3
|
Children,
|
|
4
4
|
MemberDeclaration,
|
|
5
|
-
|
|
5
|
+
MemberName,
|
|
6
6
|
Refkey,
|
|
7
7
|
Scope,
|
|
8
8
|
} from "@alloy-js/core";
|
|
@@ -12,12 +12,8 @@ import {
|
|
|
12
12
|
getAccessModifier,
|
|
13
13
|
makeModifiers,
|
|
14
14
|
} from "../../modifiers.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
CSharpMemberScope,
|
|
19
|
-
useCSharpMemberScope,
|
|
20
|
-
} from "../../symbols/scopes.js";
|
|
15
|
+
import { createMethodScope } from "../../scopes/factories.js";
|
|
16
|
+
import { createMethodSymbol } from "../../symbols/factories.js";
|
|
21
17
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
22
18
|
import { DocWhen } from "../doc/comment.jsx";
|
|
23
19
|
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
@@ -79,19 +75,11 @@ export interface InterfaceMethodProps
|
|
|
79
75
|
|
|
80
76
|
// a C# interface method
|
|
81
77
|
export function InterfaceMethod(props: InterfaceMethodProps) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
const scope = useCSharpMemberScope(["interface-decl"]);
|
|
85
|
-
|
|
86
|
-
const methodSymbol = new CSharpOutputSymbol(name, {
|
|
87
|
-
scope,
|
|
88
|
-
refkeys: props.refkey ?? refkey(props.name),
|
|
78
|
+
const methodSymbol = createMethodSymbol(props.name, {
|
|
79
|
+
refkeys: props.refkey,
|
|
89
80
|
});
|
|
90
81
|
|
|
91
|
-
|
|
92
|
-
const methodScope = new CSharpMemberScope("method-decl", {
|
|
93
|
-
owner: methodSymbol,
|
|
94
|
-
});
|
|
82
|
+
const methodScope = createMethodScope();
|
|
95
83
|
|
|
96
84
|
const modifiers = computeModifiersPrefix([
|
|
97
85
|
getAccessModifier(props),
|
|
@@ -104,7 +92,7 @@ export function InterfaceMethod(props: InterfaceMethodProps) {
|
|
|
104
92
|
<DocWhen doc={props.doc} />
|
|
105
93
|
<AttributeList attributes={props.attributes} endline />
|
|
106
94
|
{modifiers}
|
|
107
|
-
{props.returns ?? "void"}
|
|
95
|
+
{props.returns ?? "void"} <MemberName />
|
|
108
96
|
{props.typeParameters && (
|
|
109
97
|
<TypeParameters parameters={props.typeParameters} />
|
|
110
98
|
)}
|
|
@@ -30,7 +30,7 @@ describe("modifiers", () => {
|
|
|
30
30
|
).toRenderTo(`
|
|
31
31
|
public interface TestInterface
|
|
32
32
|
{
|
|
33
|
-
|
|
33
|
+
${accessModifier} string TestProp { get; }
|
|
34
34
|
}
|
|
35
35
|
`);
|
|
36
36
|
},
|
|
@@ -51,7 +51,7 @@ describe("modifiers", () => {
|
|
|
51
51
|
).toRenderTo(`
|
|
52
52
|
public interface TestInterface
|
|
53
53
|
{
|
|
54
|
-
|
|
54
|
+
${methodModifier} string TestProp { get; }
|
|
55
55
|
}
|
|
56
56
|
`);
|
|
57
57
|
});
|
|
@@ -65,7 +65,7 @@ describe("modifiers", () => {
|
|
|
65
65
|
).toRenderTo(`
|
|
66
66
|
public interface TestInterface
|
|
67
67
|
{
|
|
68
|
-
|
|
68
|
+
public new string TestProp { get; }
|
|
69
69
|
}
|
|
70
70
|
`);
|
|
71
71
|
});
|
|
@@ -79,7 +79,7 @@ it("applies PascalCase naming policy", () => {
|
|
|
79
79
|
).toRenderTo(`
|
|
80
80
|
public interface TestInterface
|
|
81
81
|
{
|
|
82
|
-
|
|
82
|
+
string TestProp { get; }
|
|
83
83
|
}
|
|
84
84
|
`);
|
|
85
85
|
});
|
|
@@ -92,7 +92,7 @@ it("has getter only", () => {
|
|
|
92
92
|
).toRenderTo(`
|
|
93
93
|
public interface TestInterface
|
|
94
94
|
{
|
|
95
|
-
|
|
95
|
+
string TestProp { get; }
|
|
96
96
|
}
|
|
97
97
|
`);
|
|
98
98
|
});
|
|
@@ -105,7 +105,7 @@ it("has setter only", () => {
|
|
|
105
105
|
).toRenderTo(`
|
|
106
106
|
public interface TestInterface
|
|
107
107
|
{
|
|
108
|
-
|
|
108
|
+
string TestProp { set; }
|
|
109
109
|
}
|
|
110
110
|
`);
|
|
111
111
|
});
|
|
@@ -117,7 +117,7 @@ it("has getter and setter", () => {
|
|
|
117
117
|
).toRenderTo(`
|
|
118
118
|
public interface TestInterface
|
|
119
119
|
{
|
|
120
|
-
|
|
120
|
+
string TestProp { get; set; }
|
|
121
121
|
}
|
|
122
122
|
`);
|
|
123
123
|
});
|
|
@@ -138,8 +138,8 @@ it("specify doc comment", () => {
|
|
|
138
138
|
).toRenderTo(`
|
|
139
139
|
interface Test
|
|
140
140
|
{
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
/// This is a test
|
|
142
|
+
string Method { get; set; }
|
|
143
143
|
}
|
|
144
144
|
`);
|
|
145
145
|
});
|
|
@@ -158,8 +158,8 @@ it("specify attributes", () => {
|
|
|
158
158
|
).toRenderTo(`
|
|
159
159
|
public interface TestInterface
|
|
160
160
|
{
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
[Test]
|
|
162
|
+
int Test { get; set; }
|
|
163
163
|
}
|
|
164
164
|
`);
|
|
165
165
|
});
|
|
@@ -3,9 +3,8 @@ import {
|
|
|
3
3
|
Children,
|
|
4
4
|
List,
|
|
5
5
|
MemberDeclaration,
|
|
6
|
-
|
|
6
|
+
MemberName,
|
|
7
7
|
Refkey,
|
|
8
|
-
Scope,
|
|
9
8
|
} from "@alloy-js/core";
|
|
10
9
|
import {
|
|
11
10
|
AccessModifiers,
|
|
@@ -13,12 +12,7 @@ import {
|
|
|
13
12
|
getAccessModifier,
|
|
14
13
|
makeModifiers,
|
|
15
14
|
} from "../../modifiers.js";
|
|
16
|
-
import {
|
|
17
|
-
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
18
|
-
import {
|
|
19
|
-
CSharpMemberScope,
|
|
20
|
-
useCSharpMemberScope,
|
|
21
|
-
} from "../../symbols/scopes.js";
|
|
15
|
+
import { createPropertySymbol } from "../../symbols/factories.js";
|
|
22
16
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
23
17
|
import { DocWhen } from "../doc/comment.jsx";
|
|
24
18
|
|
|
@@ -87,18 +81,8 @@ export interface InterfacePropertyProps
|
|
|
87
81
|
* ```
|
|
88
82
|
*/
|
|
89
83
|
export function InterfaceProperty(props: InterfacePropertyProps) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const scope = useCSharpMemberScope(["interface-decl"]);
|
|
93
|
-
|
|
94
|
-
const propertySymbol = new CSharpOutputSymbol(name, {
|
|
95
|
-
scope,
|
|
96
|
-
refkeys: props.refkey ?? refkey(props.name),
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// scope for property declaration
|
|
100
|
-
const propertyScope = new CSharpMemberScope("property-decl", {
|
|
101
|
-
owner: propertySymbol,
|
|
84
|
+
const propertySymbol = createPropertySymbol(props.name, {
|
|
85
|
+
refkeys: props.refkey,
|
|
102
86
|
});
|
|
103
87
|
|
|
104
88
|
const modifiers = computeModifiersPrefix([
|
|
@@ -108,19 +92,17 @@ export function InterfaceProperty(props: InterfacePropertyProps) {
|
|
|
108
92
|
// note that scope wraps the method decl so that the params get the correct scope
|
|
109
93
|
return (
|
|
110
94
|
<MemberDeclaration symbol={propertySymbol}>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
</Block>
|
|
123
|
-
</Scope>
|
|
95
|
+
<DocWhen doc={props.doc} />
|
|
96
|
+
<AttributeList attributes={props.attributes} endline />
|
|
97
|
+
{modifiers}
|
|
98
|
+
{props.type}
|
|
99
|
+
{props.nullable && "?"} <MemberName />{" "}
|
|
100
|
+
<Block newline inline>
|
|
101
|
+
<List joiner=" ">
|
|
102
|
+
{props.get && "get;"}
|
|
103
|
+
{props.set && "set;"}
|
|
104
|
+
</List>
|
|
105
|
+
</Block>
|
|
124
106
|
</MemberDeclaration>
|
|
125
107
|
);
|
|
126
108
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Scope, ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
|
|
2
|
+
import { useCSharpScope } from "../scopes/contexts.js";
|
|
3
|
+
import { CSharpLexicalScope } from "../scopes/lexical.js";
|
|
4
|
+
|
|
5
|
+
export interface LexicalScopePropsWithScopeValue extends ScopePropsWithValue {}
|
|
6
|
+
export interface LeixcalScopePropsWithScopeInfo extends ScopePropsWithInfo {}
|
|
7
|
+
|
|
8
|
+
export type LexicalScopeProps =
|
|
9
|
+
| LexicalScopePropsWithScopeValue
|
|
10
|
+
| LeixcalScopePropsWithScopeInfo;
|
|
11
|
+
|
|
12
|
+
export function LexicalScope(props: LexicalScopeProps) {
|
|
13
|
+
let scope;
|
|
14
|
+
if ("value" in props) {
|
|
15
|
+
if (!(props.value instanceof CSharpLexicalScope)) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"LexicalScope value must be a CSharpLexicalScope instance",
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
scope = props.value;
|
|
21
|
+
} else {
|
|
22
|
+
const parentScope = useCSharpScope();
|
|
23
|
+
scope = new CSharpLexicalScope(props.name ?? "lexical scope", parentScope, {
|
|
24
|
+
...props,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return <Scope value={scope}>{props.children}</Scope>;
|
|
29
|
+
}
|
|
@@ -23,7 +23,7 @@ describe("modifiers", () => {
|
|
|
23
23
|
).toRenderTo(`
|
|
24
24
|
public class TestClass
|
|
25
25
|
{
|
|
26
|
-
|
|
26
|
+
${accessModifier} void MethodOne() {}
|
|
27
27
|
}
|
|
28
28
|
`);
|
|
29
29
|
},
|
|
@@ -41,7 +41,7 @@ describe("modifiers", () => {
|
|
|
41
41
|
).toRenderTo(`
|
|
42
42
|
public class TestClass
|
|
43
43
|
{
|
|
44
|
-
|
|
44
|
+
${methodModifier} void MethodOne() {}
|
|
45
45
|
}
|
|
46
46
|
`);
|
|
47
47
|
},
|
|
@@ -55,7 +55,7 @@ describe("modifiers", () => {
|
|
|
55
55
|
).toRenderTo(`
|
|
56
56
|
public class TestClass
|
|
57
57
|
{
|
|
58
|
-
|
|
58
|
+
abstract void MethodOne();
|
|
59
59
|
}
|
|
60
60
|
`);
|
|
61
61
|
});
|
|
@@ -69,7 +69,7 @@ describe("modifiers", () => {
|
|
|
69
69
|
).toRenderTo(`
|
|
70
70
|
public class TestClass
|
|
71
71
|
{
|
|
72
|
-
|
|
72
|
+
async Task MethodOne() {}
|
|
73
73
|
}
|
|
74
74
|
`);
|
|
75
75
|
});
|
|
@@ -82,7 +82,7 @@ describe("modifiers", () => {
|
|
|
82
82
|
).toRenderTo(`
|
|
83
83
|
public class TestClass
|
|
84
84
|
{
|
|
85
|
-
|
|
85
|
+
public abstract async Task MethodOne();
|
|
86
86
|
}
|
|
87
87
|
`);
|
|
88
88
|
});
|
|
@@ -96,7 +96,7 @@ it("applies PascalCase naming policy", () => {
|
|
|
96
96
|
).toRenderTo(`
|
|
97
97
|
public class TestClass
|
|
98
98
|
{
|
|
99
|
-
|
|
99
|
+
void MethodOne() {}
|
|
100
100
|
}
|
|
101
101
|
`);
|
|
102
102
|
});
|
|
@@ -120,7 +120,7 @@ it("defines params and return type", () => {
|
|
|
120
120
|
expect(res).toRenderTo(`
|
|
121
121
|
public class TestClass
|
|
122
122
|
{
|
|
123
|
-
|
|
123
|
+
public string MethodOne(int intParam, string stringParam) {}
|
|
124
124
|
}
|
|
125
125
|
`);
|
|
126
126
|
});
|
|
@@ -135,8 +135,8 @@ it("specify doc comment", () => {
|
|
|
135
135
|
).toRenderTo(`
|
|
136
136
|
class Test
|
|
137
137
|
{
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
/// This is a test
|
|
139
|
+
void Method() {}
|
|
140
140
|
}
|
|
141
141
|
`);
|
|
142
142
|
});
|
|
@@ -153,8 +153,8 @@ it("use expression body form", () => {
|
|
|
153
153
|
).toRenderTo(`
|
|
154
154
|
class Test
|
|
155
155
|
{
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
/// This is a test
|
|
157
|
+
void Method() => this.MyProperty.Value;
|
|
158
158
|
}
|
|
159
159
|
`);
|
|
160
160
|
});
|
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
Block,
|
|
3
3
|
Children,
|
|
4
4
|
MemberDeclaration,
|
|
5
|
-
|
|
5
|
+
MemberName,
|
|
6
|
+
Namekey,
|
|
6
7
|
Refkey,
|
|
7
8
|
Scope,
|
|
8
9
|
} from "@alloy-js/core";
|
|
@@ -13,12 +14,8 @@ import {
|
|
|
13
14
|
getAsyncModifier,
|
|
14
15
|
makeModifiers,
|
|
15
16
|
} from "../../modifiers.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
CSharpMemberScope,
|
|
20
|
-
useCSharpMemberScope,
|
|
21
|
-
} from "../../symbols/scopes.js";
|
|
17
|
+
import { createMethodScope } from "../../scopes/factories.js";
|
|
18
|
+
import { createMethodSymbol } from "../../symbols/factories.js";
|
|
22
19
|
import { AttributeList, AttributesProp } from "../attributes/attributes.jsx";
|
|
23
20
|
import { DocWhen } from "../doc/comment.jsx";
|
|
24
21
|
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
@@ -49,9 +46,12 @@ const getMethodModifier = makeModifiers<MethodModifiers>([
|
|
|
49
46
|
|
|
50
47
|
// properties for creating a method
|
|
51
48
|
export interface MethodProps extends AccessModifiers, MethodModifiers {
|
|
52
|
-
name: string;
|
|
49
|
+
name: string | Namekey;
|
|
53
50
|
refkey?: Refkey;
|
|
54
51
|
children?: Children;
|
|
52
|
+
/**
|
|
53
|
+
* An array of parameter descriptors.
|
|
54
|
+
*/
|
|
55
55
|
parameters?: Array<ParameterProps>;
|
|
56
56
|
returns?: Children;
|
|
57
57
|
|
|
@@ -113,18 +113,12 @@ export interface MethodProps extends AccessModifiers, MethodModifiers {
|
|
|
113
113
|
|
|
114
114
|
// a C# class method
|
|
115
115
|
export function Method(props: MethodProps) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const methodSymbol = new CSharpOutputSymbol(name, {
|
|
120
|
-
scope,
|
|
121
|
-
refkeys: props.refkey ?? refkey(props.name),
|
|
116
|
+
const methodSymbol = createMethodSymbol(props.name, {
|
|
117
|
+
refkeys: props.refkey,
|
|
122
118
|
});
|
|
123
119
|
|
|
124
120
|
// scope for method declaration
|
|
125
|
-
const methodScope =
|
|
126
|
-
owner: methodSymbol,
|
|
127
|
-
});
|
|
121
|
+
const methodScope = createMethodScope();
|
|
128
122
|
|
|
129
123
|
const returns = props.returns ?? (props.async ? "Task" : "void");
|
|
130
124
|
|
|
@@ -140,7 +134,7 @@ export function Method(props: MethodProps) {
|
|
|
140
134
|
<DocWhen doc={props.doc} />
|
|
141
135
|
<AttributeList attributes={props.attributes} endline />
|
|
142
136
|
{modifiers}
|
|
143
|
-
{returns}
|
|
137
|
+
{returns} <MemberName />
|
|
144
138
|
{props.typeParameters && (
|
|
145
139
|
<TypeParameters parameters={props.typeParameters} />
|
|
146
140
|
)}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Scope, ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
|
|
2
|
+
import { useCSharpScope } from "../scopes/contexts.js";
|
|
3
|
+
import { CSharpMethodScope } from "../scopes/method.js";
|
|
4
|
+
|
|
5
|
+
export interface MethodScopePropsWithScopeValue extends ScopePropsWithValue {}
|
|
6
|
+
export interface MethodScopePropsWithScopeInfo extends ScopePropsWithInfo {}
|
|
7
|
+
|
|
8
|
+
export type MethodScopeProps =
|
|
9
|
+
| MethodScopePropsWithScopeValue
|
|
10
|
+
| MethodScopePropsWithScopeInfo;
|
|
11
|
+
|
|
12
|
+
export function MethodScope(props: MethodScopeProps) {
|
|
13
|
+
let scope;
|
|
14
|
+
if ("value" in props) {
|
|
15
|
+
if (!(props.value instanceof CSharpMethodScope)) {
|
|
16
|
+
throw new Error("MethodScope value must be a CSharpMethodScope instance");
|
|
17
|
+
}
|
|
18
|
+
scope = props.value;
|
|
19
|
+
} else {
|
|
20
|
+
const parentScope = useCSharpScope();
|
|
21
|
+
scope = new CSharpMethodScope(props.name ?? "method scope", parentScope, {
|
|
22
|
+
...props,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return <Scope value={scope}>{props.children}</Scope>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Scope } from "@alloy-js/core";
|
|
2
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { NamespaceContext } from "../contexts/namespace.js";
|
|
4
|
+
import { createCSharpNamespaceScope } from "../scopes/namespace.js";
|
|
5
|
+
import { NamespaceSymbol } from "../symbols/namespace.js";
|
|
6
|
+
|
|
7
|
+
export interface NamespaceScopProps {
|
|
8
|
+
symbol: NamespaceSymbol;
|
|
9
|
+
children: Children;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function NamespaceScope(props: NamespaceScopProps) {
|
|
13
|
+
const scope = createCSharpNamespaceScope(props.symbol);
|
|
14
|
+
return (
|
|
15
|
+
<NamespaceContext.Provider value={{ symbol: props.symbol }}>
|
|
16
|
+
<Scope value={scope}>{props.children}</Scope>
|
|
17
|
+
</NamespaceContext.Provider>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface NamespaceScopesProps {
|
|
22
|
+
symbol: NamespaceSymbol;
|
|
23
|
+
children: Children;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function NamespaceScopes(props: NamespaceScopesProps) {
|
|
27
|
+
function wrapWithScope(symbol: NamespaceSymbol, children: Children) {
|
|
28
|
+
const scopeChildren = (
|
|
29
|
+
<NamespaceScope symbol={symbol}>{children}</NamespaceScope>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (symbol.enclosingNamespace) {
|
|
33
|
+
return wrapWithScope(symbol.enclosingNamespace, scopeChildren);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return scopeChildren;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<NamespaceContext.Provider value={{ symbol: props.symbol }}>
|
|
41
|
+
{wrapWithScope(props.symbol, props.children)}
|
|
42
|
+
</NamespaceContext.Provider>
|
|
43
|
+
);
|
|
44
|
+
}
|