@alloy-js/csharp 0.18.0-dev.20 → 0.18.0-dev.22
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 +1 -1
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +7 -8
- package/dist/src/components/ClassMethod.d.ts +1 -1
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +6 -7
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -1
- package/dist/src/components/interface/method.d.ts +1 -1
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +6 -7
- package/dist/src/components/interface/method.test.js +25 -0
- package/dist/src/components/parameters/parameters.d.ts +19 -0
- package/dist/src/components/parameters/parameters.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.js +43 -0
- package/dist/src/components/property/property.d.ts +5 -0
- package/dist/src/components/property/property.d.ts.map +1 -1
- package/dist/src/components/property/property.js +1 -1
- package/dist/src/components/property/property.test.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/ClassDeclaration.tsx +5 -6
- package/src/components/ClassMethod.tsx +2 -4
- package/src/components/index.ts +1 -1
- package/src/components/interface/method.test.tsx +28 -0
- package/src/components/interface/method.tsx +2 -5
- package/src/components/{Parameters.tsx → parameters/parameters.tsx} +35 -19
- package/src/components/property/property.test.tsx +1 -0
- package/src/components/property/property.tsx +6 -0
- package/temp/api.json +39 -12
- package/dist/src/components/Parameters.d.ts +0 -18
- package/dist/src/components/Parameters.d.ts.map +0 -1
- package/dist/src/components/Parameters.js +0 -35
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
2
|
import { AccessModifiers } from "../modifiers.js";
|
|
3
|
-
import { ParameterProps } from "./
|
|
3
|
+
import { ParameterProps } from "./parameters/parameters.jsx";
|
|
4
4
|
import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
5
5
|
export interface ClassModifiers {
|
|
6
6
|
readonly abstract?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAUD,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,cAAc;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAEjD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAEzB,uCAAuC;IACvC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBA4C5D;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBAiC5D;AAGD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CACrB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBA0BlD"}
|
|
@@ -5,9 +5,9 @@ import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../mod
|
|
|
5
5
|
import { useCSharpNamePolicy } from "../name-policy.js";
|
|
6
6
|
import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
|
|
7
7
|
import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
|
|
8
|
-
import { Name } from "./Name.js";
|
|
9
|
-
import { Parameters } from "./Parameters.js";
|
|
10
8
|
import { DocWhen } from "./doc/comment.js";
|
|
9
|
+
import { Name } from "./Name.js";
|
|
10
|
+
import { Parameters } from "./parameters/parameters.js";
|
|
11
11
|
import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
|
|
12
12
|
import { TypeParameters } from "./type-parameters/type-parameters.js";
|
|
13
13
|
const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
|
|
@@ -104,11 +104,6 @@ export function ClassConstructor(props) {
|
|
|
104
104
|
owner: ctorSymbol
|
|
105
105
|
});
|
|
106
106
|
const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
|
|
107
|
-
const params = props.parameters ? _$createComponent(Parameters, {
|
|
108
|
-
get parameters() {
|
|
109
|
-
return props.parameters;
|
|
110
|
-
}
|
|
111
|
-
}) : "";
|
|
112
107
|
|
|
113
108
|
// note that scope wraps the ctor decl so that the params get the correct scope
|
|
114
109
|
return _$createComponent(core.Declaration, {
|
|
@@ -117,7 +112,11 @@ export function ClassConstructor(props) {
|
|
|
117
112
|
return _$createComponent(core.Scope, {
|
|
118
113
|
value: ctorDeclScope,
|
|
119
114
|
get children() {
|
|
120
|
-
return [modifiers, _$createComponent(Name, {}),
|
|
115
|
+
return [modifiers, _$createComponent(Name, {}), _$createComponent(Parameters, {
|
|
116
|
+
get parameters() {
|
|
117
|
+
return props.parameters;
|
|
118
|
+
}
|
|
119
|
+
}), _$createComponent(core.Block, {
|
|
121
120
|
newline: true,
|
|
122
121
|
get children() {
|
|
123
122
|
return props.children;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children, Refkey } from "@alloy-js/core";
|
|
2
2
|
import { AccessModifiers } from "../modifiers.js";
|
|
3
|
-
import { ParameterProps } from "./
|
|
3
|
+
import { ParameterProps } from "./parameters/parameters.jsx";
|
|
4
4
|
import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
5
5
|
/** Method modifiers. Can only be one. */
|
|
6
6
|
export interface ClassMethodModifiers {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKhB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKhB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,MAAM,WAAW,gBACf,SAAQ,eAAe,EACrB,oBAAoB;IACtB,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,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;CAClD;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YA0ClD"}
|
|
@@ -4,8 +4,8 @@ import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, makeModifi
|
|
|
4
4
|
import { useCSharpNamePolicy } from "../name-policy.js";
|
|
5
5
|
import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
|
|
6
6
|
import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
|
|
7
|
-
import { Parameters } from "./Parameters.js";
|
|
8
7
|
import { DocWhen } from "./doc/comment.js";
|
|
8
|
+
import { Parameters } from "./parameters/parameters.js";
|
|
9
9
|
import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
|
|
10
10
|
import { TypeParameters } from "./type-parameters/type-parameters.js";
|
|
11
11
|
|
|
@@ -31,11 +31,6 @@ export function ClassMethod(props) {
|
|
|
31
31
|
const methodScope = new CSharpMemberScope("method-decl", {
|
|
32
32
|
owner: methodSymbol
|
|
33
33
|
});
|
|
34
|
-
const params = props.parameters ? _$createComponent(Parameters, {
|
|
35
|
-
get parameters() {
|
|
36
|
-
return props.parameters;
|
|
37
|
-
}
|
|
38
|
-
}) : "";
|
|
39
34
|
const returns = props.returns ?? (props.async ? "Task" : "void");
|
|
40
35
|
const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
|
|
41
36
|
// note that scope wraps the method decl so that the params get the correct scope
|
|
@@ -53,7 +48,11 @@ export function ClassMethod(props) {
|
|
|
53
48
|
get parameters() {
|
|
54
49
|
return props.typeParameters;
|
|
55
50
|
}
|
|
56
|
-
})),
|
|
51
|
+
})), _$createComponent(Parameters, {
|
|
52
|
+
get parameters() {
|
|
53
|
+
return props.parameters;
|
|
54
|
+
}
|
|
55
|
+
}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
57
56
|
get parameters() {
|
|
58
57
|
return props.typeParameters;
|
|
59
58
|
}
|
|
@@ -9,7 +9,7 @@ export * from "./interface/method.js";
|
|
|
9
9
|
export * from "./interface/property.js";
|
|
10
10
|
export * from "./Name.js";
|
|
11
11
|
export * from "./Namespace.js";
|
|
12
|
-
export * from "./
|
|
12
|
+
export * from "./parameters/parameters.jsx";
|
|
13
13
|
export * from "./ProjectDirectory.js";
|
|
14
14
|
export * from "./property/property.jsx";
|
|
15
15
|
export * from "./record/declaration.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,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,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
|
|
@@ -9,7 +9,7 @@ export * from "./interface/method.js";
|
|
|
9
9
|
export * from "./interface/property.js";
|
|
10
10
|
export * from "./Name.js";
|
|
11
11
|
export * from "./Namespace.js";
|
|
12
|
-
export * from "./
|
|
12
|
+
export * from "./parameters/parameters.js";
|
|
13
13
|
export * from "./ProjectDirectory.js";
|
|
14
14
|
export * from "./property/property.js";
|
|
15
15
|
export * from "./record/declaration.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children, Refkey } from "@alloy-js/core";
|
|
2
2
|
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
-
import { ParameterProps } from "../
|
|
3
|
+
import { ParameterProps } from "../parameters/parameters.jsx";
|
|
4
4
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
5
5
|
/** Method modifiers. Can only be one. */
|
|
6
6
|
export interface InterfaceMethodModifiers {
|
|
@@ -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;AAK5B,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;CAChB;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,YA2C1D"}
|
|
@@ -4,8 +4,8 @@ import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../
|
|
|
4
4
|
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
5
|
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
6
6
|
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
7
|
-
import { Parameters } from "../Parameters.js";
|
|
8
7
|
import { DocWhen } from "../doc/comment.js";
|
|
8
|
+
import { Parameters } from "../parameters/parameters.js";
|
|
9
9
|
import { TypeParameterConstraints } from "../type-parameters/type-parameter-constraints.js";
|
|
10
10
|
import { TypeParameters } from "../type-parameters/type-parameters.js";
|
|
11
11
|
|
|
@@ -31,11 +31,6 @@ export function InterfaceMethod(props) {
|
|
|
31
31
|
const methodScope = new CSharpMemberScope("method-decl", {
|
|
32
32
|
owner: methodSymbol
|
|
33
33
|
});
|
|
34
|
-
const params = props.parameters ? _$createComponent(Parameters, {
|
|
35
|
-
get parameters() {
|
|
36
|
-
return props.parameters;
|
|
37
|
-
}
|
|
38
|
-
}) : "";
|
|
39
34
|
const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props)]);
|
|
40
35
|
// note that scope wraps the method decl so that the params get the correct scope
|
|
41
36
|
return _$createComponent(MemberDeclaration, {
|
|
@@ -52,7 +47,11 @@ export function InterfaceMethod(props) {
|
|
|
52
47
|
get parameters() {
|
|
53
48
|
return props.typeParameters;
|
|
54
49
|
}
|
|
55
|
-
})),
|
|
50
|
+
})), _$createComponent(Parameters, {
|
|
51
|
+
get parameters() {
|
|
52
|
+
return props.parameters;
|
|
53
|
+
}
|
|
54
|
+
}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
|
|
56
55
|
get parameters() {
|
|
57
56
|
return props.typeParameters;
|
|
58
57
|
}
|
|
@@ -251,4 +251,29 @@ describe("with type parameters", () => {
|
|
|
251
251
|
}
|
|
252
252
|
`);
|
|
253
253
|
});
|
|
254
|
+
});
|
|
255
|
+
describe("formatting", () => {
|
|
256
|
+
it("Split parameters before type parameters", () => {
|
|
257
|
+
expect(_$createComponent(Wrapper, {
|
|
258
|
+
get children() {
|
|
259
|
+
return _$createComponent(InterfaceMethod, {
|
|
260
|
+
"public": true,
|
|
261
|
+
name: "Handle",
|
|
262
|
+
parameters: [{
|
|
263
|
+
name: "message",
|
|
264
|
+
type: "Some.Quite.Long.Type.That.Will.Split"
|
|
265
|
+
}],
|
|
266
|
+
typeParameters: ["T"],
|
|
267
|
+
returns: "Some.Quite.Long.Type.That.Will.Split"
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
})).toRenderTo(`
|
|
271
|
+
public interface TestInterface
|
|
272
|
+
{
|
|
273
|
+
public Some.Quite.Long.Type.That.Will.Split Handle<T>(
|
|
274
|
+
Some.Quite.Long.Type.That.Will.Split message
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
`);
|
|
278
|
+
});
|
|
254
279
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Children, OutputSymbol, Refkey } from "@alloy-js/core";
|
|
2
|
+
export interface ParameterProps {
|
|
3
|
+
name: string;
|
|
4
|
+
type: Children;
|
|
5
|
+
/** If the parmaeter is optional(without default value) */
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
/** Default value for the parameter */
|
|
8
|
+
default?: Children;
|
|
9
|
+
refkey?: Refkey;
|
|
10
|
+
symbol?: OutputSymbol;
|
|
11
|
+
}
|
|
12
|
+
/** Define a parameter to be used in class or interface method. */
|
|
13
|
+
export declare function Parameter(props: ParameterProps): Children;
|
|
14
|
+
export interface ParametersProps {
|
|
15
|
+
parameters: ParameterProps[] | undefined;
|
|
16
|
+
}
|
|
17
|
+
/** Render a collection of parameters */
|
|
18
|
+
export declare function Parameters(props: ParametersProps): Children;
|
|
19
|
+
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../../src/components/parameters/parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,YAAY,EAEZ,MAAM,EACP,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YAwB9C;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;CAC1C;AAED,wCAAwC;AACxC,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAehD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, Declaration, For, Indent, refkey } from "@alloy-js/core";
|
|
3
|
+
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
4
|
+
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
5
|
+
import { useCSharpScope } from "../../symbols/scopes.js";
|
|
6
|
+
import { Name } from "../Name.js";
|
|
7
|
+
/** Define a parameter to be used in class or interface method. */
|
|
8
|
+
export function Parameter(props) {
|
|
9
|
+
const name = useCSharpNamePolicy().getName(props.name, "parameter");
|
|
10
|
+
const scope = useCSharpScope();
|
|
11
|
+
if (scope.kind !== "member" || scope.name !== "constructor-decl" && scope.name !== "method-decl") {
|
|
12
|
+
throw new Error("can't define a parameter outside of a constructor-decl or method-decl scope");
|
|
13
|
+
}
|
|
14
|
+
const memberSymbol = new CSharpOutputSymbol(name, {
|
|
15
|
+
scope,
|
|
16
|
+
refkeys: props.refkey ?? refkey(props.name)
|
|
17
|
+
});
|
|
18
|
+
return _$createComponent(Declaration, {
|
|
19
|
+
symbol: memberSymbol,
|
|
20
|
+
get children() {
|
|
21
|
+
return [_$memo(() => props.type), _$memo(() => props.optional ? "?" : ""), " ", _$createComponent(Name, {}), _$memo(() => props.default ? code` = ${props.default}` : "")];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** Render a collection of parameters */
|
|
26
|
+
export function Parameters(props) {
|
|
27
|
+
return _$createIntrinsic("group", {
|
|
28
|
+
get children() {
|
|
29
|
+
return ["(", _$memo(() => _$memo(() => !!props.parameters)() && _$createComponent(Indent, {
|
|
30
|
+
softline: true,
|
|
31
|
+
get children() {
|
|
32
|
+
return _$createComponent(For, {
|
|
33
|
+
get each() {
|
|
34
|
+
return props.parameters;
|
|
35
|
+
},
|
|
36
|
+
joiner: ", ",
|
|
37
|
+
children: param => _$createComponent(Parameter, param)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
})), _$createIntrinsic("softline", {}), ")"];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -10,6 +10,11 @@ export interface PropertyModifiers {
|
|
|
10
10
|
readonly abstract?: boolean;
|
|
11
11
|
readonly extern?: boolean;
|
|
12
12
|
readonly readonly?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Set required modifier on property
|
|
15
|
+
* https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/required
|
|
16
|
+
*/
|
|
17
|
+
readonly required?: boolean;
|
|
13
18
|
}
|
|
14
19
|
/** Properties for {@link Property} component */
|
|
15
20
|
export interface PropertyProps extends AccessModifiers, PropertyModifiers {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../src/components/property/property.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAM5B,0BAA0B;AAC1B,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;
|
|
1
|
+
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../src/components/property/property.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAM5B,0BAA0B;AAC1B,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAcD,gDAAgD;AAChD,MAAM,WAAW,aAAc,SAAQ,eAAe,EAAE,iBAAiB;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,oBAAoB;IACpB,IAAI,EAAE,QAAQ,CAAC;IAEf,uCAAuC;IACvC,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,uCAAuC;IACvC,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,0DAA0D;IAC1D,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,QAAQ,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,YAmD5C"}
|
|
@@ -8,7 +8,7 @@ import { DocWhen } from "../doc/comment.js";
|
|
|
8
8
|
|
|
9
9
|
/** Property modifiers. */
|
|
10
10
|
|
|
11
|
-
const getModifiers = makeModifiers(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly"]);
|
|
11
|
+
const getModifiers = makeModifiers(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly", "required"]);
|
|
12
12
|
|
|
13
13
|
/** Properties for {@link Property} component */
|
|
14
14
|
|
|
@@ -36,7 +36,7 @@ describe("modifiers", () => {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
describe("property modifiers", () => {
|
|
39
|
-
it.each(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly"])("%s", methodModifier => {
|
|
39
|
+
it.each(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly", "required"])("%s", methodModifier => {
|
|
40
40
|
expect(_$createComponent(Wrapper, {
|
|
41
41
|
get children() {
|
|
42
42
|
return _$createComponent(Property, _$mergeProps({
|