@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
|
@@ -248,3 +248,31 @@ describe("with type parameters", () => {
|
|
|
248
248
|
`);
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
describe("formatting", () => {
|
|
253
|
+
it("Split parameters before type parameters", () => {
|
|
254
|
+
expect(
|
|
255
|
+
<Wrapper>
|
|
256
|
+
<InterfaceMethod
|
|
257
|
+
public
|
|
258
|
+
name="Handle"
|
|
259
|
+
parameters={[
|
|
260
|
+
{
|
|
261
|
+
name: "message",
|
|
262
|
+
type: "Some.Quite.Long.Type.That.Will.Split",
|
|
263
|
+
},
|
|
264
|
+
]}
|
|
265
|
+
typeParameters={["T"]}
|
|
266
|
+
returns="Some.Quite.Long.Type.That.Will.Split"
|
|
267
|
+
/>
|
|
268
|
+
</Wrapper>,
|
|
269
|
+
).toRenderTo(`
|
|
270
|
+
public interface TestInterface
|
|
271
|
+
{
|
|
272
|
+
public Some.Quite.Long.Type.That.Will.Split Handle<T>(
|
|
273
|
+
Some.Quite.Long.Type.That.Will.Split message
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
`);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
16
16
|
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
17
17
|
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
18
|
-
import { ParameterProps, Parameters } from "../Parameters.jsx";
|
|
19
18
|
import { DocWhen } from "../doc/comment.jsx";
|
|
19
|
+
import { ParameterProps, Parameters } from "../parameters/parameters.jsx";
|
|
20
20
|
import { TypeParameterConstraints } from "../type-parameters/type-parameter-constraints.jsx";
|
|
21
21
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
22
22
|
import { TypeParameters } from "../type-parameters/type-parameters.jsx";
|
|
@@ -75,9 +75,6 @@ export function InterfaceMethod(props: InterfaceMethodProps) {
|
|
|
75
75
|
owner: methodSymbol,
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
const params =
|
|
79
|
-
props.parameters ? <Parameters parameters={props.parameters} /> : "";
|
|
80
|
-
|
|
81
78
|
const modifiers = computeModifiersPrefix([
|
|
82
79
|
getAccessModifier(props),
|
|
83
80
|
getMethodModifier(props),
|
|
@@ -92,7 +89,7 @@ export function InterfaceMethod(props: InterfaceMethodProps) {
|
|
|
92
89
|
{props.typeParameters && (
|
|
93
90
|
<TypeParameters parameters={props.typeParameters} />
|
|
94
91
|
)}
|
|
95
|
-
|
|
92
|
+
<Parameters parameters={props.parameters} />
|
|
96
93
|
{props.typeParameters && (
|
|
97
94
|
<TypeParameterConstraints parameters={props.typeParameters} />
|
|
98
95
|
)}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
code,
|
|
4
|
+
Declaration,
|
|
5
|
+
For,
|
|
6
|
+
Indent,
|
|
7
|
+
OutputSymbol,
|
|
8
|
+
refkey,
|
|
9
|
+
Refkey,
|
|
10
|
+
} from "@alloy-js/core";
|
|
11
|
+
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
12
|
+
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
13
|
+
import { useCSharpScope } from "../../symbols/scopes.js";
|
|
14
|
+
import { Name } from "../Name.jsx";
|
|
7
15
|
|
|
8
16
|
export interface ParameterProps {
|
|
9
17
|
name: string;
|
|
10
|
-
type:
|
|
18
|
+
type: Children;
|
|
11
19
|
/** If the parmaeter is optional(without default value) */
|
|
12
20
|
optional?: boolean;
|
|
13
21
|
/** Default value for the parameter */
|
|
14
|
-
default?:
|
|
15
|
-
refkey?:
|
|
16
|
-
symbol?:
|
|
22
|
+
default?: Children;
|
|
23
|
+
refkey?: Refkey;
|
|
24
|
+
symbol?: OutputSymbol;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
/** Define a parameter to be used in class or interface method. */
|
|
@@ -31,28 +39,36 @@ export function Parameter(props: ParameterProps) {
|
|
|
31
39
|
|
|
32
40
|
const memberSymbol = new CSharpOutputSymbol(name, {
|
|
33
41
|
scope,
|
|
34
|
-
refkeys: props.refkey ??
|
|
42
|
+
refkeys: props.refkey ?? refkey(props.name),
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
return (
|
|
38
|
-
<
|
|
46
|
+
<Declaration symbol={memberSymbol}>
|
|
39
47
|
{props.type}
|
|
40
48
|
{props.optional ? "?" : ""} <Name />
|
|
41
49
|
{props.default ? code` = ${props.default}` : ""}
|
|
42
|
-
</
|
|
50
|
+
</Declaration>
|
|
43
51
|
);
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
export interface ParametersProps {
|
|
47
|
-
|
|
48
|
-
parameters: ParameterProps[];
|
|
55
|
+
parameters: ParameterProps[] | undefined;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
/** Render a collection of parameters */
|
|
52
59
|
export function Parameters(props: ParametersProps) {
|
|
53
60
|
return (
|
|
54
|
-
<
|
|
55
|
-
{(
|
|
56
|
-
|
|
61
|
+
<group>
|
|
62
|
+
{"("}
|
|
63
|
+
{props.parameters && (
|
|
64
|
+
<Indent softline>
|
|
65
|
+
<For each={props.parameters} joiner={", "}>
|
|
66
|
+
{(param) => <Parameter {...param} />}
|
|
67
|
+
</For>
|
|
68
|
+
</Indent>
|
|
69
|
+
)}
|
|
70
|
+
<softline />
|
|
71
|
+
{")"}
|
|
72
|
+
</group>
|
|
57
73
|
);
|
|
58
74
|
}
|
|
@@ -29,6 +29,11 @@ export interface PropertyModifiers {
|
|
|
29
29
|
readonly abstract?: boolean;
|
|
30
30
|
readonly extern?: boolean;
|
|
31
31
|
readonly readonly?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Set required modifier on property
|
|
34
|
+
* https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/required
|
|
35
|
+
*/
|
|
36
|
+
readonly required?: boolean;
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
const getModifiers = makeModifiers<PropertyModifiers>([
|
|
@@ -40,6 +45,7 @@ const getModifiers = makeModifiers<PropertyModifiers>([
|
|
|
40
45
|
"abstract",
|
|
41
46
|
"extern",
|
|
42
47
|
"readonly",
|
|
48
|
+
"required",
|
|
43
49
|
]);
|
|
44
50
|
|
|
45
51
|
/** Properties for {@link Property} component */
|
package/temp/api.json
CHANGED
|
@@ -5722,7 +5722,7 @@
|
|
|
5722
5722
|
},
|
|
5723
5723
|
{
|
|
5724
5724
|
"kind": "Reference",
|
|
5725
|
-
"text": "
|
|
5725
|
+
"text": "Children",
|
|
5726
5726
|
"canonicalReference": "@alloy-js/core!Children:type"
|
|
5727
5727
|
},
|
|
5728
5728
|
{
|
|
@@ -5730,7 +5730,7 @@
|
|
|
5730
5730
|
"text": ";"
|
|
5731
5731
|
}
|
|
5732
5732
|
],
|
|
5733
|
-
"fileUrlPath": "src/components/
|
|
5733
|
+
"fileUrlPath": "src/components/parameters/parameters.tsx",
|
|
5734
5734
|
"returnTypeTokenRange": {
|
|
5735
5735
|
"startIndex": 3,
|
|
5736
5736
|
"endIndex": 4
|
|
@@ -5759,7 +5759,7 @@
|
|
|
5759
5759
|
"text": "export interface ParameterProps "
|
|
5760
5760
|
}
|
|
5761
5761
|
],
|
|
5762
|
-
"fileUrlPath": "src/components/
|
|
5762
|
+
"fileUrlPath": "src/components/parameters/parameters.tsx",
|
|
5763
5763
|
"releaseTag": "Public",
|
|
5764
5764
|
"name": "ParameterProps",
|
|
5765
5765
|
"preserveMemberOrder": false,
|
|
@@ -5775,7 +5775,7 @@
|
|
|
5775
5775
|
},
|
|
5776
5776
|
{
|
|
5777
5777
|
"kind": "Reference",
|
|
5778
|
-
"text": "
|
|
5778
|
+
"text": "Children",
|
|
5779
5779
|
"canonicalReference": "@alloy-js/core!Children:type"
|
|
5780
5780
|
},
|
|
5781
5781
|
{
|
|
@@ -5857,7 +5857,7 @@
|
|
|
5857
5857
|
},
|
|
5858
5858
|
{
|
|
5859
5859
|
"kind": "Reference",
|
|
5860
|
-
"text": "
|
|
5860
|
+
"text": "Refkey",
|
|
5861
5861
|
"canonicalReference": "@alloy-js/core!Refkey:type"
|
|
5862
5862
|
},
|
|
5863
5863
|
{
|
|
@@ -5885,7 +5885,7 @@
|
|
|
5885
5885
|
},
|
|
5886
5886
|
{
|
|
5887
5887
|
"kind": "Reference",
|
|
5888
|
-
"text": "
|
|
5888
|
+
"text": "OutputSymbol",
|
|
5889
5889
|
"canonicalReference": "@alloy-js/core!OutputSymbol:class"
|
|
5890
5890
|
},
|
|
5891
5891
|
{
|
|
@@ -5913,7 +5913,7 @@
|
|
|
5913
5913
|
},
|
|
5914
5914
|
{
|
|
5915
5915
|
"kind": "Reference",
|
|
5916
|
-
"text": "
|
|
5916
|
+
"text": "Children",
|
|
5917
5917
|
"canonicalReference": "@alloy-js/core!Children:type"
|
|
5918
5918
|
},
|
|
5919
5919
|
{
|
|
@@ -5936,7 +5936,7 @@
|
|
|
5936
5936
|
{
|
|
5937
5937
|
"kind": "Function",
|
|
5938
5938
|
"canonicalReference": "@alloy-js/csharp!Parameters_2:function(1)",
|
|
5939
|
-
"docComment": "",
|
|
5939
|
+
"docComment": "/**\n * Render a collection of parameters\n */\n",
|
|
5940
5940
|
"excerptTokens": [
|
|
5941
5941
|
{
|
|
5942
5942
|
"kind": "Content",
|
|
@@ -5953,7 +5953,7 @@
|
|
|
5953
5953
|
},
|
|
5954
5954
|
{
|
|
5955
5955
|
"kind": "Reference",
|
|
5956
|
-
"text": "
|
|
5956
|
+
"text": "Children",
|
|
5957
5957
|
"canonicalReference": "@alloy-js/core!Children:type"
|
|
5958
5958
|
},
|
|
5959
5959
|
{
|
|
@@ -5961,7 +5961,7 @@
|
|
|
5961
5961
|
"text": ";"
|
|
5962
5962
|
}
|
|
5963
5963
|
],
|
|
5964
|
-
"fileUrlPath": "src/components/
|
|
5964
|
+
"fileUrlPath": "src/components/parameters/parameters.tsx",
|
|
5965
5965
|
"returnTypeTokenRange": {
|
|
5966
5966
|
"startIndex": 3,
|
|
5967
5967
|
"endIndex": 4
|
|
@@ -5990,7 +5990,7 @@
|
|
|
5990
5990
|
"text": "export interface ParametersProps "
|
|
5991
5991
|
}
|
|
5992
5992
|
],
|
|
5993
|
-
"fileUrlPath": "src/components/
|
|
5993
|
+
"fileUrlPath": "src/components/parameters/parameters.tsx",
|
|
5994
5994
|
"releaseTag": "Public",
|
|
5995
5995
|
"name": "ParametersProps",
|
|
5996
5996
|
"preserveMemberOrder": false,
|
|
@@ -6011,7 +6011,7 @@
|
|
|
6011
6011
|
},
|
|
6012
6012
|
{
|
|
6013
6013
|
"kind": "Content",
|
|
6014
|
-
"text": "[]"
|
|
6014
|
+
"text": "[] | undefined"
|
|
6015
6015
|
},
|
|
6016
6016
|
{
|
|
6017
6017
|
"kind": "Content",
|
|
@@ -6482,6 +6482,33 @@
|
|
|
6482
6482
|
"endIndex": 2
|
|
6483
6483
|
}
|
|
6484
6484
|
},
|
|
6485
|
+
{
|
|
6486
|
+
"kind": "PropertySignature",
|
|
6487
|
+
"canonicalReference": "@alloy-js/csharp!PropertyModifiers#required:member",
|
|
6488
|
+
"docComment": "/**\n * Set required modifier on property\n * https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/required\n */\n",
|
|
6489
|
+
"excerptTokens": [
|
|
6490
|
+
{
|
|
6491
|
+
"kind": "Content",
|
|
6492
|
+
"text": "readonly required?: "
|
|
6493
|
+
},
|
|
6494
|
+
{
|
|
6495
|
+
"kind": "Content",
|
|
6496
|
+
"text": "boolean"
|
|
6497
|
+
},
|
|
6498
|
+
{
|
|
6499
|
+
"kind": "Content",
|
|
6500
|
+
"text": ";"
|
|
6501
|
+
}
|
|
6502
|
+
],
|
|
6503
|
+
"isReadonly": true,
|
|
6504
|
+
"isOptional": true,
|
|
6505
|
+
"releaseTag": "Public",
|
|
6506
|
+
"name": "required",
|
|
6507
|
+
"propertyTypeTokenRange": {
|
|
6508
|
+
"startIndex": 1,
|
|
6509
|
+
"endIndex": 2
|
|
6510
|
+
}
|
|
6511
|
+
},
|
|
6485
6512
|
{
|
|
6486
6513
|
"kind": "PropertySignature",
|
|
6487
6514
|
"canonicalReference": "@alloy-js/csharp!PropertyModifiers#sealed:member",
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as core from "@alloy-js/core";
|
|
2
|
-
export interface ParameterProps {
|
|
3
|
-
name: string;
|
|
4
|
-
type: core.Children;
|
|
5
|
-
/** If the parmaeter is optional(without default value) */
|
|
6
|
-
optional?: boolean;
|
|
7
|
-
/** Default value for the parameter */
|
|
8
|
-
default?: core.Children;
|
|
9
|
-
refkey?: core.Refkey;
|
|
10
|
-
symbol?: core.OutputSymbol;
|
|
11
|
-
}
|
|
12
|
-
/** Define a parameter to be used in class or interface method. */
|
|
13
|
-
export declare function Parameter(props: ParameterProps): core.Children;
|
|
14
|
-
export interface ParametersProps {
|
|
15
|
-
parameters: ParameterProps[];
|
|
16
|
-
}
|
|
17
|
-
export declare function Parameters(props: ParametersProps): core.Children;
|
|
18
|
-
//# sourceMappingURL=Parameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Parameters.d.ts","sourceRoot":"","sources":["../../../src/components/Parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAOvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACxB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;CAC5B;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,iBAwB9C;AAED,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAMhD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import * as core from "@alloy-js/core";
|
|
3
|
-
import { code } from "@alloy-js/core";
|
|
4
|
-
import { useCSharpNamePolicy } from "../name-policy.js";
|
|
5
|
-
import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
|
|
6
|
-
import { useCSharpScope } from "../symbols/scopes.js";
|
|
7
|
-
import { Name } from "./Name.js";
|
|
8
|
-
/** Define a parameter to be used in class or interface method. */
|
|
9
|
-
export function Parameter(props) {
|
|
10
|
-
const name = useCSharpNamePolicy().getName(props.name, "parameter");
|
|
11
|
-
const scope = useCSharpScope();
|
|
12
|
-
if (scope.kind !== "member" || scope.name !== "constructor-decl" && scope.name !== "method-decl") {
|
|
13
|
-
throw new Error("can't define a parameter outside of a constructor-decl or method-decl scope");
|
|
14
|
-
}
|
|
15
|
-
const memberSymbol = new CSharpOutputSymbol(name, {
|
|
16
|
-
scope,
|
|
17
|
-
refkeys: props.refkey ?? core.refkey(props.name)
|
|
18
|
-
});
|
|
19
|
-
return _$createComponent(core.Declaration, {
|
|
20
|
-
symbol: memberSymbol,
|
|
21
|
-
get children() {
|
|
22
|
-
return [_$memo(() => props.type), _$memo(() => props.optional ? "?" : ""), " ", _$createComponent(Name, {}), _$memo(() => props.default ? code` = ${props.default}` : "")];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
// a collection of parameters
|
|
27
|
-
export function Parameters(props) {
|
|
28
|
-
return _$createComponent(core.For, {
|
|
29
|
-
get each() {
|
|
30
|
-
return props.parameters;
|
|
31
|
-
},
|
|
32
|
-
joiner: ", ",
|
|
33
|
-
children: param => _$createComponent(Parameter, param)
|
|
34
|
-
});
|
|
35
|
-
}
|