@alloy-js/csharp 0.18.0-dev.24 → 0.18.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/Class.d.ts +23 -0
- package/dist/src/components/Class.d.ts.map +1 -0
- package/dist/src/components/{ClassDeclaration.js → Class.js} +37 -67
- package/dist/src/components/ClassMethod.d.ts +3 -44
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +8 -32
- package/dist/src/components/Enum.d.ts +14 -0
- package/dist/src/components/Enum.d.ts.map +1 -0
- package/dist/src/components/{EnumDeclaration.js → Enum.js} +2 -21
- package/dist/src/components/Parameters.d.ts +13 -0
- package/dist/src/components/Parameters.d.ts.map +1 -0
- package/dist/src/components/Parameters.js +34 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +0 -1
- package/dist/src/components/index.d.ts +4 -14
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +5 -15
- package/dist/src/components/stc/index.d.ts +2 -2
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js +2 -2
- package/dist/src/modifiers.d.ts +9 -2
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +9 -6
- package/dist/src/name-policy.d.ts +1 -1
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +0 -2
- package/dist/test/class-method.test.js +2 -23
- package/dist/test/class.test.d.ts +2 -0
- package/dist/test/class.test.d.ts.map +1 -0
- package/dist/test/{class-declaration.test.js → class.test.js} +51 -234
- package/dist/test/enum.test.js +6 -6
- package/dist/test/namespace.test.js +4 -4
- package/dist/test/projectdirectory.test.d.ts +2 -0
- package/dist/test/projectdirectory.test.d.ts.map +1 -0
- package/dist/test/{project-directory.test.js → projectdirectory.test.js} +4 -4
- package/dist/test/sourcefile.test.js +2 -2
- package/dist/test/using.test.js +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/src/components/{ClassDeclaration.tsx → Class.tsx} +38 -116
- package/src/components/ClassMethod.tsx +7 -70
- package/src/components/{EnumDeclaration.tsx → Enum.tsx} +3 -22
- package/src/components/Parameters.tsx +51 -0
- package/src/components/SourceFile.tsx +0 -1
- package/src/components/index.ts +4 -14
- package/src/components/stc/index.ts +2 -2
- package/src/modifiers.ts +30 -16
- package/src/name-policy.ts +0 -5
- package/temp/api.json +1194 -6218
- package/test/class-method.test.tsx +3 -19
- package/test/class.test.tsx +257 -0
- package/test/enum.test.tsx +11 -13
- package/test/namespace.test.tsx +4 -4
- package/test/{project-directory.test.tsx → projectdirectory.test.tsx} +4 -4
- package/test/sourcefile.test.tsx +2 -2
- package/test/using.test.tsx +6 -14
- package/vitest.config.ts +0 -3
- package/dist/src/components/ClassDeclaration.d.ts +0 -92
- package/dist/src/components/ClassDeclaration.d.ts.map +0 -1
- package/dist/src/components/EnumDeclaration.d.ts +0 -34
- package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
- package/dist/src/components/attributes/attributes.d.ts +0 -39
- package/dist/src/components/attributes/attributes.d.ts.map +0 -1
- package/dist/src/components/attributes/attributes.js +0 -62
- package/dist/src/components/attributes/attributes.test.d.ts +0 -2
- package/dist/src/components/attributes/attributes.test.d.ts.map +0 -1
- package/dist/src/components/attributes/attributes.test.js +0 -75
- package/dist/src/components/doc/comment.d.ts +0 -70
- package/dist/src/components/doc/comment.d.ts.map +0 -1
- package/dist/src/components/doc/comment.js +0 -88
- package/dist/src/components/doc/comment.test.d.ts +0 -2
- package/dist/src/components/doc/comment.test.d.ts.map +0 -1
- package/dist/src/components/doc/comment.test.js +0 -348
- package/dist/src/components/doc/from-markdown.d.ts +0 -6
- package/dist/src/components/doc/from-markdown.d.ts.map +0 -1
- package/dist/src/components/doc/from-markdown.js +0 -58
- package/dist/src/components/doc/from-markdown.test.d.ts +0 -2
- package/dist/src/components/doc/from-markdown.test.d.ts.map +0 -1
- package/dist/src/components/doc/from-markdown.test.js +0 -83
- package/dist/src/components/interface/declaration.d.ts +0 -65
- package/dist/src/components/interface/declaration.d.ts.map +0 -1
- package/dist/src/components/interface/declaration.js +0 -83
- package/dist/src/components/interface/declaration.test.d.ts +0 -2
- package/dist/src/components/interface/declaration.test.d.ts.map +0 -1
- package/dist/src/components/interface/declaration.test.js +0 -171
- package/dist/src/components/interface/method.d.ts +0 -50
- package/dist/src/components/interface/method.d.ts.map +0 -1
- package/dist/src/components/interface/method.js +0 -74
- package/dist/src/components/interface/method.test.d.ts +0 -2
- package/dist/src/components/interface/method.test.d.ts.map +0 -1
- package/dist/src/components/interface/method.test.js +0 -300
- package/dist/src/components/interface/property.d.ts +0 -56
- package/dist/src/components/interface/property.d.ts.map +0 -1
- package/dist/src/components/interface/property.js +0 -73
- package/dist/src/components/interface/property.test.d.ts +0 -2
- package/dist/src/components/interface/property.test.d.ts.map +0 -1
- package/dist/src/components/interface/property.test.js +0 -189
- package/dist/src/components/parameters/parameters.d.ts +0 -19
- package/dist/src/components/parameters/parameters.d.ts.map +0 -1
- package/dist/src/components/parameters/parameters.js +0 -43
- package/dist/src/components/property/property.d.ts +0 -80
- package/dist/src/components/property/property.d.ts.map +0 -1
- package/dist/src/components/property/property.js +0 -76
- package/dist/src/components/property/property.test.d.ts +0 -2
- package/dist/src/components/property/property.test.d.ts.map +0 -1
- package/dist/src/components/property/property.test.js +0 -242
- package/dist/src/components/record/declaration.d.ts +0 -35
- package/dist/src/components/record/declaration.d.ts.map +0 -1
- package/dist/src/components/record/declaration.js +0 -90
- package/dist/src/components/record/declaration.test.d.ts +0 -2
- package/dist/src/components/record/declaration.test.d.ts.map +0 -1
- package/dist/src/components/record/declaration.test.js +0 -94
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +0 -8
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.js +0 -44
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +0 -2
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +0 -67
- package/dist/src/components/type-parameters/type-parameter.d.ts +0 -20
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameter.js +0 -22
- package/dist/src/components/type-parameters/type-parameters.d.ts +0 -17
- package/dist/src/components/type-parameters/type-parameters.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameters.js +0 -54
- package/dist/src/components/type-parameters/type-parameters.test.d.ts +0 -2
- package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +0 -1
- package/dist/src/components/type-parameters/type-parameters.test.js +0 -48
- package/dist/src/components/var/declaration.d.ts +0 -35
- package/dist/src/components/var/declaration.d.ts.map +0 -1
- package/dist/src/components/var/declaration.js +0 -40
- package/dist/src/components/var/declaration.test.d.ts +0 -2
- package/dist/src/components/var/declaration.test.d.ts.map +0 -1
- package/dist/src/components/var/declaration.test.js +0 -73
- package/dist/test/class-declaration.test.d.ts +0 -2
- package/dist/test/class-declaration.test.d.ts.map +0 -1
- package/dist/test/project-directory.test.d.ts +0 -2
- package/dist/test/project-directory.test.d.ts.map +0 -1
- package/dist/test/vitest.setup.d.ts +0 -2
- package/dist/test/vitest.setup.d.ts.map +0 -1
- package/dist/test/vitest.setup.js +0 -1
- package/src/components/attributes/attributes.test.tsx +0 -61
- package/src/components/attributes/attributes.tsx +0 -100
- package/src/components/doc/comment.test.tsx +0 -337
- package/src/components/doc/comment.tsx +0 -152
- package/src/components/doc/from-markdown.test.tsx +0 -103
- package/src/components/doc/from-markdown.tsx +0 -58
- package/src/components/interface/declaration.test.tsx +0 -158
- package/src/components/interface/declaration.tsx +0 -125
- package/src/components/interface/method.test.tsx +0 -293
- package/src/components/interface/method.tsx +0 -122
- package/src/components/interface/property.test.tsx +0 -165
- package/src/components/interface/property.tsx +0 -127
- package/src/components/parameters/parameters.tsx +0 -74
- package/src/components/property/property.test.tsx +0 -209
- package/src/components/property/property.tsx +0 -172
- package/src/components/record/declaration.test.tsx +0 -73
- package/src/components/record/declaration.tsx +0 -109
- package/src/components/type-parameters/type-parameter-constraints.test.tsx +0 -93
- package/src/components/type-parameters/type-parameter-constraints.tsx +0 -46
- package/src/components/type-parameters/type-parameter.tsx +0 -35
- package/src/components/type-parameters/type-parameters.test.tsx +0 -46
- package/src/components/type-parameters/type-parameters.tsx +0 -63
- package/src/components/var/declaration.test.tsx +0 -59
- package/src/components/var/declaration.tsx +0 -47
- package/test/class-declaration.test.tsx +0 -430
- package/test/vitest.setup.ts +0 -1
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { code, For, Indent } from "@alloy-js/core";
|
|
3
|
-
import { normalizeParameters } from "./type-parameters.js";
|
|
4
|
-
export function TypeParameterConstraints(props) {
|
|
5
|
-
const parameters = normalizeParameters(props.parameters);
|
|
6
|
-
if (!parameters.some(x => x.constraints)) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
return _$createIntrinsic("group", {
|
|
10
|
-
get children() {
|
|
11
|
-
return _$createComponent(Indent, {
|
|
12
|
-
line: true,
|
|
13
|
-
get children() {
|
|
14
|
-
return _$createComponent(For, {
|
|
15
|
-
each: parameters,
|
|
16
|
-
hardline: true,
|
|
17
|
-
children: param => _$createComponent(TypeParameterConstraint, param)
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function TypeParameterConstraint(props) {
|
|
25
|
-
const constraints = arrayify(props.constraints);
|
|
26
|
-
return ["where ", _$memo(() => code`${props.name} : `), _$createIntrinsic("group", {
|
|
27
|
-
get children() {
|
|
28
|
-
return _$createComponent(Indent, {
|
|
29
|
-
softline: true,
|
|
30
|
-
get children() {
|
|
31
|
-
return _$createComponent(For, {
|
|
32
|
-
each: constraints,
|
|
33
|
-
comma: true,
|
|
34
|
-
line: true,
|
|
35
|
-
children: constraint => code`${constraint}`
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
})];
|
|
41
|
-
}
|
|
42
|
-
function arrayify(value) {
|
|
43
|
-
return Array.isArray(value) ? value : [value];
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-parameter-constraints.test.d.ts","sourceRoot":"","sources":["../../../../src/components/type-parameters/type-parameter-constraints.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { expect, it } from "vitest";
|
|
3
|
-
import { TypeParameterConstraints } from "./type-parameter-constraints.js";
|
|
4
|
-
it("renders nothing if there is no constraints", () => {
|
|
5
|
-
expect(_$createComponent(TypeParameterConstraints, {
|
|
6
|
-
parameters: ["A", "B"]
|
|
7
|
-
})).toRenderTo(``);
|
|
8
|
-
});
|
|
9
|
-
it("renders inline if there is only one", () => {
|
|
10
|
-
expect(["code()", _$createComponent(TypeParameterConstraints, {
|
|
11
|
-
parameters: [{
|
|
12
|
-
name: "A",
|
|
13
|
-
constraints: "string"
|
|
14
|
-
}]
|
|
15
|
-
})]).toRenderTo(`
|
|
16
|
-
code() where A : string
|
|
17
|
-
`);
|
|
18
|
-
});
|
|
19
|
-
it("renders multiple constraints", () => {
|
|
20
|
-
expect(["code()", _$createComponent(TypeParameterConstraints, {
|
|
21
|
-
parameters: [{
|
|
22
|
-
name: "A",
|
|
23
|
-
constraints: ["string", "int"]
|
|
24
|
-
}]
|
|
25
|
-
})]).toRenderTo(`
|
|
26
|
-
code() where A : string, int
|
|
27
|
-
`);
|
|
28
|
-
});
|
|
29
|
-
it("renders newline if constraint is very long", () => {
|
|
30
|
-
expect(["code()", _$createComponent(TypeParameterConstraints, {
|
|
31
|
-
parameters: [{
|
|
32
|
-
name: "ThisIsQuiteALongName",
|
|
33
|
-
constraints: "VeryLongBuilderFactorySingletonThatShouldBeSplit"
|
|
34
|
-
}]
|
|
35
|
-
})]).toRenderTo(`
|
|
36
|
-
code()
|
|
37
|
-
where ThisIsQuiteALongName : VeryLongBuilderFactorySingletonThatShouldBeSplit
|
|
38
|
-
`);
|
|
39
|
-
});
|
|
40
|
-
it("renders multiple constraints on new lines if they are very long", () => {
|
|
41
|
-
expect(["code()", _$createComponent(TypeParameterConstraints, {
|
|
42
|
-
parameters: [{
|
|
43
|
-
name: "A",
|
|
44
|
-
constraints: ["IVeryLongBuilderFactorySingletonThatShouldBeSplitA", "IVeryLongBuilderFactorySingletonThatShouldBeSplitB"]
|
|
45
|
-
}]
|
|
46
|
-
})]).toRenderTo(`
|
|
47
|
-
code()
|
|
48
|
-
where A :
|
|
49
|
-
IVeryLongBuilderFactorySingletonThatShouldBeSplitA,
|
|
50
|
-
IVeryLongBuilderFactorySingletonThatShouldBeSplitB
|
|
51
|
-
`);
|
|
52
|
-
});
|
|
53
|
-
it("declare type parameters using parameters", () => {
|
|
54
|
-
expect(["code()", _$createComponent(TypeParameterConstraints, {
|
|
55
|
-
parameters: [{
|
|
56
|
-
name: "A",
|
|
57
|
-
constraints: "string"
|
|
58
|
-
}, {
|
|
59
|
-
name: "B",
|
|
60
|
-
constraints: "string"
|
|
61
|
-
}]
|
|
62
|
-
})]).toRenderTo(`
|
|
63
|
-
code()
|
|
64
|
-
where A : string
|
|
65
|
-
where B : string
|
|
66
|
-
`);
|
|
67
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
-
/**
|
|
3
|
-
* Information for a TypeScript generic type parameter.
|
|
4
|
-
*/
|
|
5
|
-
export interface TypeParameterProps {
|
|
6
|
-
/**
|
|
7
|
-
* The name of the type parameter.
|
|
8
|
-
*/
|
|
9
|
-
readonly name: string;
|
|
10
|
-
/**
|
|
11
|
-
* The parameter constraint
|
|
12
|
-
*/
|
|
13
|
-
readonly constraints?: Children | Children[];
|
|
14
|
-
/**
|
|
15
|
-
* A refkey or array of refkeys for this type parameter.
|
|
16
|
-
*/
|
|
17
|
-
readonly refkey?: Refkey | Refkey[];
|
|
18
|
-
}
|
|
19
|
-
export declare function TypeParameter(props: TypeParameterProps): Children;
|
|
20
|
-
//# sourceMappingURL=type-parameter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-parameter.d.ts","sourceRoot":"","sources":["../../../../src/components/type-parameters/type-parameter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6B,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAK7E;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAE7C;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACrC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAStD"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { MemberDeclaration, 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
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Information for a TypeScript generic type parameter.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export function TypeParameter(props) {
|
|
12
|
-
const name = useCSharpNamePolicy().getName(props.name, "type-parameter");
|
|
13
|
-
const scope = useCSharpScope();
|
|
14
|
-
const symbol = new CSharpOutputSymbol(name, {
|
|
15
|
-
scope,
|
|
16
|
-
refkeys: props.refkey ?? refkey(props.name)
|
|
17
|
-
});
|
|
18
|
-
return _$createComponent(MemberDeclaration, {
|
|
19
|
-
symbol: symbol,
|
|
20
|
-
children: name
|
|
21
|
-
});
|
|
22
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { TypeParameterProps } from "./type-parameter.jsx";
|
|
2
|
-
export declare const typeParametersTag: unique symbol;
|
|
3
|
-
export interface TypeParametersProps {
|
|
4
|
-
/** Parameters */
|
|
5
|
-
parameters: (TypeParameterProps | string)[];
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Represent type parameters
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* <A, B extends string>
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare const TypeParameters: import("@alloy-js/core").Component<TypeParametersProps> & Required<Pick<import("@alloy-js/core").Component<TypeParametersProps>, "tag">>;
|
|
16
|
-
export declare function normalizeParameters(parameters: (TypeParameterProps | string)[]): TypeParameterProps[];
|
|
17
|
-
//# sourceMappingURL=type-parameters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-parameters.d.ts","sourceRoot":"","sources":["../../../../src/components/type-parameters/type-parameters.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,eAAO,MAAM,iBAAiB,eAAuC,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,iBAAiB;IACjB,UAAU,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,0IAmB1B,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,GAC1C,kBAAkB,EAAE,CAOtB"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { For, Indent, taggedComponent } from "@alloy-js/core";
|
|
3
|
-
import { TypeParameter } from "./type-parameter.js";
|
|
4
|
-
export const typeParametersTag = Symbol.for("csharp.type-parameters");
|
|
5
|
-
/**
|
|
6
|
-
* Represent type parameters
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* <A, B extends string>
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export const TypeParameters = taggedComponent(typeParametersTag, function TypeParameters(props) {
|
|
14
|
-
const typeParameters = normalizeParameters(props.parameters);
|
|
15
|
-
return ["<", _$createIntrinsic("group", {
|
|
16
|
-
get children() {
|
|
17
|
-
return _$createComponent(Indent, {
|
|
18
|
-
softline: true,
|
|
19
|
-
get children() {
|
|
20
|
-
return _$createComponent(For, {
|
|
21
|
-
each: typeParameters,
|
|
22
|
-
comma: true,
|
|
23
|
-
line: true,
|
|
24
|
-
children: param => _$createComponent(TypeParameter, param)
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}), ">"];
|
|
30
|
-
});
|
|
31
|
-
export function normalizeParameters(parameters) {
|
|
32
|
-
return parameters.map(param => {
|
|
33
|
-
if (typeof param === "string") {
|
|
34
|
-
return {
|
|
35
|
-
name: param
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return param;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// export function declareParameter(
|
|
43
|
-
// parameters: TypeParameterProps[],
|
|
44
|
-
// ): TypeParameterProps[] {
|
|
45
|
-
// return parameters.map((param) => {
|
|
46
|
-
// return {
|
|
47
|
-
// ...param,
|
|
48
|
-
// symbol: new CSharpOutputSymbol(entry[0], {
|
|
49
|
-
// scope: thisClassScope,
|
|
50
|
-
// refkeys: entry[1],
|
|
51
|
-
// }),
|
|
52
|
-
// };
|
|
53
|
-
// });
|
|
54
|
-
// }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-parameters.test.d.ts","sourceRoot":"","sources":["../../../../src/components/type-parameters/type-parameters.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { expect, it } from "vitest";
|
|
3
|
-
import { TestNamespace } from "../../../test/utils.js";
|
|
4
|
-
import { TypeParameters } from "./type-parameters.js";
|
|
5
|
-
it("render one", () => {
|
|
6
|
-
expect(_$createComponent(TestNamespace, {
|
|
7
|
-
get children() {
|
|
8
|
-
return _$createComponent(TypeParameters, {
|
|
9
|
-
parameters: ["A"]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
})).toRenderTo(`<A>`);
|
|
13
|
-
});
|
|
14
|
-
it("render very long", () => {
|
|
15
|
-
expect(_$createComponent(TestNamespace, {
|
|
16
|
-
get children() {
|
|
17
|
-
return _$createComponent(TypeParameters, {
|
|
18
|
-
parameters: ["SomeVeryVeryLongParamThatMightGetSplitOverMultipleLinesA", "SomeVeryVeryLongParamThatMightGetSplitOverMultipleLinesB"]
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
})).toRenderTo(`
|
|
22
|
-
<
|
|
23
|
-
SomeVeryVeryLongParamThatMightGetSplitOverMultipleLinesA,
|
|
24
|
-
SomeVeryVeryLongParamThatMightGetSplitOverMultipleLinesB>
|
|
25
|
-
`);
|
|
26
|
-
});
|
|
27
|
-
it("declare type parameters using parameters names", () => {
|
|
28
|
-
expect(_$createComponent(TestNamespace, {
|
|
29
|
-
get children() {
|
|
30
|
-
return _$createComponent(TypeParameters, {
|
|
31
|
-
parameters: ["A", "B"]
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
})).toRenderTo(`<A, B>`);
|
|
35
|
-
});
|
|
36
|
-
it("declare type parameters using parameters", () => {
|
|
37
|
-
expect(_$createComponent(TestNamespace, {
|
|
38
|
-
get children() {
|
|
39
|
-
return _$createComponent(TypeParameters, {
|
|
40
|
-
parameters: [{
|
|
41
|
-
name: "A"
|
|
42
|
-
}, {
|
|
43
|
-
name: "B"
|
|
44
|
-
}]
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
})).toRenderTo(`<A, B>`);
|
|
48
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Children, DeclarationProps, Refkey } from "@alloy-js/core";
|
|
2
|
-
/** Props for {@link VarDeclaration} component */
|
|
3
|
-
export interface VarDeclarationProps extends Omit<DeclarationProps, "nameKind"> {
|
|
4
|
-
/** Variable name */
|
|
5
|
-
name: string;
|
|
6
|
-
/** Type of the variable declaration. If not specified, defaults to "var" */
|
|
7
|
-
type?: Children;
|
|
8
|
-
/** Variable refkey */
|
|
9
|
-
refkey?: Refkey;
|
|
10
|
-
/** Variable value */
|
|
11
|
-
children?: Children;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Render a variable declaration
|
|
15
|
-
*
|
|
16
|
-
* @example with var
|
|
17
|
-
* ```tsx
|
|
18
|
-
* <VarDeclaration name="myVar">42</VarDeclaration>
|
|
19
|
-
* ```
|
|
20
|
-
* This will render:
|
|
21
|
-
* ```csharp
|
|
22
|
-
* var myVar = 42;
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @example with type
|
|
26
|
-
* ```tsx
|
|
27
|
-
* <VarDeclaration name="myVar" type="int">42</VarDeclaration>
|
|
28
|
-
* ```
|
|
29
|
-
* This will render:
|
|
30
|
-
* ```csharp
|
|
31
|
-
* int myVar = 42;
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function VarDeclaration(props: VarDeclarationProps): Children;
|
|
35
|
-
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/var/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAQ,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI1E,iDAAiD;AACjD,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC;IAC1C,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,YAQxD"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Name } from "@alloy-js/core";
|
|
3
|
-
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
4
|
-
import { Declaration } from "../Declaration.js";
|
|
5
|
-
|
|
6
|
-
/** Props for {@link VarDeclaration} component */
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Render a variable declaration
|
|
10
|
-
*
|
|
11
|
-
* @example with var
|
|
12
|
-
* ```tsx
|
|
13
|
-
* <VarDeclaration name="myVar">42</VarDeclaration>
|
|
14
|
-
* ```
|
|
15
|
-
* This will render:
|
|
16
|
-
* ```csharp
|
|
17
|
-
* var myVar = 42;
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @example with type
|
|
21
|
-
* ```tsx
|
|
22
|
-
* <VarDeclaration name="myVar" type="int">42</VarDeclaration>
|
|
23
|
-
* ```
|
|
24
|
-
* This will render:
|
|
25
|
-
* ```csharp
|
|
26
|
-
* int myVar = 42;
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export function VarDeclaration(props) {
|
|
30
|
-
const name = useCSharpNamePolicy().getName(props.name, "variable");
|
|
31
|
-
return _$createComponent(Declaration, {
|
|
32
|
-
name: name,
|
|
33
|
-
get refkey() {
|
|
34
|
-
return props.refkey;
|
|
35
|
-
},
|
|
36
|
-
get children() {
|
|
37
|
-
return [_$memo(() => props.type ?? "var"), " ", _$createComponent(Name, {}), " = ", _$memo(() => props.children), ";"];
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.test.d.ts","sourceRoot":"","sources":["../../../../src/components/var/declaration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { List, refkey } from "@alloy-js/core";
|
|
3
|
-
import { expect, it } from "vitest";
|
|
4
|
-
import { TestNamespace } from "../../../test/utils.js";
|
|
5
|
-
import { SourceFile } from "../SourceFile.js";
|
|
6
|
-
import { VarDeclaration } from "./declaration.js";
|
|
7
|
-
it("declares var without type", () => {
|
|
8
|
-
expect(_$createComponent(TestNamespace, {
|
|
9
|
-
get children() {
|
|
10
|
-
return _$createComponent(VarDeclaration, {
|
|
11
|
-
name: "testVar",
|
|
12
|
-
children: "42"
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
})).toRenderTo(`
|
|
16
|
-
var testVar = 42;
|
|
17
|
-
`);
|
|
18
|
-
});
|
|
19
|
-
it("declares var with type", () => {
|
|
20
|
-
expect(_$createComponent(TestNamespace, {
|
|
21
|
-
get children() {
|
|
22
|
-
return _$createComponent(VarDeclaration, {
|
|
23
|
-
name: "testVar",
|
|
24
|
-
type: "int",
|
|
25
|
-
children: "42"
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
})).toRenderTo(`
|
|
29
|
-
int testVar = 42;
|
|
30
|
-
`);
|
|
31
|
-
});
|
|
32
|
-
it("name variables camel case", () => {
|
|
33
|
-
expect(_$createComponent(TestNamespace, {
|
|
34
|
-
get children() {
|
|
35
|
-
return _$createComponent(VarDeclaration, {
|
|
36
|
-
name: "test_var",
|
|
37
|
-
children: "42"
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
})).toRenderTo(`
|
|
41
|
-
var testVar = 42;
|
|
42
|
-
`);
|
|
43
|
-
});
|
|
44
|
-
it("links refkey", () => {
|
|
45
|
-
const key = refkey();
|
|
46
|
-
expect(_$createComponent(TestNamespace, {
|
|
47
|
-
get children() {
|
|
48
|
-
return _$createComponent(SourceFile, {
|
|
49
|
-
path: "test.cs",
|
|
50
|
-
get children() {
|
|
51
|
-
return _$createComponent(List, {
|
|
52
|
-
get children() {
|
|
53
|
-
return [_$createComponent(VarDeclaration, {
|
|
54
|
-
name: "testVar",
|
|
55
|
-
refkey: key,
|
|
56
|
-
children: "42"
|
|
57
|
-
}), _$createComponent(VarDeclaration, {
|
|
58
|
-
name: "testVar2",
|
|
59
|
-
children: key
|
|
60
|
-
})];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
})).toRenderTo(`
|
|
67
|
-
namespace TestCode
|
|
68
|
-
{
|
|
69
|
-
var testVar = 42;
|
|
70
|
-
var testVar2 = testVar;
|
|
71
|
-
}
|
|
72
|
-
`);
|
|
73
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"class-declaration.test.d.ts","sourceRoot":"","sources":["../../test/class-declaration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-directory.test.d.ts","sourceRoot":"","sources":["../../test/project-directory.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.setup.d.ts","sourceRoot":"","sources":["../../test/vitest.setup.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "@alloy-js/core/testing";
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { expect, it } from "vitest";
|
|
2
|
-
import { Attribute, AttributeList } from "./attributes.jsx";
|
|
3
|
-
|
|
4
|
-
it("define attribute", () => {
|
|
5
|
-
expect(<Attribute name="Test" />).toRenderTo(`
|
|
6
|
-
[Test]
|
|
7
|
-
`);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("define attribute with single arg", () => {
|
|
11
|
-
expect(<Attribute name="Test" args={[`"abc"`]} />).toRenderTo(`
|
|
12
|
-
[Test("abc")]
|
|
13
|
-
`);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("define attribute with multiple arg", () => {
|
|
17
|
-
expect(<Attribute name="Test" args={[`"abc"`, `"def"`]} />).toRenderTo(`
|
|
18
|
-
[Test("abc", "def")]
|
|
19
|
-
`);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("define attribute list with Attribute components", () => {
|
|
23
|
-
expect(
|
|
24
|
-
<AttributeList
|
|
25
|
-
attributes={[<Attribute name="TestA" />, <Attribute name="TestB" />]}
|
|
26
|
-
/>,
|
|
27
|
-
).toRenderTo(`
|
|
28
|
-
[TestA]
|
|
29
|
-
[TestB]
|
|
30
|
-
`);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("define attribute list with attribute names", () => {
|
|
34
|
-
expect(<AttributeList attributes={["TestA", "TestB"]} />).toRenderTo(`
|
|
35
|
-
[TestA]
|
|
36
|
-
[TestB]
|
|
37
|
-
`);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("define attribute list with attribute props", () => {
|
|
41
|
-
expect(
|
|
42
|
-
<AttributeList
|
|
43
|
-
attributes={[{ name: "TestA" }, { name: "TestB", args: [`"test"`] }]}
|
|
44
|
-
/>,
|
|
45
|
-
).toRenderTo(`
|
|
46
|
-
[TestA]
|
|
47
|
-
[TestB("test")]
|
|
48
|
-
`);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("define attribute list with children", () => {
|
|
52
|
-
expect(
|
|
53
|
-
<AttributeList>
|
|
54
|
-
<Attribute name="TestA" />
|
|
55
|
-
<Attribute name="TestB" />
|
|
56
|
-
</AttributeList>,
|
|
57
|
-
).toRenderTo(`
|
|
58
|
-
[TestA]
|
|
59
|
-
[TestB]
|
|
60
|
-
`);
|
|
61
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Children,
|
|
3
|
-
findKeyedChildren,
|
|
4
|
-
For,
|
|
5
|
-
Indent,
|
|
6
|
-
taggedComponent,
|
|
7
|
-
} from "@alloy-js/core";
|
|
8
|
-
|
|
9
|
-
export interface AttributeItem {
|
|
10
|
-
name: string;
|
|
11
|
-
args?: string[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type AttributesProp = Array<string | AttributeProps | Children>;
|
|
15
|
-
|
|
16
|
-
export interface AttributeListProps {
|
|
17
|
-
/** If the attribute list should finish with a hard line if there is any attribute */
|
|
18
|
-
endline?: boolean;
|
|
19
|
-
attributes?: AttributesProp;
|
|
20
|
-
children?: Children[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Render each attributes in a new line.
|
|
25
|
-
*/
|
|
26
|
-
export function AttributeList(props: AttributeListProps) {
|
|
27
|
-
const attributes =
|
|
28
|
-
props.attributes ??
|
|
29
|
-
(props.children && findKeyedChildren(props.children, Attribute.tag));
|
|
30
|
-
|
|
31
|
-
if (!attributes) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<>
|
|
37
|
-
<For each={attributes} line>
|
|
38
|
-
{(arg) => renderAttribute(arg)}
|
|
39
|
-
</For>
|
|
40
|
-
{props.endline && attributes.length > 0 && <hbr />}
|
|
41
|
-
</>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function renderAttribute(attr: string | AttributeProps | Children): Children {
|
|
46
|
-
if (typeof attr === "string") {
|
|
47
|
-
return <Attribute name={attr} />;
|
|
48
|
-
} else if (typeof attr === "object" && attr && "name" in attr) {
|
|
49
|
-
return <Attribute {...attr} />;
|
|
50
|
-
} else {
|
|
51
|
-
return attr;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface AttributeProps {
|
|
56
|
-
/** Attribute name */
|
|
57
|
-
name: Children;
|
|
58
|
-
|
|
59
|
-
/** Argument */
|
|
60
|
-
args?: Children[];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const AttributeTag = Symbol("AttributeTag");
|
|
64
|
-
/**
|
|
65
|
-
* Render a csharp attribute.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* <Attribute name="Test" /><hbr/>
|
|
70
|
-
* <Attribute name="Test" args={["arg1", "arg2"]} />
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* will render:
|
|
74
|
-
* ```csharp
|
|
75
|
-
* [Test]
|
|
76
|
-
* [Test("arg1", "arg2")]
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
export const Attribute = taggedComponent(
|
|
80
|
-
AttributeTag,
|
|
81
|
-
(props: AttributeProps) => {
|
|
82
|
-
return (
|
|
83
|
-
<group>
|
|
84
|
-
[{props.name}
|
|
85
|
-
{props.args && props.args.length > 0 && (
|
|
86
|
-
<>
|
|
87
|
-
(
|
|
88
|
-
<Indent softline>
|
|
89
|
-
<For each={props.args ?? []} comma line>
|
|
90
|
-
{(arg) => arg}
|
|
91
|
-
</For>
|
|
92
|
-
</Indent>
|
|
93
|
-
)
|
|
94
|
-
</>
|
|
95
|
-
)}
|
|
96
|
-
]
|
|
97
|
-
</group>
|
|
98
|
-
);
|
|
99
|
-
},
|
|
100
|
-
);
|