@alloy-js/csharp 0.19.0-dev.4 → 0.19.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 +0 -8
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +1 -31
- package/dist/src/components/field/field.d.ts +12 -0
- package/dist/src/components/field/field.d.ts.map +1 -0
- package/dist/src/components/field/field.js +34 -0
- package/dist/src/components/field/field.test.d.ts +2 -0
- package/dist/src/components/field/field.test.d.ts.map +1 -0
- package/dist/src/components/field/field.test.js +37 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/stc/index.d.ts +1 -1
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +1 -1
- package/dist/src/components/struct/declaration.d.ts +2 -0
- package/dist/src/components/struct/declaration.d.ts.map +1 -1
- package/dist/src/components/struct/declaration.js +6 -2
- package/dist/src/components/struct/declaration.test.js +45 -1
- package/dist/test/class-declaration.test.js +8 -7
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/ClassDeclaration.tsx +2 -40
- package/src/components/field/field.test.tsx +24 -0
- package/src/components/field/field.tsx +50 -0
- package/src/components/index.ts +1 -0
- package/src/components/stc/index.ts +1 -1
- package/src/components/struct/declaration.test.tsx +31 -1
- package/src/components/struct/declaration.tsx +11 -0
- package/temp/api.json +222 -190
- package/test/class-declaration.test.tsx +8 -26
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StatementList } from "@alloy-js/core";
|
|
2
|
+
import { expect, it } from "vitest";
|
|
3
|
+
import { TestNamespace } from "../../../test/utils.jsx";
|
|
4
|
+
import { ClassDeclaration } from "../ClassDeclaration.jsx";
|
|
5
|
+
import { Field } from "./field.jsx";
|
|
6
|
+
|
|
7
|
+
it("declares some field", () => {
|
|
8
|
+
expect(
|
|
9
|
+
<TestNamespace>
|
|
10
|
+
<ClassDeclaration public name="TestClass">
|
|
11
|
+
<StatementList>
|
|
12
|
+
<Field public name="MemberOne" type="string" />
|
|
13
|
+
<Field private name="MemberTwo" type="int" />
|
|
14
|
+
</StatementList>
|
|
15
|
+
</ClassDeclaration>
|
|
16
|
+
</TestNamespace>,
|
|
17
|
+
).toRenderTo(`
|
|
18
|
+
public class TestClass
|
|
19
|
+
{
|
|
20
|
+
public string MemberOne;
|
|
21
|
+
private int memberTwo;
|
|
22
|
+
}
|
|
23
|
+
`);
|
|
24
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Children, Declaration, Name, refkey, Refkey } from "@alloy-js/core";
|
|
2
|
+
import {
|
|
3
|
+
AccessModifiers,
|
|
4
|
+
computeModifiersPrefix,
|
|
5
|
+
getAccessModifier,
|
|
6
|
+
} from "../../modifiers.js";
|
|
7
|
+
import { CSharpElements, useCSharpNamePolicy } from "../../name-policy.js";
|
|
8
|
+
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
9
|
+
import { useCSharpScope } from "../../symbols/scopes.js";
|
|
10
|
+
import { DocWhen } from "../doc/comment.jsx";
|
|
11
|
+
|
|
12
|
+
export interface FieldProps extends AccessModifiers {
|
|
13
|
+
name: string;
|
|
14
|
+
type: Children;
|
|
15
|
+
refkey?: Refkey;
|
|
16
|
+
/** Doc comment */
|
|
17
|
+
doc?: Children;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Render a c# field */
|
|
21
|
+
export function Field(props: FieldProps) {
|
|
22
|
+
let nameElement: CSharpElements = "class-member-private";
|
|
23
|
+
if (props.public) {
|
|
24
|
+
nameElement = "class-member-public";
|
|
25
|
+
}
|
|
26
|
+
const name = useCSharpNamePolicy().getName(props.name, nameElement);
|
|
27
|
+
const scope = useCSharpScope();
|
|
28
|
+
if (
|
|
29
|
+
scope.kind !== "member" ||
|
|
30
|
+
(scope.name !== "class-decl" && scope.name !== "struct-decl")
|
|
31
|
+
) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"can't define a class member outside of a class or struct scope",
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const memberSymbol = new CSharpOutputSymbol(name, {
|
|
38
|
+
scope,
|
|
39
|
+
refkeys: props.refkey ?? refkey(props.name),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
43
|
+
return (
|
|
44
|
+
<Declaration symbol={memberSymbol}>
|
|
45
|
+
<DocWhen doc={props.doc} />
|
|
46
|
+
{modifiers}
|
|
47
|
+
{props.type} <Name />
|
|
48
|
+
</Declaration>
|
|
49
|
+
);
|
|
50
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./Declaration.js";
|
|
|
5
5
|
export * from "./doc/comment.jsx";
|
|
6
6
|
export * from "./doc/from-markdown.jsx";
|
|
7
7
|
export * from "./EnumDeclaration.jsx";
|
|
8
|
+
export * from "./field/field.jsx";
|
|
8
9
|
export * from "./interface/declaration.js";
|
|
9
10
|
export * from "./interface/method.js";
|
|
10
11
|
export * from "./interface/property.js";
|
|
@@ -3,7 +3,7 @@ import * as base from "../index.js";
|
|
|
3
3
|
|
|
4
4
|
export const ClassDeclaration = core.stc(base.ClassDeclaration);
|
|
5
5
|
export const Constructor = core.stc(base.Constructor);
|
|
6
|
-
export const
|
|
6
|
+
export const Field = core.stc(base.Field);
|
|
7
7
|
export const ClassMethod = core.stc(base.Method);
|
|
8
8
|
export const EnumDeclaration = core.stc(base.EnumDeclaration);
|
|
9
9
|
export const EnumMember = core.stc(base.EnumMember);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { List, refkey } from "@alloy-js/core";
|
|
1
|
+
import { List, refkey, StatementList } from "@alloy-js/core";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
3
|
import { TestNamespace } from "../../../test/utils.jsx";
|
|
4
4
|
import { Attribute } from "../attributes/attributes.jsx";
|
|
5
5
|
import { Constructor } from "../constructor/constructor.jsx";
|
|
6
|
+
import { Field } from "../field/field.jsx";
|
|
6
7
|
import { Method } from "../method/method.jsx";
|
|
7
8
|
import { Property } from "../property/property.jsx";
|
|
8
9
|
import { SourceFile } from "../SourceFile.jsx";
|
|
@@ -167,3 +168,32 @@ it("define constructor", () => {
|
|
|
167
168
|
}
|
|
168
169
|
`);
|
|
169
170
|
});
|
|
171
|
+
|
|
172
|
+
it("defines fields", () => {
|
|
173
|
+
expect(
|
|
174
|
+
<TestNamespace>
|
|
175
|
+
<StructDeclaration public name="TestClass">
|
|
176
|
+
<StatementList>
|
|
177
|
+
<Field public name="MemberOne" type="string" />
|
|
178
|
+
<Field private name="MemberTwo" type="int" />
|
|
179
|
+
</StatementList>
|
|
180
|
+
</StructDeclaration>
|
|
181
|
+
</TestNamespace>,
|
|
182
|
+
).toRenderTo(`
|
|
183
|
+
public struct TestClass
|
|
184
|
+
{
|
|
185
|
+
public string MemberOne;
|
|
186
|
+
private int memberTwo;
|
|
187
|
+
}
|
|
188
|
+
`);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("define multiple interface types", () => {
|
|
192
|
+
expect(
|
|
193
|
+
<TestNamespace>
|
|
194
|
+
<StructDeclaration name="Test" interfaceTypes={["Foo", "Bar"]} />
|
|
195
|
+
</TestNamespace>,
|
|
196
|
+
).toRenderTo(`
|
|
197
|
+
struct Test : Foo, Bar;
|
|
198
|
+
`);
|
|
199
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
|
+
import { join } from "@alloy-js/core";
|
|
2
3
|
import {
|
|
3
4
|
AccessModifiers,
|
|
4
5
|
computeModifiersPrefix,
|
|
@@ -71,6 +72,9 @@ export interface StructDeclarationProps
|
|
|
71
72
|
* ```
|
|
72
73
|
*/
|
|
73
74
|
attributes?: AttributesProp;
|
|
75
|
+
|
|
76
|
+
/** Interfaces this struct implements */
|
|
77
|
+
interfaceTypes?: core.Children[];
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
/**
|
|
@@ -108,6 +112,12 @@ export function StructDeclaration(props: StructDeclarationProps) {
|
|
|
108
112
|
getAccessModifier(props),
|
|
109
113
|
getStructModifiers(props),
|
|
110
114
|
]);
|
|
115
|
+
|
|
116
|
+
const base =
|
|
117
|
+
props.interfaceTypes && props.interfaceTypes.length > 0 ?
|
|
118
|
+
<> : {join(props.interfaceTypes, { joiner: ", " })}</>
|
|
119
|
+
: null;
|
|
120
|
+
|
|
111
121
|
return (
|
|
112
122
|
<core.Declaration symbol={thisStructSymbol}>
|
|
113
123
|
<DocWhen doc={props.doc} />
|
|
@@ -116,6 +126,7 @@ export function StructDeclaration(props: StructDeclarationProps) {
|
|
|
116
126
|
{props.typeParameters && (
|
|
117
127
|
<TypeParameters parameters={props.typeParameters} />
|
|
118
128
|
)}
|
|
129
|
+
{base}
|
|
119
130
|
{props.typeParameters && (
|
|
120
131
|
<TypeParameterConstraints parameters={props.typeParameters} />
|
|
121
132
|
)}
|
package/temp/api.json
CHANGED
|
@@ -1078,196 +1078,6 @@
|
|
|
1078
1078
|
}
|
|
1079
1079
|
]
|
|
1080
1080
|
},
|
|
1081
|
-
{
|
|
1082
|
-
"kind": "Function",
|
|
1083
|
-
"canonicalReference": "@alloy-js/csharp!ClassMember:function(1)",
|
|
1084
|
-
"docComment": "",
|
|
1085
|
-
"excerptTokens": [
|
|
1086
|
-
{
|
|
1087
|
-
"kind": "Content",
|
|
1088
|
-
"text": "export declare function ClassMember(props: "
|
|
1089
|
-
},
|
|
1090
|
-
{
|
|
1091
|
-
"kind": "Reference",
|
|
1092
|
-
"text": "ClassMemberProps",
|
|
1093
|
-
"canonicalReference": "@alloy-js/csharp!ClassMemberProps:interface"
|
|
1094
|
-
},
|
|
1095
|
-
{
|
|
1096
|
-
"kind": "Content",
|
|
1097
|
-
"text": "): "
|
|
1098
|
-
},
|
|
1099
|
-
{
|
|
1100
|
-
"kind": "Reference",
|
|
1101
|
-
"text": "core.Children",
|
|
1102
|
-
"canonicalReference": "@alloy-js/core!Children:type"
|
|
1103
|
-
},
|
|
1104
|
-
{
|
|
1105
|
-
"kind": "Content",
|
|
1106
|
-
"text": ";"
|
|
1107
|
-
}
|
|
1108
|
-
],
|
|
1109
|
-
"fileUrlPath": "src/components/ClassDeclaration.tsx",
|
|
1110
|
-
"returnTypeTokenRange": {
|
|
1111
|
-
"startIndex": 3,
|
|
1112
|
-
"endIndex": 4
|
|
1113
|
-
},
|
|
1114
|
-
"releaseTag": "Public",
|
|
1115
|
-
"overloadIndex": 1,
|
|
1116
|
-
"parameters": [
|
|
1117
|
-
{
|
|
1118
|
-
"parameterName": "props",
|
|
1119
|
-
"parameterTypeTokenRange": {
|
|
1120
|
-
"startIndex": 1,
|
|
1121
|
-
"endIndex": 2
|
|
1122
|
-
},
|
|
1123
|
-
"isOptional": false
|
|
1124
|
-
}
|
|
1125
|
-
],
|
|
1126
|
-
"name": "ClassMember"
|
|
1127
|
-
},
|
|
1128
|
-
{
|
|
1129
|
-
"kind": "Interface",
|
|
1130
|
-
"canonicalReference": "@alloy-js/csharp!ClassMemberProps:interface",
|
|
1131
|
-
"docComment": "",
|
|
1132
|
-
"excerptTokens": [
|
|
1133
|
-
{
|
|
1134
|
-
"kind": "Content",
|
|
1135
|
-
"text": "export interface ClassMemberProps extends "
|
|
1136
|
-
},
|
|
1137
|
-
{
|
|
1138
|
-
"kind": "Reference",
|
|
1139
|
-
"text": "AccessModifiers",
|
|
1140
|
-
"canonicalReference": "@alloy-js/csharp!AccessModifiers:interface"
|
|
1141
|
-
},
|
|
1142
|
-
{
|
|
1143
|
-
"kind": "Content",
|
|
1144
|
-
"text": " "
|
|
1145
|
-
}
|
|
1146
|
-
],
|
|
1147
|
-
"fileUrlPath": "src/components/ClassDeclaration.tsx",
|
|
1148
|
-
"releaseTag": "Public",
|
|
1149
|
-
"name": "ClassMemberProps",
|
|
1150
|
-
"preserveMemberOrder": false,
|
|
1151
|
-
"members": [
|
|
1152
|
-
{
|
|
1153
|
-
"kind": "PropertySignature",
|
|
1154
|
-
"canonicalReference": "@alloy-js/csharp!ClassMemberProps#doc:member",
|
|
1155
|
-
"docComment": "/**\n * Doc comment\n */\n",
|
|
1156
|
-
"excerptTokens": [
|
|
1157
|
-
{
|
|
1158
|
-
"kind": "Content",
|
|
1159
|
-
"text": "doc?: "
|
|
1160
|
-
},
|
|
1161
|
-
{
|
|
1162
|
-
"kind": "Reference",
|
|
1163
|
-
"text": "core.Children",
|
|
1164
|
-
"canonicalReference": "@alloy-js/core!Children:type"
|
|
1165
|
-
},
|
|
1166
|
-
{
|
|
1167
|
-
"kind": "Content",
|
|
1168
|
-
"text": ";"
|
|
1169
|
-
}
|
|
1170
|
-
],
|
|
1171
|
-
"isReadonly": false,
|
|
1172
|
-
"isOptional": true,
|
|
1173
|
-
"releaseTag": "Public",
|
|
1174
|
-
"name": "doc",
|
|
1175
|
-
"propertyTypeTokenRange": {
|
|
1176
|
-
"startIndex": 1,
|
|
1177
|
-
"endIndex": 2
|
|
1178
|
-
}
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
"kind": "PropertySignature",
|
|
1182
|
-
"canonicalReference": "@alloy-js/csharp!ClassMemberProps#name:member",
|
|
1183
|
-
"docComment": "",
|
|
1184
|
-
"excerptTokens": [
|
|
1185
|
-
{
|
|
1186
|
-
"kind": "Content",
|
|
1187
|
-
"text": "name: "
|
|
1188
|
-
},
|
|
1189
|
-
{
|
|
1190
|
-
"kind": "Content",
|
|
1191
|
-
"text": "string"
|
|
1192
|
-
},
|
|
1193
|
-
{
|
|
1194
|
-
"kind": "Content",
|
|
1195
|
-
"text": ";"
|
|
1196
|
-
}
|
|
1197
|
-
],
|
|
1198
|
-
"isReadonly": false,
|
|
1199
|
-
"isOptional": false,
|
|
1200
|
-
"releaseTag": "Public",
|
|
1201
|
-
"name": "name",
|
|
1202
|
-
"propertyTypeTokenRange": {
|
|
1203
|
-
"startIndex": 1,
|
|
1204
|
-
"endIndex": 2
|
|
1205
|
-
}
|
|
1206
|
-
},
|
|
1207
|
-
{
|
|
1208
|
-
"kind": "PropertySignature",
|
|
1209
|
-
"canonicalReference": "@alloy-js/csharp!ClassMemberProps#refkey:member",
|
|
1210
|
-
"docComment": "",
|
|
1211
|
-
"excerptTokens": [
|
|
1212
|
-
{
|
|
1213
|
-
"kind": "Content",
|
|
1214
|
-
"text": "refkey?: "
|
|
1215
|
-
},
|
|
1216
|
-
{
|
|
1217
|
-
"kind": "Reference",
|
|
1218
|
-
"text": "core.Refkey",
|
|
1219
|
-
"canonicalReference": "@alloy-js/core!Refkey:type"
|
|
1220
|
-
},
|
|
1221
|
-
{
|
|
1222
|
-
"kind": "Content",
|
|
1223
|
-
"text": ";"
|
|
1224
|
-
}
|
|
1225
|
-
],
|
|
1226
|
-
"isReadonly": false,
|
|
1227
|
-
"isOptional": true,
|
|
1228
|
-
"releaseTag": "Public",
|
|
1229
|
-
"name": "refkey",
|
|
1230
|
-
"propertyTypeTokenRange": {
|
|
1231
|
-
"startIndex": 1,
|
|
1232
|
-
"endIndex": 2
|
|
1233
|
-
}
|
|
1234
|
-
},
|
|
1235
|
-
{
|
|
1236
|
-
"kind": "PropertySignature",
|
|
1237
|
-
"canonicalReference": "@alloy-js/csharp!ClassMemberProps#type:member",
|
|
1238
|
-
"docComment": "",
|
|
1239
|
-
"excerptTokens": [
|
|
1240
|
-
{
|
|
1241
|
-
"kind": "Content",
|
|
1242
|
-
"text": "type: "
|
|
1243
|
-
},
|
|
1244
|
-
{
|
|
1245
|
-
"kind": "Reference",
|
|
1246
|
-
"text": "core.Children",
|
|
1247
|
-
"canonicalReference": "@alloy-js/core!Children:type"
|
|
1248
|
-
},
|
|
1249
|
-
{
|
|
1250
|
-
"kind": "Content",
|
|
1251
|
-
"text": ";"
|
|
1252
|
-
}
|
|
1253
|
-
],
|
|
1254
|
-
"isReadonly": false,
|
|
1255
|
-
"isOptional": false,
|
|
1256
|
-
"releaseTag": "Public",
|
|
1257
|
-
"name": "type",
|
|
1258
|
-
"propertyTypeTokenRange": {
|
|
1259
|
-
"startIndex": 1,
|
|
1260
|
-
"endIndex": 2
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
],
|
|
1264
|
-
"extendsTokenRanges": [
|
|
1265
|
-
{
|
|
1266
|
-
"startIndex": 1,
|
|
1267
|
-
"endIndex": 2
|
|
1268
|
-
}
|
|
1269
|
-
]
|
|
1270
|
-
},
|
|
1271
1081
|
{
|
|
1272
1082
|
"kind": "Interface",
|
|
1273
1083
|
"canonicalReference": "@alloy-js/csharp!ClassModifiers:interface",
|
|
@@ -4239,6 +4049,196 @@
|
|
|
4239
4049
|
],
|
|
4240
4050
|
"extendsTokenRanges": []
|
|
4241
4051
|
},
|
|
4052
|
+
{
|
|
4053
|
+
"kind": "Function",
|
|
4054
|
+
"canonicalReference": "@alloy-js/csharp!Field:function(1)",
|
|
4055
|
+
"docComment": "/**\n * Render a c# field\n */\n",
|
|
4056
|
+
"excerptTokens": [
|
|
4057
|
+
{
|
|
4058
|
+
"kind": "Content",
|
|
4059
|
+
"text": "export declare function Field(props: "
|
|
4060
|
+
},
|
|
4061
|
+
{
|
|
4062
|
+
"kind": "Reference",
|
|
4063
|
+
"text": "FieldProps",
|
|
4064
|
+
"canonicalReference": "@alloy-js/csharp!FieldProps:interface"
|
|
4065
|
+
},
|
|
4066
|
+
{
|
|
4067
|
+
"kind": "Content",
|
|
4068
|
+
"text": "): "
|
|
4069
|
+
},
|
|
4070
|
+
{
|
|
4071
|
+
"kind": "Reference",
|
|
4072
|
+
"text": "Children",
|
|
4073
|
+
"canonicalReference": "@alloy-js/core!Children:type"
|
|
4074
|
+
},
|
|
4075
|
+
{
|
|
4076
|
+
"kind": "Content",
|
|
4077
|
+
"text": ";"
|
|
4078
|
+
}
|
|
4079
|
+
],
|
|
4080
|
+
"fileUrlPath": "src/components/field/field.tsx",
|
|
4081
|
+
"returnTypeTokenRange": {
|
|
4082
|
+
"startIndex": 3,
|
|
4083
|
+
"endIndex": 4
|
|
4084
|
+
},
|
|
4085
|
+
"releaseTag": "Public",
|
|
4086
|
+
"overloadIndex": 1,
|
|
4087
|
+
"parameters": [
|
|
4088
|
+
{
|
|
4089
|
+
"parameterName": "props",
|
|
4090
|
+
"parameterTypeTokenRange": {
|
|
4091
|
+
"startIndex": 1,
|
|
4092
|
+
"endIndex": 2
|
|
4093
|
+
},
|
|
4094
|
+
"isOptional": false
|
|
4095
|
+
}
|
|
4096
|
+
],
|
|
4097
|
+
"name": "Field"
|
|
4098
|
+
},
|
|
4099
|
+
{
|
|
4100
|
+
"kind": "Interface",
|
|
4101
|
+
"canonicalReference": "@alloy-js/csharp!FieldProps:interface",
|
|
4102
|
+
"docComment": "",
|
|
4103
|
+
"excerptTokens": [
|
|
4104
|
+
{
|
|
4105
|
+
"kind": "Content",
|
|
4106
|
+
"text": "export interface FieldProps extends "
|
|
4107
|
+
},
|
|
4108
|
+
{
|
|
4109
|
+
"kind": "Reference",
|
|
4110
|
+
"text": "AccessModifiers",
|
|
4111
|
+
"canonicalReference": "@alloy-js/csharp!AccessModifiers:interface"
|
|
4112
|
+
},
|
|
4113
|
+
{
|
|
4114
|
+
"kind": "Content",
|
|
4115
|
+
"text": " "
|
|
4116
|
+
}
|
|
4117
|
+
],
|
|
4118
|
+
"fileUrlPath": "src/components/field/field.tsx",
|
|
4119
|
+
"releaseTag": "Public",
|
|
4120
|
+
"name": "FieldProps",
|
|
4121
|
+
"preserveMemberOrder": false,
|
|
4122
|
+
"members": [
|
|
4123
|
+
{
|
|
4124
|
+
"kind": "PropertySignature",
|
|
4125
|
+
"canonicalReference": "@alloy-js/csharp!FieldProps#doc:member",
|
|
4126
|
+
"docComment": "/**\n * Doc comment\n */\n",
|
|
4127
|
+
"excerptTokens": [
|
|
4128
|
+
{
|
|
4129
|
+
"kind": "Content",
|
|
4130
|
+
"text": "doc?: "
|
|
4131
|
+
},
|
|
4132
|
+
{
|
|
4133
|
+
"kind": "Reference",
|
|
4134
|
+
"text": "Children",
|
|
4135
|
+
"canonicalReference": "@alloy-js/core!Children:type"
|
|
4136
|
+
},
|
|
4137
|
+
{
|
|
4138
|
+
"kind": "Content",
|
|
4139
|
+
"text": ";"
|
|
4140
|
+
}
|
|
4141
|
+
],
|
|
4142
|
+
"isReadonly": false,
|
|
4143
|
+
"isOptional": true,
|
|
4144
|
+
"releaseTag": "Public",
|
|
4145
|
+
"name": "doc",
|
|
4146
|
+
"propertyTypeTokenRange": {
|
|
4147
|
+
"startIndex": 1,
|
|
4148
|
+
"endIndex": 2
|
|
4149
|
+
}
|
|
4150
|
+
},
|
|
4151
|
+
{
|
|
4152
|
+
"kind": "PropertySignature",
|
|
4153
|
+
"canonicalReference": "@alloy-js/csharp!FieldProps#name:member",
|
|
4154
|
+
"docComment": "",
|
|
4155
|
+
"excerptTokens": [
|
|
4156
|
+
{
|
|
4157
|
+
"kind": "Content",
|
|
4158
|
+
"text": "name: "
|
|
4159
|
+
},
|
|
4160
|
+
{
|
|
4161
|
+
"kind": "Content",
|
|
4162
|
+
"text": "string"
|
|
4163
|
+
},
|
|
4164
|
+
{
|
|
4165
|
+
"kind": "Content",
|
|
4166
|
+
"text": ";"
|
|
4167
|
+
}
|
|
4168
|
+
],
|
|
4169
|
+
"isReadonly": false,
|
|
4170
|
+
"isOptional": false,
|
|
4171
|
+
"releaseTag": "Public",
|
|
4172
|
+
"name": "name",
|
|
4173
|
+
"propertyTypeTokenRange": {
|
|
4174
|
+
"startIndex": 1,
|
|
4175
|
+
"endIndex": 2
|
|
4176
|
+
}
|
|
4177
|
+
},
|
|
4178
|
+
{
|
|
4179
|
+
"kind": "PropertySignature",
|
|
4180
|
+
"canonicalReference": "@alloy-js/csharp!FieldProps#refkey:member",
|
|
4181
|
+
"docComment": "",
|
|
4182
|
+
"excerptTokens": [
|
|
4183
|
+
{
|
|
4184
|
+
"kind": "Content",
|
|
4185
|
+
"text": "refkey?: "
|
|
4186
|
+
},
|
|
4187
|
+
{
|
|
4188
|
+
"kind": "Reference",
|
|
4189
|
+
"text": "Refkey",
|
|
4190
|
+
"canonicalReference": "@alloy-js/core!Refkey:type"
|
|
4191
|
+
},
|
|
4192
|
+
{
|
|
4193
|
+
"kind": "Content",
|
|
4194
|
+
"text": ";"
|
|
4195
|
+
}
|
|
4196
|
+
],
|
|
4197
|
+
"isReadonly": false,
|
|
4198
|
+
"isOptional": true,
|
|
4199
|
+
"releaseTag": "Public",
|
|
4200
|
+
"name": "refkey",
|
|
4201
|
+
"propertyTypeTokenRange": {
|
|
4202
|
+
"startIndex": 1,
|
|
4203
|
+
"endIndex": 2
|
|
4204
|
+
}
|
|
4205
|
+
},
|
|
4206
|
+
{
|
|
4207
|
+
"kind": "PropertySignature",
|
|
4208
|
+
"canonicalReference": "@alloy-js/csharp!FieldProps#type:member",
|
|
4209
|
+
"docComment": "",
|
|
4210
|
+
"excerptTokens": [
|
|
4211
|
+
{
|
|
4212
|
+
"kind": "Content",
|
|
4213
|
+
"text": "type: "
|
|
4214
|
+
},
|
|
4215
|
+
{
|
|
4216
|
+
"kind": "Reference",
|
|
4217
|
+
"text": "Children",
|
|
4218
|
+
"canonicalReference": "@alloy-js/core!Children:type"
|
|
4219
|
+
},
|
|
4220
|
+
{
|
|
4221
|
+
"kind": "Content",
|
|
4222
|
+
"text": ";"
|
|
4223
|
+
}
|
|
4224
|
+
],
|
|
4225
|
+
"isReadonly": false,
|
|
4226
|
+
"isOptional": false,
|
|
4227
|
+
"releaseTag": "Public",
|
|
4228
|
+
"name": "type",
|
|
4229
|
+
"propertyTypeTokenRange": {
|
|
4230
|
+
"startIndex": 1,
|
|
4231
|
+
"endIndex": 2
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
],
|
|
4235
|
+
"extendsTokenRanges": [
|
|
4236
|
+
{
|
|
4237
|
+
"startIndex": 1,
|
|
4238
|
+
"endIndex": 2
|
|
4239
|
+
}
|
|
4240
|
+
]
|
|
4241
|
+
},
|
|
4242
4242
|
{
|
|
4243
4243
|
"kind": "Function",
|
|
4244
4244
|
"canonicalReference": "@alloy-js/csharp!getAccessModifier:function(1)",
|
|
@@ -8270,6 +8270,38 @@
|
|
|
8270
8270
|
"endIndex": 2
|
|
8271
8271
|
}
|
|
8272
8272
|
},
|
|
8273
|
+
{
|
|
8274
|
+
"kind": "PropertySignature",
|
|
8275
|
+
"canonicalReference": "@alloy-js/csharp!StructDeclarationProps#interfaceTypes:member",
|
|
8276
|
+
"docComment": "/**\n * Interfaces this struct implements\n */\n",
|
|
8277
|
+
"excerptTokens": [
|
|
8278
|
+
{
|
|
8279
|
+
"kind": "Content",
|
|
8280
|
+
"text": "interfaceTypes?: "
|
|
8281
|
+
},
|
|
8282
|
+
{
|
|
8283
|
+
"kind": "Reference",
|
|
8284
|
+
"text": "core.Children",
|
|
8285
|
+
"canonicalReference": "@alloy-js/core!Children:type"
|
|
8286
|
+
},
|
|
8287
|
+
{
|
|
8288
|
+
"kind": "Content",
|
|
8289
|
+
"text": "[]"
|
|
8290
|
+
},
|
|
8291
|
+
{
|
|
8292
|
+
"kind": "Content",
|
|
8293
|
+
"text": ";"
|
|
8294
|
+
}
|
|
8295
|
+
],
|
|
8296
|
+
"isReadonly": false,
|
|
8297
|
+
"isOptional": true,
|
|
8298
|
+
"releaseTag": "Public",
|
|
8299
|
+
"name": "interfaceTypes",
|
|
8300
|
+
"propertyTypeTokenRange": {
|
|
8301
|
+
"startIndex": 1,
|
|
8302
|
+
"endIndex": 3
|
|
8303
|
+
}
|
|
8304
|
+
},
|
|
8273
8305
|
{
|
|
8274
8306
|
"kind": "PropertySignature",
|
|
8275
8307
|
"canonicalReference": "@alloy-js/csharp!StructDeclarationProps#name:member",
|
|
@@ -3,15 +3,11 @@ import { List, refkey } from "@alloy-js/core";
|
|
|
3
3
|
import * as coretest from "@alloy-js/core/testing";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { Attribute } from "../src/components/attributes/attributes.jsx";
|
|
6
|
+
import { Field } from "../src/components/field/field.jsx";
|
|
6
7
|
import { Constructor } from "../src/components/stc/index.js";
|
|
7
8
|
import { TypeParameterProps } from "../src/components/type-parameters/type-parameter.jsx";
|
|
8
9
|
import * as csharp from "../src/index.js";
|
|
9
|
-
import {
|
|
10
|
-
ClassDeclaration,
|
|
11
|
-
ClassMember,
|
|
12
|
-
Property,
|
|
13
|
-
SourceFile,
|
|
14
|
-
} from "../src/index.js";
|
|
10
|
+
import { ClassDeclaration, Property, SourceFile } from "../src/index.js";
|
|
15
11
|
import * as utils from "./utils.jsx";
|
|
16
12
|
|
|
17
13
|
it("declares class with no members", () => {
|
|
@@ -99,8 +95,8 @@ it("declares class with some members", () => {
|
|
|
99
95
|
const res = utils.toSourceText(
|
|
100
96
|
<csharp.ClassDeclaration public name="TestClass">
|
|
101
97
|
<core.StatementList>
|
|
102
|
-
<
|
|
103
|
-
<
|
|
98
|
+
<Field public name="MemberOne" type="string" />
|
|
99
|
+
<Field private name="MemberTwo" type="int" />
|
|
104
100
|
</core.StatementList>
|
|
105
101
|
</csharp.ClassDeclaration>,
|
|
106
102
|
);
|
|
@@ -183,11 +179,7 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
183
179
|
/>
|
|
184
180
|
<hbr />
|
|
185
181
|
<csharp.ClassDeclaration public name="TestClass">
|
|
186
|
-
<
|
|
187
|
-
private
|
|
188
|
-
name="MemberOne"
|
|
189
|
-
type={enumTypeRefkey}
|
|
190
|
-
/>
|
|
182
|
+
<Field private name="MemberOne" type={enumTypeRefkey} />
|
|
191
183
|
;
|
|
192
184
|
<hbr />
|
|
193
185
|
<csharp.Method
|
|
@@ -351,19 +343,9 @@ it("declares class with constructor params and assigns values to fields", () =>
|
|
|
351
343
|
|
|
352
344
|
const res = utils.toSourceText(
|
|
353
345
|
<csharp.ClassDeclaration public name="TestClass">
|
|
354
|
-
<
|
|
355
|
-
private
|
|
356
|
-
name="name"
|
|
357
|
-
type="string"
|
|
358
|
-
refkey={thisNameRefkey}
|
|
359
|
-
/>
|
|
346
|
+
<Field private name="name" type="string" refkey={thisNameRefkey} />
|
|
360
347
|
;<hbr />
|
|
361
|
-
<
|
|
362
|
-
private
|
|
363
|
-
name="size"
|
|
364
|
-
type="int"
|
|
365
|
-
refkey={thisSizeRefkey}
|
|
366
|
-
/>
|
|
348
|
+
<Field private name="size" type="int" refkey={thisSizeRefkey} />
|
|
367
349
|
;<hbr />
|
|
368
350
|
<Constructor public parameters={ctorParams}>
|
|
369
351
|
{thisNameRefkey} = {paramNameRefkey};<hbr />
|
|
@@ -406,7 +388,7 @@ it("supports class member doc comments", () => {
|
|
|
406
388
|
expect(
|
|
407
389
|
<utils.TestNamespace>
|
|
408
390
|
<ClassDeclaration name="Test" doc="This is a test">
|
|
409
|
-
<
|
|
391
|
+
<Field name="Member" public type="int" doc="This is a member" />
|
|
410
392
|
</ClassDeclaration>
|
|
411
393
|
</utils.TestNamespace>,
|
|
412
394
|
).toRenderTo(`
|