@alloy-js/csharp 0.20.0-dev.2 → 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 +19 -33
- package/dist/src/components/class/declaration.test.js +192 -193
- package/dist/src/components/constructor/constructor.d.ts.map +1 -1
- package/dist/src/components/constructor/constructor.js +11 -19
- 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 -17
- 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 -18
- 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 -39
- 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 -16
- 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 -14
- 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 -39
- package/dist/src/components/property/property.test.js +14 -14
- package/dist/src/components/record/declaration.d.ts +18 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -1
- package/dist/src/components/record/declaration.js +19 -13
- package/dist/src/components/record/declaration.test.js +50 -3
- 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 +8 -4
- 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 +138 -143
- package/src/components/class/declaration.tsx +20 -33
- package/src/components/constructor/constructor.test.tsx +10 -16
- package/src/components/constructor/constructor.tsx +13 -32
- 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 -22
- 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 -20
- package/src/components/interface/property.test.tsx +11 -11
- package/src/components/interface/property.tsx +15 -34
- package/src/components/lexical-scope.tsx +29 -0
- package/src/components/method/method.test.tsx +11 -11
- package/src/components/method/method.tsx +12 -23
- 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 -21
- package/src/components/property/property.test.tsx +14 -14
- package/src/components/property/property.tsx +17 -41
- package/src/components/record/declaration.test.tsx +47 -3
- package/src/components/record/declaration.tsx +34 -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 +6152 -2151
- 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/tsdoc-metadata.json +1 -1
- package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
- package/dist/src/components/EnumDeclaration.js +0 -85
- 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 -14
- package/dist/src/symbols/scopes.d.ts.map +0 -1
- package/dist/src/symbols/scopes.js +0 -31
- 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 -99
- package/src/components/Namespace.tsx +0 -35
- package/src/symbols/csharp-output-symbol.ts +0 -22
- package/src/symbols/scopes.ts +0 -41
- 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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Block, Declaration, MemberScope } from "@alloy-js/core";
|
|
3
|
+
import { computeModifiersPrefix, getAccessModifier } from "../../modifiers.js";
|
|
4
|
+
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
|
+
import { createNamedTypeScope } from "../../scopes/factories.js";
|
|
6
|
+
import { createNamedTypeSymbol } from "../../symbols/factories.js";
|
|
7
|
+
import { Name } from "../Name.js";
|
|
8
|
+
|
|
9
|
+
// properties for creating an enum
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A C# enum declaration
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <EnumDeclaration public name="Color">
|
|
16
|
+
* <EnumMember name="Red" />
|
|
17
|
+
* <EnumMember name="Green" />
|
|
18
|
+
* <EnumMember name="Blue" />
|
|
19
|
+
* </EnumDeclaration>
|
|
20
|
+
* ```
|
|
21
|
+
* This will produce:
|
|
22
|
+
* ```csharp
|
|
23
|
+
* public enum Color
|
|
24
|
+
* {
|
|
25
|
+
* Red,
|
|
26
|
+
* Green,
|
|
27
|
+
* Blue
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function EnumDeclaration(props) {
|
|
32
|
+
const name = useCSharpNamePolicy().getName(props.name, "enum");
|
|
33
|
+
const symbol = createNamedTypeSymbol(name, "enum", {
|
|
34
|
+
refkeys: props.refkey
|
|
35
|
+
});
|
|
36
|
+
const scope = createNamedTypeScope(symbol);
|
|
37
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
38
|
+
return _$createComponent(Declaration, {
|
|
39
|
+
symbol: symbol,
|
|
40
|
+
get children() {
|
|
41
|
+
return [modifiers, "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(MemberScope, {
|
|
42
|
+
value: scope,
|
|
43
|
+
get children() {
|
|
44
|
+
return _$createComponent(Block, {
|
|
45
|
+
newline: true,
|
|
46
|
+
get children() {
|
|
47
|
+
return props.children;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}))];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.ref.test.d.ts","sourceRoot":"","sources":["../../../../src/components/enum/declaration.ref.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Namespace } from "#components/namespace.js";
|
|
3
|
+
import { SourceFile } from "#components/SourceFile.js";
|
|
4
|
+
import { Output, refkey } from "@alloy-js/core";
|
|
5
|
+
import { d } from "@alloy-js/core/testing";
|
|
6
|
+
import { expect, it } from "vitest";
|
|
7
|
+
import { EnumDeclaration } from "./declaration.js";
|
|
8
|
+
import { EnumMember } from "./member.js";
|
|
9
|
+
it("can reference things by refkey", () => {
|
|
10
|
+
const enumRK = refkey();
|
|
11
|
+
const twoRK = refkey();
|
|
12
|
+
const tree = _$createComponent(Output, {
|
|
13
|
+
get children() {
|
|
14
|
+
return _$createComponent(Namespace, {
|
|
15
|
+
name: "TestCode",
|
|
16
|
+
get children() {
|
|
17
|
+
return _$createComponent(SourceFile, {
|
|
18
|
+
path: "Test.cs",
|
|
19
|
+
get children() {
|
|
20
|
+
return [_$createComponent(EnumDeclaration, {
|
|
21
|
+
"public": true,
|
|
22
|
+
name: "TestEnum",
|
|
23
|
+
refkey: enumRK,
|
|
24
|
+
get children() {
|
|
25
|
+
return [_$createComponent(EnumMember, {
|
|
26
|
+
name: "One"
|
|
27
|
+
}), ",", _$createIntrinsic("hbr", {}), _$createComponent(EnumMember, {
|
|
28
|
+
name: "Two",
|
|
29
|
+
refkey: twoRK
|
|
30
|
+
})];
|
|
31
|
+
}
|
|
32
|
+
}), _$createIntrinsic("hbr", {}), enumRK, ";", _$createIntrinsic("hbr", {}), twoRK, ";"];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
expect(tree).toRenderTo(d`
|
|
40
|
+
namespace TestCode;
|
|
41
|
+
|
|
42
|
+
public enum TestEnum
|
|
43
|
+
{
|
|
44
|
+
One,
|
|
45
|
+
Two
|
|
46
|
+
}
|
|
47
|
+
TestEnum;
|
|
48
|
+
TestEnum.Two;
|
|
49
|
+
`);
|
|
50
|
+
});
|
|
51
|
+
it("can reference things by refkey across files", () => {
|
|
52
|
+
const enumRK = refkey();
|
|
53
|
+
const barRK = refkey();
|
|
54
|
+
const tree = _$createComponent(Output, {
|
|
55
|
+
get children() {
|
|
56
|
+
return _$createComponent(Namespace, {
|
|
57
|
+
name: "TestCode",
|
|
58
|
+
get children() {
|
|
59
|
+
return [_$createComponent(SourceFile, {
|
|
60
|
+
path: "Test.cs",
|
|
61
|
+
get children() {
|
|
62
|
+
return [_$createComponent(EnumDeclaration, {
|
|
63
|
+
"public": true,
|
|
64
|
+
name: "TestEnum",
|
|
65
|
+
get children() {
|
|
66
|
+
return [_$createComponent(EnumMember, {
|
|
67
|
+
name: "One"
|
|
68
|
+
}), ",", _$createIntrinsic("hbr", {}), _$createComponent(EnumMember, {
|
|
69
|
+
name: "Two"
|
|
70
|
+
})];
|
|
71
|
+
}
|
|
72
|
+
}), _$createIntrinsic("hbr", {}), enumRK, ";", _$createIntrinsic("hbr", {}), barRK, ";"];
|
|
73
|
+
}
|
|
74
|
+
}), _$createComponent(SourceFile, {
|
|
75
|
+
path: "Other.cs",
|
|
76
|
+
get children() {
|
|
77
|
+
return [_$createComponent(EnumDeclaration, {
|
|
78
|
+
"public": true,
|
|
79
|
+
name: "OtherEnum",
|
|
80
|
+
refkey: enumRK,
|
|
81
|
+
get children() {
|
|
82
|
+
return [_$createComponent(EnumMember, {
|
|
83
|
+
name: "Foo"
|
|
84
|
+
}), ",", _$createIntrinsic("hbr", {}), _$createComponent(EnumMember, {
|
|
85
|
+
name: "Bar",
|
|
86
|
+
refkey: barRK
|
|
87
|
+
})];
|
|
88
|
+
}
|
|
89
|
+
}), _$createIntrinsic("hbr", {}), enumRK, ";", _$createIntrinsic("hbr", {}), barRK, ";"];
|
|
90
|
+
}
|
|
91
|
+
})];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
expect(tree).toRenderTo({
|
|
97
|
+
"Test.cs": d`
|
|
98
|
+
namespace TestCode;
|
|
99
|
+
|
|
100
|
+
public enum TestEnum
|
|
101
|
+
{
|
|
102
|
+
One,
|
|
103
|
+
Two
|
|
104
|
+
}
|
|
105
|
+
OtherEnum;
|
|
106
|
+
OtherEnum.Bar;
|
|
107
|
+
`,
|
|
108
|
+
"Other.cs": d`
|
|
109
|
+
namespace TestCode;
|
|
110
|
+
|
|
111
|
+
public enum OtherEnum
|
|
112
|
+
{
|
|
113
|
+
Foo,
|
|
114
|
+
Bar
|
|
115
|
+
}
|
|
116
|
+
OtherEnum;
|
|
117
|
+
OtherEnum.Bar;
|
|
118
|
+
`
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.test.d.ts","sourceRoot":"","sources":["../../../../src/components/enum/declaration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { toSourceText } from "#test/utils.js";
|
|
3
|
+
import { d } from "@alloy-js/core/testing";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { EnumDeclaration } from "./declaration.js";
|
|
6
|
+
import { EnumMember } from "./member.js";
|
|
7
|
+
it("declares enum with no members", () => {
|
|
8
|
+
const res = toSourceText(_$createComponent(EnumDeclaration, {
|
|
9
|
+
"public": true,
|
|
10
|
+
name: "TestEnum"
|
|
11
|
+
}));
|
|
12
|
+
expect(res).toBe(d`
|
|
13
|
+
namespace TestCode;
|
|
14
|
+
|
|
15
|
+
public enum TestEnum;
|
|
16
|
+
`);
|
|
17
|
+
});
|
|
18
|
+
it("applies naming policy to enum and members", () => {
|
|
19
|
+
const res = toSourceText(_$createComponent(EnumDeclaration, {
|
|
20
|
+
"public": true,
|
|
21
|
+
name: "testEnum",
|
|
22
|
+
get children() {
|
|
23
|
+
return [_$createComponent(EnumMember, {
|
|
24
|
+
name: "one"
|
|
25
|
+
}), ",", _$createIntrinsic("hbr", {}), _$createComponent(EnumMember, {
|
|
26
|
+
name: "two"
|
|
27
|
+
})];
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
expect(res).toBe(d`
|
|
31
|
+
namespace TestCode;
|
|
32
|
+
|
|
33
|
+
public enum TestEnum
|
|
34
|
+
{
|
|
35
|
+
One,
|
|
36
|
+
Two
|
|
37
|
+
}
|
|
38
|
+
`);
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../../../../src/components/enum/member.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAMvE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,qCAuBhD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { MemberDeclaration, MemberName } from "@alloy-js/core";
|
|
3
|
+
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
4
|
+
import { useNamedTypeScope } from "../../scopes/contexts.js";
|
|
5
|
+
import { CSharpSymbol } from "../../symbols/csharp.js";
|
|
6
|
+
|
|
7
|
+
// properties for creating a C# enum member
|
|
8
|
+
|
|
9
|
+
// a member within a C# enum
|
|
10
|
+
export function EnumMember(props) {
|
|
11
|
+
const scope = useNamedTypeScope();
|
|
12
|
+
if (!scope) {
|
|
13
|
+
throw new Error("EnumMember must be used within an EnumDeclaration.");
|
|
14
|
+
}
|
|
15
|
+
const symbol = scope.ownerSymbol;
|
|
16
|
+
if (symbol.typeKind !== "enum") {
|
|
17
|
+
throw new Error("EnumMember must be used within an EnumDeclaration.");
|
|
18
|
+
}
|
|
19
|
+
const name = useCSharpNamePolicy().getName(props.name, "enum-member");
|
|
20
|
+
const thisEnumValueSymbol = new CSharpSymbol(name, symbol.members, {
|
|
21
|
+
refkeys: props.refkey
|
|
22
|
+
});
|
|
23
|
+
return _$createComponent(MemberDeclaration, {
|
|
24
|
+
symbol: thisEnumValueSymbol,
|
|
25
|
+
get children() {
|
|
26
|
+
return _$createComponent(MemberName, {});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"member.test.d.ts","sourceRoot":"","sources":["../../../../src/components/enum/member.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { toSourceText } from "#test/utils.js";
|
|
3
|
+
import { d } from "@alloy-js/core/testing";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { EnumDeclaration } from "./declaration.js";
|
|
6
|
+
import { EnumMember } from "./member.js";
|
|
7
|
+
it("declares enum with members", () => {
|
|
8
|
+
const res = toSourceText(_$createComponent(EnumDeclaration, {
|
|
9
|
+
"public": true,
|
|
10
|
+
name: "TestEnum",
|
|
11
|
+
get children() {
|
|
12
|
+
return [_$createComponent(EnumMember, {
|
|
13
|
+
name: "One"
|
|
14
|
+
}), ",", _$createIntrinsic("hbr", {}), _$createComponent(EnumMember, {
|
|
15
|
+
name: "Two"
|
|
16
|
+
})];
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
expect(res).toBe(d`
|
|
20
|
+
namespace TestCode;
|
|
21
|
+
|
|
22
|
+
public enum TestEnum
|
|
23
|
+
{
|
|
24
|
+
One,
|
|
25
|
+
Two
|
|
26
|
+
}
|
|
27
|
+
`);
|
|
28
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/components/field/field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/components/field/field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAQ5B,uBAAuB;AACvB,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AASD,MAAM,WAAW,UAAW,SAAQ,eAAe,EAAE,cAAc;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAwB;AACxB,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,YAqBtC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Declaration, Name
|
|
2
|
+
import { Declaration, Name } from "@alloy-js/core";
|
|
3
3
|
import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../modifiers.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { useCSharpScope } from "../../symbols/scopes.js";
|
|
4
|
+
import { accessibilityFromProps, nonAccessibilityFromProps } from "../../symbols/csharp.js";
|
|
5
|
+
import { createFieldSymbol } from "../../symbols/factories.js";
|
|
7
6
|
import { DocWhen } from "../doc/comment.js";
|
|
8
7
|
|
|
9
8
|
/** Field modifiers. */
|
|
@@ -11,19 +10,12 @@ import { DocWhen } from "../doc/comment.js";
|
|
|
11
10
|
const getModifiers = makeModifiers(["new", "static", "readonly", "volatile"]);
|
|
12
11
|
/** Render a c# field */
|
|
13
12
|
export function Field(props) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
if (scope.kind !== "member" || scope.name !== "class-decl" && scope.name !== "struct-decl") {
|
|
21
|
-
throw new Error("can't define a class member outside of a class or struct scope");
|
|
22
|
-
}
|
|
23
|
-
const memberSymbol = new CSharpOutputSymbol(name, {
|
|
24
|
-
scope,
|
|
25
|
-
refkeys: props.refkey ?? refkey(props.name)
|
|
26
|
-
});
|
|
13
|
+
const options = {
|
|
14
|
+
accessibility: accessibilityFromProps(props),
|
|
15
|
+
refkeys: props.refkey,
|
|
16
|
+
...nonAccessibilityFromProps(props)
|
|
17
|
+
};
|
|
18
|
+
const memberSymbol = createFieldSymbol(props.name, options);
|
|
27
19
|
const modifiers = computeModifiersPrefix([getAccessModifier(props), getModifiers(props)]);
|
|
28
20
|
return _$createComponent(Declaration, {
|
|
29
21
|
symbol: memberSymbol,
|
|
@@ -37,8 +37,8 @@ it("declares multiple fields", () => {
|
|
|
37
37
|
})).toRenderTo(`
|
|
38
38
|
public class TestClass
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
public string MemberOne;
|
|
41
|
+
public int MemberTwo;
|
|
42
42
|
}
|
|
43
43
|
`);
|
|
44
44
|
});
|
|
@@ -57,7 +57,7 @@ describe("modifiers", () => {
|
|
|
57
57
|
})).toRenderTo(`
|
|
58
58
|
public class TestClass
|
|
59
59
|
{
|
|
60
|
-
|
|
60
|
+
${accessModifier} string ${accessModifier === "private" ? "_testProp" : "TestProp"};
|
|
61
61
|
}
|
|
62
62
|
`);
|
|
63
63
|
});
|
|
@@ -76,7 +76,7 @@ describe("modifiers", () => {
|
|
|
76
76
|
})).toRenderTo(`
|
|
77
77
|
public class TestClass
|
|
78
78
|
{
|
|
79
|
-
|
|
79
|
+
${methodModifier} string _testField;
|
|
80
80
|
}
|
|
81
81
|
`);
|
|
82
82
|
});
|
|
@@ -94,7 +94,7 @@ describe("modifiers", () => {
|
|
|
94
94
|
})).toRenderTo(`
|
|
95
95
|
public class TestClass
|
|
96
96
|
{
|
|
97
|
-
|
|
97
|
+
public new string TestField;
|
|
98
98
|
}
|
|
99
99
|
`);
|
|
100
100
|
});
|
|
@@ -116,7 +116,7 @@ describe("naming", () => {
|
|
|
116
116
|
})).toRenderTo(`
|
|
117
117
|
public class TestClass
|
|
118
118
|
{
|
|
119
|
-
|
|
119
|
+
public string MemberOne;
|
|
120
120
|
}
|
|
121
121
|
`);
|
|
122
122
|
});
|
|
@@ -136,7 +136,7 @@ describe("naming", () => {
|
|
|
136
136
|
})).toRenderTo(`
|
|
137
137
|
public class TestClass
|
|
138
138
|
{
|
|
139
|
-
|
|
139
|
+
private string _memberOne;
|
|
140
140
|
}
|
|
141
141
|
`);
|
|
142
142
|
});
|
|
@@ -4,14 +4,17 @@ export * from "./constructor/constructor.jsx";
|
|
|
4
4
|
export * from "./Declaration.js";
|
|
5
5
|
export * from "./doc/comment.jsx";
|
|
6
6
|
export * from "./doc/from-markdown.jsx";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./enum/declaration.jsx";
|
|
8
|
+
export * from "./enum/member.jsx";
|
|
8
9
|
export * from "./field/field.jsx";
|
|
9
10
|
export * from "./interface/declaration.js";
|
|
10
11
|
export * from "./interface/method.js";
|
|
11
12
|
export * from "./interface/property.js";
|
|
13
|
+
export * from "./lexical-scope.jsx";
|
|
14
|
+
export * from "./method-scope.jsx";
|
|
12
15
|
export * from "./method/method.jsx";
|
|
13
16
|
export * from "./Name.js";
|
|
14
|
-
export * from "./
|
|
17
|
+
export * from "./namespace.js";
|
|
15
18
|
export * from "./parameters/parameters.jsx";
|
|
16
19
|
export * from "./ProjectDirectory.js";
|
|
17
20
|
export * from "./property/property.jsx";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
@@ -4,14 +4,17 @@ export * from "./constructor/constructor.js";
|
|
|
4
4
|
export * from "./Declaration.js";
|
|
5
5
|
export * from "./doc/comment.js";
|
|
6
6
|
export * from "./doc/from-markdown.js";
|
|
7
|
-
export * from "./
|
|
7
|
+
export * from "./enum/declaration.js";
|
|
8
|
+
export * from "./enum/member.js";
|
|
8
9
|
export * from "./field/field.js";
|
|
9
10
|
export * from "./interface/declaration.js";
|
|
10
11
|
export * from "./interface/method.js";
|
|
11
12
|
export * from "./interface/property.js";
|
|
13
|
+
export * from "./lexical-scope.js";
|
|
14
|
+
export * from "./method-scope.js";
|
|
12
15
|
export * from "./method/method.js";
|
|
13
16
|
export * from "./Name.js";
|
|
14
|
-
export * from "./
|
|
17
|
+
export * from "./namespace.js";
|
|
15
18
|
export * from "./parameters/parameters.js";
|
|
16
19
|
export * from "./ProjectDirectory.js";
|
|
17
20
|
export * from "./property/property.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD,MAAM,WAAW,yBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,kBAAkB;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD,MAAM,WAAW,yBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,kBAAkB;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,iBAmCpE"}
|
|
@@ -2,8 +2,8 @@ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/
|
|
|
2
2
|
import * as core from "@alloy-js/core";
|
|
3
3
|
import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../modifiers.js";
|
|
4
4
|
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { createNamedTypeScope } from "../../scopes/factories.js";
|
|
6
|
+
import { createNamedTypeSymbol } from "../../symbols/factories.js";
|
|
7
7
|
import { AttributeList } from "../attributes/attributes.js";
|
|
8
8
|
import { DocWhen } from "../doc/comment.js";
|
|
9
9
|
import { Name } from "../Name.js";
|
|
@@ -35,7 +35,7 @@ const getInterfaceModifiers = makeModifiers(["partial"]);
|
|
|
35
35
|
*/
|
|
36
36
|
export function InterfaceDeclaration(props) {
|
|
37
37
|
const name = useCSharpNamePolicy().getName(props.name, "interface");
|
|
38
|
-
const
|
|
38
|
+
const symbol = createNamedTypeSymbol(name, "interface", {
|
|
39
39
|
refkeys: props.refkey
|
|
40
40
|
});
|
|
41
41
|
|
|
@@ -43,12 +43,10 @@ export function InterfaceDeclaration(props) {
|
|
|
43
43
|
// members will automatically "inherit" this scope so
|
|
44
44
|
// that refkeys to them will produce the fully-qualified
|
|
45
45
|
// name e.g. Foo.Bar.
|
|
46
|
-
const thisInterfaceScope =
|
|
47
|
-
owner: thisInterfaceSymbol
|
|
48
|
-
});
|
|
46
|
+
const thisInterfaceScope = createNamedTypeScope(symbol);
|
|
49
47
|
const modifiers = computeModifiersPrefix([getAccessModifier(props), getInterfaceModifiers(props)]);
|
|
50
48
|
return _$createComponent(core.Declaration, {
|
|
51
|
-
symbol:
|
|
49
|
+
symbol: symbol,
|
|
52
50
|
get children() {
|
|
53
51
|
return [_$createComponent(DocWhen, {
|
|
54
52
|
get doc() {
|
|
@@ -59,25 +57,25 @@ export function InterfaceDeclaration(props) {
|
|
|
59
57
|
return props.attributes;
|
|
60
58
|
},
|
|
61
59
|
endline: true
|
|
62
|
-
}), modifiers, "interface ", _$createComponent(Name, {}), _$
|
|
63
|
-
|
|
64
|
-
return props.typeParameters;
|
|
65
|
-
}
|
|
66
|
-
})), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
67
|
-
get parameters() {
|
|
68
|
-
return props.typeParameters;
|
|
69
|
-
}
|
|
70
|
-
})), _$memo(() => _$memo(() => !!props.children)() ? _$createComponent(core.Block, {
|
|
71
|
-
newline: true,
|
|
60
|
+
}), modifiers, "interface ", _$createComponent(Name, {}), _$createComponent(core.Scope, {
|
|
61
|
+
value: thisInterfaceScope,
|
|
72
62
|
get children() {
|
|
73
|
-
return _$createComponent(
|
|
74
|
-
|
|
63
|
+
return [_$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
|
|
64
|
+
get parameters() {
|
|
65
|
+
return props.typeParameters;
|
|
66
|
+
}
|
|
67
|
+
})), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
68
|
+
get parameters() {
|
|
69
|
+
return props.typeParameters;
|
|
70
|
+
}
|
|
71
|
+
})), _$memo(() => _$memo(() => !!props.children)() ? _$createComponent(core.Block, {
|
|
72
|
+
newline: true,
|
|
75
73
|
get children() {
|
|
76
74
|
return props.children;
|
|
77
75
|
}
|
|
78
|
-
});
|
|
76
|
+
}) : ";")];
|
|
79
77
|
}
|
|
80
|
-
})
|
|
78
|
+
})];
|
|
81
79
|
}
|
|
82
80
|
});
|
|
83
81
|
}
|
|
@@ -3,7 +3,6 @@ import { List, refkey } from "@alloy-js/core";
|
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import { TestNamespace } from "../../../test/utils.js";
|
|
5
5
|
import { Attribute } from "../attributes/attributes.js";
|
|
6
|
-
import { SourceFile } from "../SourceFile.js";
|
|
7
6
|
import { InterfaceDeclaration } from "./declaration.js";
|
|
8
7
|
import { InterfaceProperty } from "./property.js";
|
|
9
8
|
it("declares class with no members", () => {
|
|
@@ -82,46 +81,38 @@ describe("with type parameters", () => {
|
|
|
82
81
|
}];
|
|
83
82
|
expect(_$createComponent(TestNamespace, {
|
|
84
83
|
get children() {
|
|
85
|
-
return _$createComponent(
|
|
86
|
-
|
|
84
|
+
return _$createComponent(InterfaceDeclaration, {
|
|
85
|
+
"public": true,
|
|
86
|
+
name: "Test",
|
|
87
|
+
typeParameters: typeParameters,
|
|
87
88
|
get children() {
|
|
88
|
-
return _$createComponent(
|
|
89
|
-
"public": true,
|
|
90
|
-
name: "Test",
|
|
91
|
-
typeParameters: typeParameters,
|
|
89
|
+
return _$createComponent(List, {
|
|
92
90
|
get children() {
|
|
93
|
-
return _$createComponent(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
set: true
|
|
109
|
-
})];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
91
|
+
return [_$createComponent(InterfaceProperty, {
|
|
92
|
+
name: "PropA",
|
|
93
|
+
get type() {
|
|
94
|
+
return typeParameters[0].refkey;
|
|
95
|
+
},
|
|
96
|
+
get: true,
|
|
97
|
+
set: true
|
|
98
|
+
}), _$createComponent(InterfaceProperty, {
|
|
99
|
+
name: "PropB",
|
|
100
|
+
get type() {
|
|
101
|
+
return typeParameters[1].refkey;
|
|
102
|
+
},
|
|
103
|
+
get: true,
|
|
104
|
+
set: true
|
|
105
|
+
})];
|
|
112
106
|
}
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
109
|
});
|
|
116
110
|
}
|
|
117
111
|
})).toRenderTo(`
|
|
118
|
-
|
|
112
|
+
public interface Test<T, U>
|
|
119
113
|
{
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
T PropA { get; set; }
|
|
123
|
-
U PropB { get; set; }
|
|
124
|
-
}
|
|
114
|
+
T PropA { get; set; }
|
|
115
|
+
U PropB { get; set; }
|
|
125
116
|
}
|
|
126
117
|
`);
|
|
127
118
|
});
|
|
@@ -144,10 +135,10 @@ describe("with type parameters", () => {
|
|
|
144
135
|
}
|
|
145
136
|
})).toRenderTo(`
|
|
146
137
|
public interface Test<T, U>
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
where T : IFoo
|
|
139
|
+
where U : IBar
|
|
149
140
|
{
|
|
150
|
-
|
|
141
|
+
// Body
|
|
151
142
|
}
|
|
152
143
|
`);
|
|
153
144
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/method.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/method.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAc,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,yCAAyC;AACzC,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;CACxB;AAKD,MAAM,WAAW,oBACf,SAAQ,eAAe,EACrB,wBAAwB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IACjD,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YAgC1D"}
|