@alloy-js/csharp 0.18.0-dev.19 → 0.18.0-dev.2
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 +26 -0
- package/dist/src/components/Class.d.ts.map +1 -0
- package/dist/src/components/{ClassDeclaration.js → Class.js} +32 -59
- package/dist/src/components/ClassMethod.d.ts +4 -25
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +3 -22
- package/dist/src/components/Enum.d.ts +15 -0
- package/dist/src/components/Enum.d.ts.map +1 -0
- package/dist/src/components/{EnumDeclaration.js → Enum.js} +5 -25
- package/dist/src/components/Parameters.d.ts +1 -6
- package/dist/src/components/Parameters.d.ts.map +1 -1
- package/dist/src/components/Parameters.js +2 -3
- package/dist/src/components/index.d.ts +3 -12
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +4 -13
- 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 +4 -10
- package/dist/src/modifiers.d.ts.map +1 -1
- package/dist/src/modifiers.js +32 -9
- 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 +14 -37
- package/dist/test/class.test.d.ts +2 -0
- package/dist/test/class.test.d.ts.map +1 -0
- package/dist/test/class.test.js +298 -0
- package/dist/test/enum.test.js +12 -12
- package/dist/test/namespace.test.js +8 -8
- 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} +8 -8
- package/dist/test/sourcefile.test.js +4 -4
- package/dist/test/using.test.js +9 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/components/{ClassDeclaration.tsx → Class.tsx} +43 -108
- package/src/components/ClassMethod.tsx +12 -53
- package/src/components/{EnumDeclaration.tsx → Enum.tsx} +6 -30
- package/src/components/Parameters.tsx +3 -10
- package/src/components/index.ts +3 -12
- package/src/components/stc/index.ts +2 -2
- package/src/modifiers.ts +42 -25
- package/src/name-policy.ts +0 -5
- package/temp/api.json +714 -5256
- package/test/class-method.test.tsx +14 -24
- package/test/class.test.tsx +292 -0
- package/test/enum.test.tsx +11 -11
- 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 +9 -9
- package/vitest.config.ts +0 -3
- package/LICENSE +0 -7
- package/dist/src/components/ClassDeclaration.d.ts +0 -74
- 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/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 -47
- package/dist/src/components/interface/declaration.d.ts.map +0 -1
- package/dist/src/components/interface/declaration.js +0 -77
- 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 -153
- package/dist/src/components/interface/method.d.ts +0 -32
- package/dist/src/components/interface/method.d.ts.map +0 -1
- package/dist/src/components/interface/method.js +0 -69
- 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 -254
- package/dist/src/components/interface/property.d.ts +0 -38
- package/dist/src/components/interface/property.d.ts.map +0 -1
- package/dist/src/components/interface/property.js +0 -67
- 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 -165
- package/dist/src/components/property/property.d.ts +0 -57
- package/dist/src/components/property/property.d.ts.map +0 -1
- package/dist/src/components/property/property.js +0 -70
- 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 -218
- 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 -65
- 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 -26
- 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/class-declaration.test.js +0 -463
- 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/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 -143
- package/src/components/interface/declaration.tsx +0 -105
- package/src/components/interface/method.test.tsx +0 -250
- package/src/components/interface/method.tsx +0 -105
- package/src/components/interface/property.test.tsx +0 -144
- package/src/components/interface/property.tsx +0 -107
- package/src/components/property/property.test.tsx +0 -187
- package/src/components/property/property.tsx +0 -146
- 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 -19
- package/src/components/type-parameters/type-parameters.tsx +0 -72
- package/src/components/var/declaration.test.tsx +0 -59
- package/src/components/var/declaration.tsx +0 -47
- package/test/class-declaration.test.tsx +0 -418
- package/test/vitest.setup.ts +0 -1
|
@@ -1,65 +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
|
-
|
|
16
|
-
// const typeParameters = normalizeAndDeclareParameters(props.parameters);
|
|
17
|
-
|
|
18
|
-
// onCleanup(() => {
|
|
19
|
-
// for (const param of typeParameters) {
|
|
20
|
-
// param.symbol.delete();
|
|
21
|
-
// }
|
|
22
|
-
// });
|
|
23
|
-
|
|
24
|
-
return ["<", _$createIntrinsic("group", {
|
|
25
|
-
get children() {
|
|
26
|
-
return _$createComponent(Indent, {
|
|
27
|
-
softline: true,
|
|
28
|
-
get children() {
|
|
29
|
-
return [_$createComponent(For, {
|
|
30
|
-
each: typeParameters,
|
|
31
|
-
comma: true,
|
|
32
|
-
line: true,
|
|
33
|
-
children: param => _$createComponent(TypeParameter, param)
|
|
34
|
-
}), _$createIntrinsic("ifBreak", {
|
|
35
|
-
children: ","
|
|
36
|
-
})];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}), ">"];
|
|
41
|
-
});
|
|
42
|
-
export function normalizeParameters(parameters) {
|
|
43
|
-
return parameters.map(param => {
|
|
44
|
-
if (typeof param === "string") {
|
|
45
|
-
return {
|
|
46
|
-
name: param
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return param;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// export function declareParameter(
|
|
54
|
-
// parameters: TypeParameterProps[],
|
|
55
|
-
// ): TypeParameterProps[] {
|
|
56
|
-
// return parameters.map((param) => {
|
|
57
|
-
// return {
|
|
58
|
-
// ...param,
|
|
59
|
-
// symbol: new CSharpOutputSymbol(entry[0], {
|
|
60
|
-
// scope: thisClassScope,
|
|
61
|
-
// refkeys: entry[1],
|
|
62
|
-
// }),
|
|
63
|
-
// };
|
|
64
|
-
// });
|
|
65
|
-
// }
|
|
@@ -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,26 +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("declare type parameters using parameters names", () => {
|
|
6
|
-
expect(_$createComponent(TestNamespace, {
|
|
7
|
-
get children() {
|
|
8
|
-
return _$createComponent(TypeParameters, {
|
|
9
|
-
parameters: ["A", "B"]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
})).toRenderTo(`<A, B>`);
|
|
13
|
-
});
|
|
14
|
-
it("declare type parameters using parameters", () => {
|
|
15
|
-
expect(_$createComponent(TestNamespace, {
|
|
16
|
-
get children() {
|
|
17
|
-
return _$createComponent(TypeParameters, {
|
|
18
|
-
parameters: [{
|
|
19
|
-
name: "A"
|
|
20
|
-
}, {
|
|
21
|
-
name: "B"
|
|
22
|
-
}]
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
})).toRenderTo(`<A, B>`);
|
|
26
|
-
});
|
|
@@ -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":""}
|