@alloy-js/csharp 0.18.0-dev.10 → 0.18.0-dev.11
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/property.d.ts +55 -0
- package/dist/src/components/class/property.d.ts.map +1 -0
- package/dist/src/components/class/property.js +67 -0
- package/dist/src/components/class/property.test.d.ts +2 -0
- package/dist/src/components/class/property.test.d.ts.map +1 -0
- package/dist/src/components/class/property.test.js +201 -0
- package/dist/src/components/index.d.ts +2 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -0
- package/dist/src/components/interface/property.d.ts +18 -1
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +12 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/class/property.test.tsx +180 -0
- package/src/components/class/property.tsx +135 -0
- package/src/components/index.ts +2 -0
- package/src/components/interface/property.tsx +23 -6
- package/temp/api.json +1190 -315
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
+
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
+
/** Method modifiers. Can only be one. */
|
|
4
|
+
export interface ClassPropertyModifiers {
|
|
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
|
+
/** Properties for {@link ClassProperty} component */
|
|
15
|
+
export interface ClassPropertyProps extends AccessModifiers, ClassPropertyModifiers {
|
|
16
|
+
name: string;
|
|
17
|
+
refkey?: Refkey;
|
|
18
|
+
/** Property type */
|
|
19
|
+
type: Children;
|
|
20
|
+
/** If property should have a getter */
|
|
21
|
+
get?: boolean;
|
|
22
|
+
/** If property should have a setter */
|
|
23
|
+
set?: boolean;
|
|
24
|
+
/** Doc comment */
|
|
25
|
+
doc?: Children;
|
|
26
|
+
/**
|
|
27
|
+
* Property initializer
|
|
28
|
+
* @example `<ClassProperty name="My" get set nullable />`
|
|
29
|
+
*
|
|
30
|
+
* ```cs
|
|
31
|
+
* int? My { get; set; };
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
nullable?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Property initializer
|
|
37
|
+
* @example `<ClassProperty name="My" get set init={42} />`
|
|
38
|
+
*
|
|
39
|
+
* ```cs
|
|
40
|
+
* int My { get; set; } = 42;
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
init?: Children;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Render a C# class property.
|
|
47
|
+
*
|
|
48
|
+
* @example `<ClassProperty public name="My" get set />`
|
|
49
|
+
*
|
|
50
|
+
* ```cs
|
|
51
|
+
* public int My { get; set; };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function ClassProperty(props: ClassPropertyProps): Children;
|
|
55
|
+
//# sourceMappingURL=property.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../src/components/class/property.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAM5B,yCAAyC;AACzC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAaD,qDAAqD;AACrD,MAAM,WAAW,kBACf,SAAQ,eAAe,EACrB,sBAAsB;IACxB,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;IAEnB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAyCtD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
/** Method modifiers. Can only be one. */
|
|
10
|
+
|
|
11
|
+
const getModifiers = makeModifiers(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly"]);
|
|
12
|
+
|
|
13
|
+
/** Properties for {@link ClassProperty} 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 ClassProperty(props) {
|
|
25
|
+
const name = useCSharpNamePolicy().getName(props.name, "class-property");
|
|
26
|
+
const scope = useCSharpScope();
|
|
27
|
+
if (scope.kind !== "member" || scope.name !== "class-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
|
+
}), _$memo(() => props.init && code` = ${props.init};`)];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.test.d.ts","sourceRoot":"","sources":["../../../../src/components/class/property.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,201 @@
|
|
|
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 { ClassDeclaration } from "../ClassDeclaration.js";
|
|
5
|
+
import { ClassProperty } from "./property.js";
|
|
6
|
+
const Wrapper = props => _$createComponent(TestNamespace, {
|
|
7
|
+
get children() {
|
|
8
|
+
return _$createComponent(ClassDeclaration, {
|
|
9
|
+
"public": true,
|
|
10
|
+
name: "TestClass",
|
|
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(ClassProperty, _$mergeProps({
|
|
23
|
+
[accessModifier]: true
|
|
24
|
+
}, {
|
|
25
|
+
name: "TestProp",
|
|
26
|
+
type: "string",
|
|
27
|
+
get: true
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
})).toRenderTo(`
|
|
31
|
+
public class TestClass
|
|
32
|
+
{
|
|
33
|
+
${accessModifier} string TestProp { get; }
|
|
34
|
+
}
|
|
35
|
+
`);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe("property modifiers", () => {
|
|
39
|
+
it.each(["new", "static", "virtual", "sealed", "override", "abstract", "extern", "readonly"])("%s", methodModifier => {
|
|
40
|
+
expect(_$createComponent(Wrapper, {
|
|
41
|
+
get children() {
|
|
42
|
+
return _$createComponent(ClassProperty, _$mergeProps({
|
|
43
|
+
[methodModifier]: true
|
|
44
|
+
}, {
|
|
45
|
+
name: "TestProp",
|
|
46
|
+
type: "string",
|
|
47
|
+
get: true
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
})).toRenderTo(`
|
|
51
|
+
public class TestClass
|
|
52
|
+
{
|
|
53
|
+
${methodModifier} string TestProp { get; }
|
|
54
|
+
}
|
|
55
|
+
`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it("combine modifiers", () => {
|
|
59
|
+
expect(_$createComponent(Wrapper, {
|
|
60
|
+
get children() {
|
|
61
|
+
return _$createComponent(ClassProperty, {
|
|
62
|
+
"public": true,
|
|
63
|
+
"new": true,
|
|
64
|
+
name: "TestProp",
|
|
65
|
+
type: "string",
|
|
66
|
+
get: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
})).toRenderTo(`
|
|
70
|
+
public class TestClass
|
|
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(ClassProperty, {
|
|
81
|
+
name: "test_prop",
|
|
82
|
+
type: "string",
|
|
83
|
+
get: true
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
})).toRenderTo(`
|
|
87
|
+
public class TestClass
|
|
88
|
+
{
|
|
89
|
+
string TestProp { get; }
|
|
90
|
+
}
|
|
91
|
+
`);
|
|
92
|
+
});
|
|
93
|
+
it("has getter only", () => {
|
|
94
|
+
expect(_$createComponent(Wrapper, {
|
|
95
|
+
get children() {
|
|
96
|
+
return _$createComponent(ClassProperty, {
|
|
97
|
+
name: "TestProp",
|
|
98
|
+
type: "string",
|
|
99
|
+
get: true
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
})).toRenderTo(`
|
|
103
|
+
public class TestClass
|
|
104
|
+
{
|
|
105
|
+
string TestProp { get; }
|
|
106
|
+
}
|
|
107
|
+
`);
|
|
108
|
+
});
|
|
109
|
+
it("has setter only", () => {
|
|
110
|
+
expect(_$createComponent(Wrapper, {
|
|
111
|
+
get children() {
|
|
112
|
+
return _$createComponent(ClassProperty, {
|
|
113
|
+
name: "TestProp",
|
|
114
|
+
type: "string",
|
|
115
|
+
set: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
})).toRenderTo(`
|
|
119
|
+
public class TestClass
|
|
120
|
+
{
|
|
121
|
+
string TestProp { set; }
|
|
122
|
+
}
|
|
123
|
+
`);
|
|
124
|
+
});
|
|
125
|
+
it("has getter and setter", () => {
|
|
126
|
+
expect(_$createComponent(Wrapper, {
|
|
127
|
+
get children() {
|
|
128
|
+
return _$createComponent(ClassProperty, {
|
|
129
|
+
name: "TestProp",
|
|
130
|
+
type: "string",
|
|
131
|
+
get: true,
|
|
132
|
+
set: true
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
})).toRenderTo(`
|
|
136
|
+
public class TestClass
|
|
137
|
+
{
|
|
138
|
+
string TestProp { get; set; }
|
|
139
|
+
}
|
|
140
|
+
`);
|
|
141
|
+
});
|
|
142
|
+
it("specify doc comment", () => {
|
|
143
|
+
expect(_$createComponent(TestNamespace, {
|
|
144
|
+
get children() {
|
|
145
|
+
return _$createComponent(ClassDeclaration, {
|
|
146
|
+
name: "Test",
|
|
147
|
+
get children() {
|
|
148
|
+
return _$createComponent(ClassProperty, {
|
|
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
|
+
class Test
|
|
160
|
+
{
|
|
161
|
+
/// This is a test
|
|
162
|
+
string Method { get; set; }
|
|
163
|
+
}
|
|
164
|
+
`);
|
|
165
|
+
});
|
|
166
|
+
it("specify nullable property", () => {
|
|
167
|
+
expect(_$createComponent(Wrapper, {
|
|
168
|
+
get children() {
|
|
169
|
+
return _$createComponent(ClassProperty, {
|
|
170
|
+
name: "TestProp",
|
|
171
|
+
type: "string",
|
|
172
|
+
nullable: true,
|
|
173
|
+
get: true,
|
|
174
|
+
set: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
})).toRenderTo(`
|
|
178
|
+
public class TestClass
|
|
179
|
+
{
|
|
180
|
+
string? TestProp { get; set; }
|
|
181
|
+
}
|
|
182
|
+
`);
|
|
183
|
+
});
|
|
184
|
+
it("specify initializer", () => {
|
|
185
|
+
expect(_$createComponent(Wrapper, {
|
|
186
|
+
get children() {
|
|
187
|
+
return _$createComponent(ClassProperty, {
|
|
188
|
+
name: "TestProp",
|
|
189
|
+
type: "string",
|
|
190
|
+
get: true,
|
|
191
|
+
set: true,
|
|
192
|
+
init: `"abc"`
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
})).toRenderTo(`
|
|
196
|
+
public class TestClass
|
|
197
|
+
{
|
|
198
|
+
string TestProp { get; set; } = "abc";
|
|
199
|
+
}
|
|
200
|
+
`);
|
|
201
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./class/property.js";
|
|
1
2
|
export * from "./ClassDeclaration.jsx";
|
|
2
3
|
export * from "./ClassMethod.jsx";
|
|
3
4
|
export * from "./Declaration.js";
|
|
@@ -6,6 +7,7 @@ export * from "./doc/from-markdown.jsx";
|
|
|
6
7
|
export * from "./EnumDeclaration.jsx";
|
|
7
8
|
export * from "./interface/declaration.js";
|
|
8
9
|
export * from "./interface/method.js";
|
|
10
|
+
export * from "./interface/property.js";
|
|
9
11
|
export * from "./Name.js";
|
|
10
12
|
export * from "./Namespace.js";
|
|
11
13
|
export * from "./Parameters.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./class/property.js";
|
|
1
2
|
export * from "./ClassDeclaration.js";
|
|
2
3
|
export * from "./ClassMethod.js";
|
|
3
4
|
export * from "./Declaration.js";
|
|
@@ -6,6 +7,7 @@ export * from "./doc/from-markdown.js";
|
|
|
6
7
|
export * from "./EnumDeclaration.js";
|
|
7
8
|
export * from "./interface/declaration.js";
|
|
8
9
|
export * from "./interface/method.js";
|
|
10
|
+
export * from "./interface/property.js";
|
|
9
11
|
export * from "./Name.js";
|
|
10
12
|
export * from "./Namespace.js";
|
|
11
13
|
export * from "./Parameters.js";
|
|
@@ -4,7 +4,6 @@ import { AccessModifiers } from "../../modifiers.js";
|
|
|
4
4
|
export interface InterfacePropertyModifiers {
|
|
5
5
|
readonly new?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare const getMethodModifier: (data: InterfacePropertyModifiers) => string;
|
|
8
7
|
export interface InterfacePropertyProps extends AccessModifiers, InterfacePropertyModifiers {
|
|
9
8
|
name: string;
|
|
10
9
|
refkey?: Refkey;
|
|
@@ -16,6 +15,24 @@ export interface InterfacePropertyProps extends AccessModifiers, InterfaceProper
|
|
|
16
15
|
set?: boolean;
|
|
17
16
|
/** Doc comment */
|
|
18
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;
|
|
19
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
|
+
*/
|
|
20
37
|
export declare function InterfaceProperty(props: InterfacePropertyProps): Children;
|
|
21
38
|
//# sourceMappingURL=property.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|
|
@@ -8,11 +8,19 @@ import { DocWhen } from "../doc/comment.js";
|
|
|
8
8
|
|
|
9
9
|
/** Method modifiers. Can only be one. */
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const getModifiers = makeModifiers(["new"]);
|
|
12
12
|
|
|
13
13
|
// properties for creating a method
|
|
14
14
|
|
|
15
|
-
|
|
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
|
+
*/
|
|
16
24
|
export function InterfaceProperty(props) {
|
|
17
25
|
const name = useCSharpNamePolicy().getName(props.name, "class-property");
|
|
18
26
|
const scope = useCSharpScope();
|
|
@@ -28,7 +36,7 @@ export function InterfaceProperty(props) {
|
|
|
28
36
|
const propertyScope = new CSharpMemberScope("property-decl", {
|
|
29
37
|
owner: propertySymbol
|
|
30
38
|
});
|
|
31
|
-
const modifiers = computeModifiersPrefix([getAccessModifier(props),
|
|
39
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props), getModifiers(props)]);
|
|
32
40
|
// note that scope wraps the method decl so that the params get the correct scope
|
|
33
41
|
return _$createComponent(MemberDeclaration, {
|
|
34
42
|
symbol: propertySymbol,
|
|
@@ -40,7 +48,7 @@ export function InterfaceProperty(props) {
|
|
|
40
48
|
get doc() {
|
|
41
49
|
return props.doc;
|
|
42
50
|
}
|
|
43
|
-
}), modifiers, _$memo(() => props.type), " ", name, " ", _$createComponent(Block, {
|
|
51
|
+
}), modifiers, _$memo(() => props.type), _$memo(() => props.nullable && "?"), " ", name, " ", _$createComponent(Block, {
|
|
44
52
|
newline: true,
|
|
45
53
|
inline: true,
|
|
46
54
|
get children() {
|