@alloy-js/csharp 0.18.0-dev.23 → 0.18.0-dev.3
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} +38 -64
- package/dist/src/components/ClassMethod.d.ts +5 -26
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +9 -27
- 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 +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 -13
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +5 -14
- 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 +3 -4
- package/src/components/Class.tsx +149 -0
- package/src/components/ClassMethod.tsx +15 -54
- package/src/components/{EnumDeclaration.tsx → Enum.tsx} +6 -30
- package/src/components/Parameters.tsx +51 -0
- package/src/components/SourceFile.tsx +0 -1
- package/src/components/index.ts +4 -13
- 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 +715 -5284
- 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/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 -68
- 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 -279
- 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/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 -62
- 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 -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/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/ClassDeclaration.tsx +0 -213
- 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 -278
- package/src/components/interface/method.tsx +0 -102
- package/src/components/interface/property.test.tsx +0 -144
- package/src/components/interface/property.tsx +0 -107
- package/src/components/parameters/parameters.tsx +0 -74
- package/src/components/property/property.test.tsx +0 -188
- package/src/components/property/property.tsx +0 -152
- 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 -418
- package/test/vitest.setup.ts +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
-
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
-
/** Method modifiers. Can only be one. */
|
|
4
|
-
export interface InterfacePropertyModifiers {
|
|
5
|
-
readonly new?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface InterfacePropertyProps extends AccessModifiers, InterfacePropertyModifiers {
|
|
8
|
-
name: string;
|
|
9
|
-
refkey?: Refkey;
|
|
10
|
-
/** Property type */
|
|
11
|
-
type: Children;
|
|
12
|
-
/** If property should have a getter */
|
|
13
|
-
get?: boolean;
|
|
14
|
-
/** If property should have a setter */
|
|
15
|
-
set?: boolean;
|
|
16
|
-
/** Doc comment */
|
|
17
|
-
doc?: Children;
|
|
18
|
-
/**
|
|
19
|
-
* Property initializer
|
|
20
|
-
* @example `<ClassProperty name="My" get set nullable />`
|
|
21
|
-
*
|
|
22
|
-
* ```cs
|
|
23
|
-
* int? My { get; set; };
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
nullable?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Render a C# interface property.
|
|
30
|
-
*
|
|
31
|
-
* @example `<InterfaceProperty public name="My" get set />`
|
|
32
|
-
*
|
|
33
|
-
* ```cs
|
|
34
|
-
* public int My { get; set; };
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare function InterfaceProperty(props: InterfacePropertyProps): Children;
|
|
38
|
-
//# sourceMappingURL=property.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/property.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAM5B,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;CACxB;AAKD,MAAM,WAAW,sBACf,SAAQ,eAAe,EACrB,0BAA0B;IAC5B,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,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,YAwC9D"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Block, List, MemberDeclaration, refkey, Scope } from "@alloy-js/core";
|
|
3
|
-
import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../modifiers.js";
|
|
4
|
-
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
|
-
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
6
|
-
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
7
|
-
import { DocWhen } from "../doc/comment.js";
|
|
8
|
-
|
|
9
|
-
/** Method modifiers. Can only be one. */
|
|
10
|
-
|
|
11
|
-
const getModifiers = makeModifiers(["new"]);
|
|
12
|
-
|
|
13
|
-
// properties for creating a method
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Render a C# interface property.
|
|
17
|
-
*
|
|
18
|
-
* @example `<InterfaceProperty public name="My" get set />`
|
|
19
|
-
*
|
|
20
|
-
* ```cs
|
|
21
|
-
* public int My { get; set; };
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function InterfaceProperty(props) {
|
|
25
|
-
const name = useCSharpNamePolicy().getName(props.name, "class-property");
|
|
26
|
-
const scope = useCSharpScope();
|
|
27
|
-
if (scope.kind !== "member" || scope.name !== "interface-decl") {
|
|
28
|
-
throw new Error("can't define an interface method outside of an interface scope");
|
|
29
|
-
}
|
|
30
|
-
const propertySymbol = new CSharpOutputSymbol(name, {
|
|
31
|
-
scope,
|
|
32
|
-
refkeys: props.refkey ?? refkey(props.name)
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// scope for property declaration
|
|
36
|
-
const propertyScope = new CSharpMemberScope("property-decl", {
|
|
37
|
-
owner: propertySymbol
|
|
38
|
-
});
|
|
39
|
-
const modifiers = computeModifiersPrefix([getAccessModifier(props), getModifiers(props)]);
|
|
40
|
-
// note that scope wraps the method decl so that the params get the correct scope
|
|
41
|
-
return _$createComponent(MemberDeclaration, {
|
|
42
|
-
symbol: propertySymbol,
|
|
43
|
-
get children() {
|
|
44
|
-
return _$createComponent(Scope, {
|
|
45
|
-
value: propertyScope,
|
|
46
|
-
get children() {
|
|
47
|
-
return [_$createComponent(DocWhen, {
|
|
48
|
-
get doc() {
|
|
49
|
-
return props.doc;
|
|
50
|
-
}
|
|
51
|
-
}), modifiers, _$memo(() => props.type), _$memo(() => props.nullable && "?"), " ", name, " ", _$createComponent(Block, {
|
|
52
|
-
newline: true,
|
|
53
|
-
inline: true,
|
|
54
|
-
get children() {
|
|
55
|
-
return _$createComponent(List, {
|
|
56
|
-
joiner: " ",
|
|
57
|
-
get children() {
|
|
58
|
-
return [_$memo(() => props.get && "get;"), _$memo(() => props.set && "set;")];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
})];
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property.test.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/property.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { memo as _$memo, createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { TestNamespace } from "../../../test/utils.js";
|
|
4
|
-
import { InterfaceDeclaration } from "./declaration.js";
|
|
5
|
-
import { InterfaceProperty } from "./property.js";
|
|
6
|
-
const Wrapper = props => _$createComponent(TestNamespace, {
|
|
7
|
-
get children() {
|
|
8
|
-
return _$createComponent(InterfaceDeclaration, {
|
|
9
|
-
"public": true,
|
|
10
|
-
name: "TestInterface",
|
|
11
|
-
get children() {
|
|
12
|
-
return props.children;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
describe("modifiers", () => {
|
|
18
|
-
describe("access modifiers", () => {
|
|
19
|
-
it.each(["public", "private", "protected", "internal"])("%s", accessModifier => {
|
|
20
|
-
expect(_$createComponent(Wrapper, {
|
|
21
|
-
get children() {
|
|
22
|
-
return _$createComponent(InterfaceProperty, _$mergeProps({
|
|
23
|
-
[accessModifier]: true
|
|
24
|
-
}, {
|
|
25
|
-
name: "TestProp",
|
|
26
|
-
type: "string",
|
|
27
|
-
get: true
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
})).toRenderTo(`
|
|
31
|
-
public interface TestInterface
|
|
32
|
-
{
|
|
33
|
-
${accessModifier} string TestProp { get; }
|
|
34
|
-
}
|
|
35
|
-
`);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe("method modifiers", () => {
|
|
39
|
-
it.each(["new"])("%s", methodModifier => {
|
|
40
|
-
expect(_$createComponent(Wrapper, {
|
|
41
|
-
get children() {
|
|
42
|
-
return _$createComponent(InterfaceProperty, _$mergeProps({
|
|
43
|
-
[methodModifier]: true
|
|
44
|
-
}, {
|
|
45
|
-
name: "TestProp",
|
|
46
|
-
type: "string",
|
|
47
|
-
get: true
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
})).toRenderTo(`
|
|
51
|
-
public interface TestInterface
|
|
52
|
-
{
|
|
53
|
-
${methodModifier} string TestProp { get; }
|
|
54
|
-
}
|
|
55
|
-
`);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
it("combine modifiers", () => {
|
|
59
|
-
expect(_$createComponent(Wrapper, {
|
|
60
|
-
get children() {
|
|
61
|
-
return _$createComponent(InterfaceProperty, {
|
|
62
|
-
"public": true,
|
|
63
|
-
"new": true,
|
|
64
|
-
name: "TestProp",
|
|
65
|
-
type: "string",
|
|
66
|
-
get: true
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
})).toRenderTo(`
|
|
70
|
-
public interface TestInterface
|
|
71
|
-
{
|
|
72
|
-
public new string TestProp { get; }
|
|
73
|
-
}
|
|
74
|
-
`);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
it("applies PascalCase naming policy", () => {
|
|
78
|
-
expect(_$createComponent(Wrapper, {
|
|
79
|
-
get children() {
|
|
80
|
-
return _$createComponent(InterfaceProperty, {
|
|
81
|
-
name: "test_prop",
|
|
82
|
-
type: "string",
|
|
83
|
-
get: true
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
})).toRenderTo(`
|
|
87
|
-
public interface TestInterface
|
|
88
|
-
{
|
|
89
|
-
string TestProp { get; }
|
|
90
|
-
}
|
|
91
|
-
`);
|
|
92
|
-
});
|
|
93
|
-
it("has getter only", () => {
|
|
94
|
-
expect(_$createComponent(Wrapper, {
|
|
95
|
-
get children() {
|
|
96
|
-
return _$createComponent(InterfaceProperty, {
|
|
97
|
-
name: "TestProp",
|
|
98
|
-
type: "string",
|
|
99
|
-
get: true
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
})).toRenderTo(`
|
|
103
|
-
public interface TestInterface
|
|
104
|
-
{
|
|
105
|
-
string TestProp { get; }
|
|
106
|
-
}
|
|
107
|
-
`);
|
|
108
|
-
});
|
|
109
|
-
it("has setter only", () => {
|
|
110
|
-
expect(_$createComponent(Wrapper, {
|
|
111
|
-
get children() {
|
|
112
|
-
return _$createComponent(InterfaceProperty, {
|
|
113
|
-
name: "TestProp",
|
|
114
|
-
type: "string",
|
|
115
|
-
set: true
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
})).toRenderTo(`
|
|
119
|
-
public interface TestInterface
|
|
120
|
-
{
|
|
121
|
-
string TestProp { set; }
|
|
122
|
-
}
|
|
123
|
-
`);
|
|
124
|
-
});
|
|
125
|
-
it("has getter and setter", () => {
|
|
126
|
-
expect(_$createComponent(Wrapper, {
|
|
127
|
-
get children() {
|
|
128
|
-
return _$createComponent(InterfaceProperty, {
|
|
129
|
-
name: "TestProp",
|
|
130
|
-
type: "string",
|
|
131
|
-
get: true,
|
|
132
|
-
set: true
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
})).toRenderTo(`
|
|
136
|
-
public interface TestInterface
|
|
137
|
-
{
|
|
138
|
-
string TestProp { get; set; }
|
|
139
|
-
}
|
|
140
|
-
`);
|
|
141
|
-
});
|
|
142
|
-
it("specify doc comment", () => {
|
|
143
|
-
expect(_$createComponent(TestNamespace, {
|
|
144
|
-
get children() {
|
|
145
|
-
return _$createComponent(InterfaceDeclaration, {
|
|
146
|
-
name: "Test",
|
|
147
|
-
get children() {
|
|
148
|
-
return _$createComponent(InterfaceProperty, {
|
|
149
|
-
name: "Method",
|
|
150
|
-
type: "string",
|
|
151
|
-
get: true,
|
|
152
|
-
set: true,
|
|
153
|
-
doc: "This is a test"
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
})).toRenderTo(`
|
|
159
|
-
interface Test
|
|
160
|
-
{
|
|
161
|
-
/// This is a test
|
|
162
|
-
string Method { get; set; }
|
|
163
|
-
}
|
|
164
|
-
`);
|
|
165
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
-
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
-
/** Property modifiers. */
|
|
4
|
-
export interface PropertyModifiers {
|
|
5
|
-
readonly new?: boolean;
|
|
6
|
-
readonly static?: boolean;
|
|
7
|
-
readonly virtual?: boolean;
|
|
8
|
-
readonly sealed?: boolean;
|
|
9
|
-
readonly override?: boolean;
|
|
10
|
-
readonly abstract?: boolean;
|
|
11
|
-
readonly extern?: boolean;
|
|
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;
|
|
18
|
-
}
|
|
19
|
-
/** Properties for {@link Property} component */
|
|
20
|
-
export interface PropertyProps extends AccessModifiers, PropertyModifiers {
|
|
21
|
-
name: string;
|
|
22
|
-
refkey?: Refkey;
|
|
23
|
-
/** Property type */
|
|
24
|
-
type: Children;
|
|
25
|
-
/** If property should have a getter */
|
|
26
|
-
get?: boolean;
|
|
27
|
-
/** If property should have a setter */
|
|
28
|
-
set?: boolean;
|
|
29
|
-
/** If property should only be set on the type creation */
|
|
30
|
-
init?: boolean;
|
|
31
|
-
/** Doc comment */
|
|
32
|
-
doc?: Children;
|
|
33
|
-
/**
|
|
34
|
-
* Property initializer
|
|
35
|
-
* @example `<ClassProperty name="My" get set nullable />`
|
|
36
|
-
*
|
|
37
|
-
* ```cs
|
|
38
|
-
* int? My { get; set; };
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
nullable?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Property initializer
|
|
44
|
-
* @example `<ClassProperty name="My" get set init={42} />`
|
|
45
|
-
*
|
|
46
|
-
* ```cs
|
|
47
|
-
* int My { get; set; } = 42;
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
initializer?: Children;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Render a C# class property.
|
|
54
|
-
*
|
|
55
|
-
* @example `<ClassProperty public name="My" get set />`
|
|
56
|
-
*
|
|
57
|
-
* ```cs
|
|
58
|
-
* public int My { get; set; };
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare function Property(props: PropertyProps): Children;
|
|
62
|
-
//# sourceMappingURL=property.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { Block, code, List, MemberDeclaration, refkey, Scope } from "@alloy-js/core";
|
|
3
|
-
import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../modifiers.js";
|
|
4
|
-
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
|
-
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
6
|
-
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
7
|
-
import { DocWhen } from "../doc/comment.js";
|
|
8
|
-
|
|
9
|
-
/** Property modifiers. */
|
|
10
|
-
|
|
11
|
-
const getModifiers = makeModifiers(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly", "required"]);
|
|
12
|
-
|
|
13
|
-
/** Properties for {@link Property} component */
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Render a C# class property.
|
|
17
|
-
*
|
|
18
|
-
* @example `<ClassProperty public name="My" get set />`
|
|
19
|
-
*
|
|
20
|
-
* ```cs
|
|
21
|
-
* public int My { get; set; };
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export function Property(props) {
|
|
25
|
-
const name = useCSharpNamePolicy().getName(props.name, "class-property");
|
|
26
|
-
const scope = useCSharpScope();
|
|
27
|
-
if (scope.kind !== "member" || scope.name !== "class-decl" && scope.name !== "record-decl") {
|
|
28
|
-
throw new Error("can't define an interface method outside of an interface scope");
|
|
29
|
-
}
|
|
30
|
-
const propertySymbol = new CSharpOutputSymbol(name, {
|
|
31
|
-
scope,
|
|
32
|
-
refkeys: props.refkey ?? refkey(props.name)
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// scope for property declaration
|
|
36
|
-
const propertyScope = new CSharpMemberScope("property-decl", {
|
|
37
|
-
owner: propertySymbol
|
|
38
|
-
});
|
|
39
|
-
const modifiers = computeModifiersPrefix([getAccessModifier(props), getModifiers(props)]);
|
|
40
|
-
if (props.init && props.set) {
|
|
41
|
-
throw new Error(`Cannot use 'init' and 'set' together on property '${name}'`);
|
|
42
|
-
}
|
|
43
|
-
// note that scope wraps the method decl so that the params get the correct scope
|
|
44
|
-
return _$createComponent(MemberDeclaration, {
|
|
45
|
-
symbol: propertySymbol,
|
|
46
|
-
get children() {
|
|
47
|
-
return _$createComponent(Scope, {
|
|
48
|
-
value: propertyScope,
|
|
49
|
-
get children() {
|
|
50
|
-
return [_$createComponent(DocWhen, {
|
|
51
|
-
get doc() {
|
|
52
|
-
return props.doc;
|
|
53
|
-
}
|
|
54
|
-
}), modifiers, _$memo(() => props.type), _$memo(() => props.nullable && "?"), " ", name, " ", _$createComponent(Block, {
|
|
55
|
-
newline: true,
|
|
56
|
-
inline: true,
|
|
57
|
-
get children() {
|
|
58
|
-
return _$createComponent(List, {
|
|
59
|
-
joiner: " ",
|
|
60
|
-
get children() {
|
|
61
|
-
return [_$memo(() => props.get && "get;"), _$memo(() => props.set && "set;"), _$memo(() => props.init && "init;")];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}), _$memo(() => props.initializer && code` = ${props.initializer};`)];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"property.test.d.ts","sourceRoot":"","sources":["../../../../src/components/property/property.test.tsx"],"names":[],"mappings":""}
|