@alloy-js/csharp 0.18.0-dev.22 → 0.18.0-dev.24
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/ClassDeclaration.d.ts +18 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +6 -0
- package/dist/src/components/ClassMethod.d.ts +18 -0
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +6 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +1 -0
- package/dist/src/components/attributes/attributes.d.ts +39 -0
- package/dist/src/components/attributes/attributes.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.js +62 -0
- package/dist/src/components/attributes/attributes.test.d.ts +2 -0
- package/dist/src/components/attributes/attributes.test.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +75 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/interface/declaration.d.ts +18 -0
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +6 -0
- package/dist/src/components/interface/declaration.test.js +18 -0
- package/dist/src/components/interface/method.d.ts +18 -0
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +6 -0
- package/dist/src/components/interface/method.test.js +21 -0
- package/dist/src/components/interface/property.d.ts +18 -0
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +6 -0
- package/dist/src/components/interface/property.test.js +24 -0
- package/dist/src/components/property/property.d.ts +18 -0
- package/dist/src/components/property/property.d.ts.map +1 -1
- package/dist/src/components/property/property.js +6 -0
- package/dist/src/components/property/property.test.js +24 -0
- package/dist/test/class-declaration.test.js +18 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/ClassDeclaration.tsx +20 -0
- package/src/components/ClassMethod.tsx +20 -0
- package/src/components/SourceFile.tsx +1 -0
- package/src/components/attributes/attributes.test.tsx +61 -0
- package/src/components/attributes/attributes.tsx +100 -0
- package/src/components/index.ts +1 -0
- package/src/components/interface/declaration.test.tsx +15 -0
- package/src/components/interface/declaration.tsx +20 -0
- package/src/components/interface/method.test.tsx +15 -0
- package/src/components/interface/method.tsx +20 -0
- package/src/components/interface/property.test.tsx +21 -0
- package/src/components/interface/property.tsx +20 -0
- package/src/components/property/property.test.tsx +21 -0
- package/src/components/property/property.tsx +20 -0
- package/temp/api.json +596 -0
- package/test/class-declaration.test.tsx +12 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Children, Refkey } from "@alloy-js/core";
|
|
2
2
|
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
+
import { AttributesProp } from "../attributes/attributes.jsx";
|
|
3
4
|
/** Property modifiers. */
|
|
4
5
|
export interface PropertyModifiers {
|
|
5
6
|
readonly new?: boolean;
|
|
@@ -48,6 +49,23 @@ export interface PropertyProps extends AccessModifiers, PropertyModifiers {
|
|
|
48
49
|
* ```
|
|
49
50
|
*/
|
|
50
51
|
initializer?: Children;
|
|
52
|
+
/**
|
|
53
|
+
* Define attributes to attach
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <Property name="MyProp" attributes={[
|
|
57
|
+
* <Attribute name="Test" />
|
|
58
|
+
* <Attribute name="Test2" args={["arg1", "arg2"]} />
|
|
59
|
+
* ]} />
|
|
60
|
+
* ```
|
|
61
|
+
* This will produce:
|
|
62
|
+
* ```csharp
|
|
63
|
+
* [Test]
|
|
64
|
+
* [Test2("arg1", "arg2")]
|
|
65
|
+
* int MyProp { get; set; }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
attributes?: AttributesProp;
|
|
51
69
|
}
|
|
52
70
|
/**
|
|
53
71
|
* Render a C# class property.
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG7E,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;IAEvB;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,YAoD5C"}
|
|
@@ -4,6 +4,7 @@ import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../
|
|
|
4
4
|
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
5
5
|
import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
|
|
6
6
|
import { CSharpMemberScope, useCSharpScope } from "../../symbols/scopes.js";
|
|
7
|
+
import { AttributeList } from "../attributes/attributes.js";
|
|
7
8
|
import { DocWhen } from "../doc/comment.js";
|
|
8
9
|
|
|
9
10
|
/** Property modifiers. */
|
|
@@ -51,6 +52,11 @@ export function Property(props) {
|
|
|
51
52
|
get doc() {
|
|
52
53
|
return props.doc;
|
|
53
54
|
}
|
|
55
|
+
}), _$createComponent(AttributeList, {
|
|
56
|
+
get attributes() {
|
|
57
|
+
return props.attributes;
|
|
58
|
+
},
|
|
59
|
+
endline: true
|
|
54
60
|
}), modifiers, _$memo(() => props.type), _$memo(() => props.nullable && "?"), " ", name, " ", _$createComponent(Block, {
|
|
55
61
|
newline: true,
|
|
56
62
|
inline: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { describe, expect, it } from "vitest";
|
|
3
3
|
import { TestNamespace } from "../../../test/utils.js";
|
|
4
|
+
import { Attribute } from "../attributes/attributes.js";
|
|
4
5
|
import { ClassDeclaration } from "../ClassDeclaration.js";
|
|
5
6
|
import { Property } from "./property.js";
|
|
6
7
|
const Wrapper = props => _$createComponent(TestNamespace, {
|
|
@@ -215,4 +216,27 @@ it("specify initializer", () => {
|
|
|
215
216
|
string TestProp { get; set; } = "abc";
|
|
216
217
|
}
|
|
217
218
|
`);
|
|
219
|
+
});
|
|
220
|
+
it("specify attributes", () => {
|
|
221
|
+
expect(_$createComponent(Wrapper, {
|
|
222
|
+
get children() {
|
|
223
|
+
return _$createComponent(Property, {
|
|
224
|
+
name: "Test",
|
|
225
|
+
type: "int",
|
|
226
|
+
get attributes() {
|
|
227
|
+
return [_$createComponent(Attribute, {
|
|
228
|
+
name: "Test"
|
|
229
|
+
})];
|
|
230
|
+
},
|
|
231
|
+
get: true,
|
|
232
|
+
set: true
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
})).toRenderTo(`
|
|
236
|
+
public class TestClass
|
|
237
|
+
{
|
|
238
|
+
[Test]
|
|
239
|
+
int Test { get; set; }
|
|
240
|
+
}
|
|
241
|
+
`);
|
|
218
242
|
});
|
|
@@ -3,6 +3,7 @@ import * as core from "@alloy-js/core";
|
|
|
3
3
|
import { List, refkey } from "@alloy-js/core";
|
|
4
4
|
import * as coretest from "@alloy-js/core/testing";
|
|
5
5
|
import { describe, expect, it } from "vitest";
|
|
6
|
+
import { Attribute } from "../src/components/attributes/attributes.js";
|
|
6
7
|
import * as csharp from "../src/index.js";
|
|
7
8
|
import { ClassDeclaration, ClassMember, Property, SourceFile } from "../src/index.js";
|
|
8
9
|
import * as utils from "./utils.js";
|
|
@@ -460,4 +461,21 @@ it("supports class member doc comments", () => {
|
|
|
460
461
|
public int Member
|
|
461
462
|
}
|
|
462
463
|
`);
|
|
464
|
+
});
|
|
465
|
+
it("specify attributes", () => {
|
|
466
|
+
expect(_$createComponent(utils.TestNamespace, {
|
|
467
|
+
get children() {
|
|
468
|
+
return _$createComponent(ClassDeclaration, {
|
|
469
|
+
name: "Test",
|
|
470
|
+
get attributes() {
|
|
471
|
+
return [_$createComponent(Attribute, {
|
|
472
|
+
name: "Test"
|
|
473
|
+
})];
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
})).toRenderTo(`
|
|
478
|
+
[Test]
|
|
479
|
+
class Test;
|
|
480
|
+
`);
|
|
463
481
|
});
|