@alloy-js/csharp 0.18.0-dev.12 → 0.18.0-dev.14
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/Parameters.d.ts +6 -1
- package/dist/src/components/Parameters.d.ts.map +1 -1
- package/dist/src/components/Parameters.js +3 -2
- package/dist/src/components/class/property.d.ts.map +1 -1
- package/dist/src/components/class/property.js +1 -1
- package/dist/src/components/interface/method.test.js +44 -0
- package/dist/src/components/record/declaration.d.ts +34 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -0
- package/dist/src/components/record/declaration.js +90 -0
- package/dist/src/components/record/declaration.test.d.ts +2 -0
- package/dist/src/components/record/declaration.test.d.ts.map +1 -0
- package/dist/src/components/record/declaration.test.js +94 -0
- 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 +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/Parameters.tsx +10 -3
- package/src/components/class/property.tsx +4 -1
- package/src/components/interface/method.test.tsx +52 -0
- package/src/components/record/declaration.test.tsx +73 -0
- package/src/components/record/declaration.tsx +109 -0
- package/src/name-policy.ts +2 -0
- package/temp/api.json +59 -13
|
@@ -2,12 +2,17 @@ import * as core from "@alloy-js/core";
|
|
|
2
2
|
export interface ParameterProps {
|
|
3
3
|
name: string;
|
|
4
4
|
type: core.Children;
|
|
5
|
+
/** If the parmaeter is optional(without default value) */
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
/** Default value for the parameter */
|
|
8
|
+
default?: core.Children;
|
|
5
9
|
refkey?: core.Refkey;
|
|
6
10
|
symbol?: core.OutputSymbol;
|
|
7
11
|
}
|
|
12
|
+
/** Define a parameter to be used in class or interface method. */
|
|
8
13
|
export declare function Parameter(props: ParameterProps): core.Children;
|
|
9
14
|
export interface ParametersProps {
|
|
10
|
-
parameters:
|
|
15
|
+
parameters: ParameterProps[];
|
|
11
16
|
}
|
|
12
17
|
export declare function Parameters(props: ParametersProps): core.Children;
|
|
13
18
|
//# sourceMappingURL=Parameters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parameters.d.ts","sourceRoot":"","sources":["../../../src/components/Parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Parameters.d.ts","sourceRoot":"","sources":["../../../src/components/Parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAOvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACxB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;CAC5B;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,iBAwB9C;AAED,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAMhD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as core from "@alloy-js/core";
|
|
3
|
+
import { code } from "@alloy-js/core";
|
|
3
4
|
import { useCSharpNamePolicy } from "../name-policy.js";
|
|
4
5
|
import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
|
|
5
6
|
import { useCSharpScope } from "../symbols/scopes.js";
|
|
6
7
|
import { Name } from "./Name.js";
|
|
7
|
-
|
|
8
|
+
/** Define a parameter to be used in class or interface method. */
|
|
8
9
|
export function Parameter(props) {
|
|
9
10
|
const name = useCSharpNamePolicy().getName(props.name, "parameter");
|
|
10
11
|
const scope = useCSharpScope();
|
|
@@ -18,7 +19,7 @@ export function Parameter(props) {
|
|
|
18
19
|
return _$createComponent(core.Declaration, {
|
|
19
20
|
symbol: memberSymbol,
|
|
20
21
|
get children() {
|
|
21
|
-
return [_$memo(() => props.type), " ", _$createComponent(Name, {})];
|
|
22
|
+
return [_$memo(() => props.type), _$memo(() => props.optional ? "?" : ""), " ", _$createComponent(Name, {}), _$memo(() => props.default ? code` = ${props.default}` : "")];
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
}
|
|
@@ -1 +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,
|
|
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,YA4CtD"}
|
|
@@ -24,7 +24,7 @@ const getModifiers = makeModifiers(["new", "static", "virtual", "sealed", "overr
|
|
|
24
24
|
export function ClassProperty(props) {
|
|
25
25
|
const name = useCSharpNamePolicy().getName(props.name, "class-property");
|
|
26
26
|
const scope = useCSharpScope();
|
|
27
|
-
if (scope.kind !== "member" || scope.name !== "class-decl") {
|
|
27
|
+
if (scope.kind !== "member" || scope.name !== "class-decl" && scope.name !== "record-decl") {
|
|
28
28
|
throw new Error("can't define an interface method outside of an interface scope");
|
|
29
29
|
}
|
|
30
30
|
const propertySymbol = new CSharpOutputSymbol(name, {
|
|
@@ -108,6 +108,50 @@ it("defines params and return type", () => {
|
|
|
108
108
|
}
|
|
109
109
|
`);
|
|
110
110
|
});
|
|
111
|
+
it("defines optional param", () => {
|
|
112
|
+
const res = _$createComponent(Wrapper, {
|
|
113
|
+
get children() {
|
|
114
|
+
return _$createComponent(InterfaceMethod, {
|
|
115
|
+
"public": true,
|
|
116
|
+
name: "MethodOne",
|
|
117
|
+
parameters: [{
|
|
118
|
+
name: "intParam",
|
|
119
|
+
type: "int",
|
|
120
|
+
optional: true
|
|
121
|
+
}],
|
|
122
|
+
returns: "string"
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
expect(res).toRenderTo(`
|
|
127
|
+
public interface TestInterface
|
|
128
|
+
{
|
|
129
|
+
public string MethodOne(int? intParam);
|
|
130
|
+
}
|
|
131
|
+
`);
|
|
132
|
+
});
|
|
133
|
+
it("defines optional param with default", () => {
|
|
134
|
+
const res = _$createComponent(Wrapper, {
|
|
135
|
+
get children() {
|
|
136
|
+
return _$createComponent(InterfaceMethod, {
|
|
137
|
+
"public": true,
|
|
138
|
+
name: "MethodOne",
|
|
139
|
+
parameters: [{
|
|
140
|
+
name: "intParam",
|
|
141
|
+
type: "int",
|
|
142
|
+
default: 12
|
|
143
|
+
}],
|
|
144
|
+
returns: "string"
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
expect(res).toRenderTo(`
|
|
149
|
+
public interface TestInterface
|
|
150
|
+
{
|
|
151
|
+
public string MethodOne(int intParam = 12);
|
|
152
|
+
}
|
|
153
|
+
`);
|
|
154
|
+
});
|
|
111
155
|
it("specify doc comment", () => {
|
|
112
156
|
expect(_$createComponent(TestNamespace, {
|
|
113
157
|
get children() {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
|
+
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
+
export interface RecordModifiers {
|
|
4
|
+
readonly partial?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface RecordDeclarationProps extends Omit<core.DeclarationProps, "nameKind">, AccessModifiers, RecordModifiers {
|
|
7
|
+
name: string;
|
|
8
|
+
/** Doc comment */
|
|
9
|
+
doc?: core.Children;
|
|
10
|
+
refkey?: core.Refkey;
|
|
11
|
+
typeParameters?: Record<string, core.Refkey>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* CSharp record declaration.
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <RecordDeclaration public name="IMyRecord">
|
|
18
|
+
* <RecordMember public name="MyProperty" type="int" />
|
|
19
|
+
* <RecordMethod public name="MyMethod" returnType="void">
|
|
20
|
+
* <Parameter name="value" type="int" />
|
|
21
|
+
* </RecordMethod>
|
|
22
|
+
* </RecordDeclaration>
|
|
23
|
+
* ```
|
|
24
|
+
* This will produce:
|
|
25
|
+
* ```csharp
|
|
26
|
+
* public record MyIface
|
|
27
|
+
* {
|
|
28
|
+
* public int MyProperty { get; set; }
|
|
29
|
+
* public void MyMethod(int value);
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function RecordDeclaration(props: RecordDeclarationProps): core.Children;
|
|
34
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/record/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAO5B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,eAAe;IACjB,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,iBAwD9D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import * as core 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 } from "../../symbols/scopes.js";
|
|
7
|
+
import { DocWhen } from "../doc/comment.js";
|
|
8
|
+
import { Name } from "../Name.js";
|
|
9
|
+
const getRecordModifiers = makeModifiers(["partial"]);
|
|
10
|
+
|
|
11
|
+
// properties for creating a class
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* CSharp record declaration.
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <RecordDeclaration public name="IMyRecord">
|
|
18
|
+
* <RecordMember public name="MyProperty" type="int" />
|
|
19
|
+
* <RecordMethod public name="MyMethod" returnType="void">
|
|
20
|
+
* <Parameter name="value" type="int" />
|
|
21
|
+
* </RecordMethod>
|
|
22
|
+
* </RecordDeclaration>
|
|
23
|
+
* ```
|
|
24
|
+
* This will produce:
|
|
25
|
+
* ```csharp
|
|
26
|
+
* public record MyIface
|
|
27
|
+
* {
|
|
28
|
+
* public int MyProperty { get; set; }
|
|
29
|
+
* public void MyMethod(int value);
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function RecordDeclaration(props) {
|
|
34
|
+
const name = useCSharpNamePolicy().getName(props.name, "record");
|
|
35
|
+
const thisRecordSymbol = new CSharpOutputSymbol(name, {
|
|
36
|
+
refkeys: props.refkey
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// this creates a new scope for the record definition.
|
|
40
|
+
// members will automatically "inherit" this scope so
|
|
41
|
+
// that refkeys to them will produce the fully-qualified
|
|
42
|
+
// name e.g. Foo.Bar.
|
|
43
|
+
const thisRecordScope = new CSharpMemberScope("record-decl", {
|
|
44
|
+
owner: thisRecordSymbol
|
|
45
|
+
});
|
|
46
|
+
let typeParams;
|
|
47
|
+
if (props.typeParameters) {
|
|
48
|
+
const typeParamNames = new Array();
|
|
49
|
+
for (const entry of Object.entries(props.typeParameters)) {
|
|
50
|
+
typeParamNames.push(useCSharpNamePolicy().getName(entry[0], "type-parameter"));
|
|
51
|
+
// create a symbol for each type param so its
|
|
52
|
+
// refkey resolves to the type param's name
|
|
53
|
+
new CSharpOutputSymbol(entry[0], {
|
|
54
|
+
scope: thisRecordScope,
|
|
55
|
+
refkeys: entry[1]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
typeParams = _$createIntrinsic("group", {
|
|
59
|
+
get children() {
|
|
60
|
+
return ["<", _$createComponent(core.For, {
|
|
61
|
+
each: typeParamNames,
|
|
62
|
+
comma: true,
|
|
63
|
+
line: true,
|
|
64
|
+
children: name => name
|
|
65
|
+
}), ">"];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const modifiers = computeModifiersPrefix([getAccessModifier(props), getRecordModifiers(props)]);
|
|
70
|
+
return _$createComponent(core.Declaration, {
|
|
71
|
+
symbol: thisRecordSymbol,
|
|
72
|
+
get children() {
|
|
73
|
+
return [_$createComponent(DocWhen, {
|
|
74
|
+
get doc() {
|
|
75
|
+
return props.doc;
|
|
76
|
+
}
|
|
77
|
+
}), modifiers, "record ", _$createComponent(Name, {}), typeParams, _$memo(() => _$memo(() => !!props.children)() ? _$createComponent(core.Block, {
|
|
78
|
+
newline: true,
|
|
79
|
+
get children() {
|
|
80
|
+
return _$createComponent(core.Scope, {
|
|
81
|
+
value: thisRecordScope,
|
|
82
|
+
get children() {
|
|
83
|
+
return props.children;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}) : ";")];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.test.d.ts","sourceRoot":"","sources":["../../../../src/components/record/declaration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { 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 { ClassProperty } from "../class/property.js";
|
|
5
|
+
import { RecordDeclaration } from "./declaration.js";
|
|
6
|
+
it("declares class with no members", () => {
|
|
7
|
+
expect(_$createComponent(TestNamespace, {
|
|
8
|
+
get children() {
|
|
9
|
+
return _$createComponent(RecordDeclaration, {
|
|
10
|
+
name: "TestRecord"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
})).toRenderTo(`
|
|
14
|
+
record TestRecord;
|
|
15
|
+
`);
|
|
16
|
+
});
|
|
17
|
+
describe("modifiers", () => {
|
|
18
|
+
it.each(["public", "private", "internal"])("%s", mod => {
|
|
19
|
+
expect(_$createComponent(TestNamespace, {
|
|
20
|
+
get children() {
|
|
21
|
+
return _$createComponent(RecordDeclaration, _$mergeProps({
|
|
22
|
+
[mod]: true
|
|
23
|
+
}, {
|
|
24
|
+
name: "TestRecord"
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
})).toRenderTo(`
|
|
28
|
+
${mod} record TestRecord;
|
|
29
|
+
`);
|
|
30
|
+
});
|
|
31
|
+
it.each(["partial"])("%s", mod => {
|
|
32
|
+
expect(_$createComponent(TestNamespace, {
|
|
33
|
+
get children() {
|
|
34
|
+
return _$createComponent(RecordDeclaration, _$mergeProps({
|
|
35
|
+
[mod]: true
|
|
36
|
+
}, {
|
|
37
|
+
name: "TestRecord"
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
})).toRenderTo(`
|
|
41
|
+
${mod} record TestRecord;
|
|
42
|
+
`);
|
|
43
|
+
});
|
|
44
|
+
it("combines modifiers", () => {
|
|
45
|
+
expect(_$createComponent(TestNamespace, {
|
|
46
|
+
get children() {
|
|
47
|
+
return _$createComponent(RecordDeclaration, {
|
|
48
|
+
"public": true,
|
|
49
|
+
partial: true,
|
|
50
|
+
name: "TestRecord"
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
})).toRenderTo(`
|
|
54
|
+
public partial record TestRecord;
|
|
55
|
+
`);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
it("specify doc comment", () => {
|
|
59
|
+
expect(_$createComponent(TestNamespace, {
|
|
60
|
+
get children() {
|
|
61
|
+
return _$createComponent(RecordDeclaration, {
|
|
62
|
+
name: "TestRecord",
|
|
63
|
+
doc: "This is a test"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
})).toRenderTo(`
|
|
67
|
+
/// This is a test
|
|
68
|
+
record TestRecord;
|
|
69
|
+
`);
|
|
70
|
+
});
|
|
71
|
+
it("specify class property inside", () => {
|
|
72
|
+
expect(_$createComponent(TestNamespace, {
|
|
73
|
+
get children() {
|
|
74
|
+
return _$createComponent(RecordDeclaration, {
|
|
75
|
+
name: "TestRecord",
|
|
76
|
+
doc: "This is a test",
|
|
77
|
+
get children() {
|
|
78
|
+
return _$createComponent(ClassProperty, {
|
|
79
|
+
name: "Prop",
|
|
80
|
+
get: true,
|
|
81
|
+
set: true,
|
|
82
|
+
type: "string"
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
})).toRenderTo(`
|
|
88
|
+
/// This is a test
|
|
89
|
+
record TestRecord
|
|
90
|
+
{
|
|
91
|
+
string Prop { get; set; }
|
|
92
|
+
}
|
|
93
|
+
`);
|
|
94
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
|
-
export type CSharpElements = "class" | "constant" | "enum" | "enum-member" | "function" | "interface" | "class-member-private" | "class-member-public" | "class-method" | "class-property" | "parameter" | "type-parameter";
|
|
2
|
+
export type CSharpElements = "class" | "constant" | "enum" | "enum-member" | "function" | "interface" | "record" | "class-member-private" | "class-member-public" | "class-method" | "class-property" | "parameter" | "type-parameter";
|
|
3
3
|
export declare function createCSharpNamePolicy(): core.NamePolicy<CSharpElements>;
|
|
4
4
|
export declare function useCSharpNamePolicy(): core.NamePolicy<CSharpElements>;
|
|
5
5
|
//# sourceMappingURL=name-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAIvC,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,GACV,WAAW,GACX,sBAAsB,GACtB,qBAAqB,GACrB,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,gBAAgB,CAAC;AAGrB,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAIvC,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,GACV,WAAW,GACX,QAAQ,GACR,sBAAsB,GACtB,qBAAqB,GACrB,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,gBAAgB,CAAC;AAGrB,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAmBxE;AAGD,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAErE"}
|