@alloy-js/csharp 0.19.0-dev.4 → 0.19.0-dev.5

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.
Files changed (31) hide show
  1. package/dist/src/components/ClassDeclaration.d.ts +0 -8
  2. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  3. package/dist/src/components/ClassDeclaration.js +1 -31
  4. package/dist/src/components/field/field.d.ts +12 -0
  5. package/dist/src/components/field/field.d.ts.map +1 -0
  6. package/dist/src/components/field/field.js +34 -0
  7. package/dist/src/components/field/field.test.d.ts +2 -0
  8. package/dist/src/components/field/field.test.d.ts.map +1 -0
  9. package/dist/src/components/field/field.test.js +37 -0
  10. package/dist/src/components/index.d.ts +1 -0
  11. package/dist/src/components/index.d.ts.map +1 -1
  12. package/dist/src/components/index.js +1 -0
  13. package/dist/src/components/stc/index.d.ts +1 -1
  14. package/dist/src/components/stc/index.d.ts.map +1 -1
  15. package/dist/src/components/stc/index.js +1 -1
  16. package/dist/src/components/struct/declaration.d.ts +2 -0
  17. package/dist/src/components/struct/declaration.d.ts.map +1 -1
  18. package/dist/src/components/struct/declaration.js +6 -2
  19. package/dist/src/components/struct/declaration.test.js +45 -1
  20. package/dist/test/class-declaration.test.js +8 -7
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +1 -1
  23. package/src/components/ClassDeclaration.tsx +2 -40
  24. package/src/components/field/field.test.tsx +24 -0
  25. package/src/components/field/field.tsx +50 -0
  26. package/src/components/index.ts +1 -0
  27. package/src/components/stc/index.ts +1 -1
  28. package/src/components/struct/declaration.test.tsx +31 -1
  29. package/src/components/struct/declaration.tsx +11 -0
  30. package/temp/api.json +222 -190
  31. package/test/class-declaration.test.tsx +8 -26
@@ -73,12 +73,4 @@ export interface ClassDeclarationProps extends Omit<core.DeclarationProps, "name
73
73
  * ```
74
74
  */
75
75
  export declare function ClassDeclaration(props: ClassDeclarationProps): core.Children;
76
- export interface ClassMemberProps extends AccessModifiers {
77
- name: string;
78
- type: core.Children;
79
- refkey?: core.Refkey;
80
- /** Doc comment */
81
- doc?: core.Children;
82
- }
83
- export declare function ClassMember(props: ClassMemberProps): core.Children;
84
76
  //# sourceMappingURL=ClassDeclaration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAiB,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAUD,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,cAAc;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAEjD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAEzB,uCAAuC;IACvC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEjC;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBA6C5D;AAGD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CACrB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBA0BlD"}
1
+ {"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAiB,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAUD,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,cAAc;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAEjD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAEzB,uCAAuC;IACvC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEjC;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBA6C5D"}
@@ -4,7 +4,7 @@ import { join } from "@alloy-js/core";
4
4
  import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../modifiers.js";
5
5
  import { useCSharpNamePolicy } from "../name-policy.js";
6
6
  import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
7
- import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
7
+ import { CSharpMemberScope } from "../symbols/scopes.js";
8
8
  import { AttributeList } from "./attributes/attributes.js";
9
9
  import { DocWhen } from "./doc/comment.js";
10
10
  import { Name } from "./Name.js";
@@ -89,34 +89,4 @@ export function ClassDeclaration(props) {
89
89
  }))];
90
90
  }
91
91
  });
92
- }
93
-
94
- // properties for creating a class member
95
-
96
- // a C# class member (i.e. a field within a class like "private int count")
97
- export function ClassMember(props) {
98
- let nameElement = "class-member-private";
99
- if (props.public) {
100
- nameElement = "class-member-public";
101
- }
102
- const name = useCSharpNamePolicy().getName(props.name, nameElement);
103
- const scope = useCSharpScope();
104
- if (scope.kind !== "member" || scope.name !== "class-decl") {
105
- throw new Error("can't define a class member outside of a class-decl scope");
106
- }
107
- const memberSymbol = new CSharpOutputSymbol(name, {
108
- scope,
109
- refkeys: props.refkey ?? core.refkey(props.name)
110
- });
111
- const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
112
- return _$createComponent(core.Declaration, {
113
- symbol: memberSymbol,
114
- get children() {
115
- return [_$createComponent(DocWhen, {
116
- get doc() {
117
- return props.doc;
118
- }
119
- }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
120
- }
121
- });
122
92
  }
@@ -0,0 +1,12 @@
1
+ import { Children, Refkey } from "@alloy-js/core";
2
+ import { AccessModifiers } from "../../modifiers.js";
3
+ export interface FieldProps extends AccessModifiers {
4
+ name: string;
5
+ type: Children;
6
+ refkey?: Refkey;
7
+ /** Doc comment */
8
+ doc?: Children;
9
+ }
10
+ /** Render a c# field */
11
+ export declare function Field(props: FieldProps): Children;
12
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/components/field/field.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6B,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EACL,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AAM5B,MAAM,WAAW,UAAW,SAAQ,eAAe;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;CAChB;AAED,wBAAwB;AACxB,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,YA6BtC"}
@@ -0,0 +1,34 @@
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { Declaration, Name, refkey } from "@alloy-js/core";
3
+ import { computeModifiersPrefix, getAccessModifier } from "../../modifiers.js";
4
+ import { useCSharpNamePolicy } from "../../name-policy.js";
5
+ import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
6
+ import { useCSharpScope } from "../../symbols/scopes.js";
7
+ import { DocWhen } from "../doc/comment.js";
8
+ /** Render a c# field */
9
+ export function Field(props) {
10
+ let nameElement = "class-member-private";
11
+ if (props.public) {
12
+ nameElement = "class-member-public";
13
+ }
14
+ const name = useCSharpNamePolicy().getName(props.name, nameElement);
15
+ const scope = useCSharpScope();
16
+ if (scope.kind !== "member" || scope.name !== "class-decl" && scope.name !== "struct-decl") {
17
+ throw new Error("can't define a class member outside of a class or struct scope");
18
+ }
19
+ const memberSymbol = new CSharpOutputSymbol(name, {
20
+ scope,
21
+ refkeys: props.refkey ?? refkey(props.name)
22
+ });
23
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
24
+ return _$createComponent(Declaration, {
25
+ symbol: memberSymbol,
26
+ get children() {
27
+ return [_$createComponent(DocWhen, {
28
+ get doc() {
29
+ return props.doc;
30
+ }
31
+ }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
32
+ }
33
+ });
34
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=field.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.test.d.ts","sourceRoot":"","sources":["../../../../src/components/field/field.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { StatementList } from "@alloy-js/core";
3
+ import { expect, it } from "vitest";
4
+ import { TestNamespace } from "../../../test/utils.js";
5
+ import { ClassDeclaration } from "../ClassDeclaration.js";
6
+ import { Field } from "./field.js";
7
+ it("declares some field", () => {
8
+ expect(_$createComponent(TestNamespace, {
9
+ get children() {
10
+ return _$createComponent(ClassDeclaration, {
11
+ "public": true,
12
+ name: "TestClass",
13
+ get children() {
14
+ return _$createComponent(StatementList, {
15
+ get children() {
16
+ return [_$createComponent(Field, {
17
+ "public": true,
18
+ name: "MemberOne",
19
+ type: "string"
20
+ }), _$createComponent(Field, {
21
+ "private": true,
22
+ name: "MemberTwo",
23
+ type: "int"
24
+ })];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ })).toRenderTo(`
31
+ public class TestClass
32
+ {
33
+ public string MemberOne;
34
+ private int memberTwo;
35
+ }
36
+ `);
37
+ });
@@ -5,6 +5,7 @@ export * from "./Declaration.js";
5
5
  export * from "./doc/comment.jsx";
6
6
  export * from "./doc/from-markdown.jsx";
7
7
  export * from "./EnumDeclaration.jsx";
8
+ export * from "./field/field.jsx";
8
9
  export * from "./interface/declaration.js";
9
10
  export * from "./interface/method.js";
10
11
  export * from "./interface/property.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,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,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
@@ -5,6 +5,7 @@ export * from "./Declaration.js";
5
5
  export * from "./doc/comment.js";
6
6
  export * from "./doc/from-markdown.js";
7
7
  export * from "./EnumDeclaration.js";
8
+ export * from "./field/field.js";
8
9
  export * from "./interface/declaration.js";
9
10
  export * from "./interface/method.js";
10
11
  export * from "./interface/property.js";
@@ -2,7 +2,7 @@ import * as core from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
3
  export declare const ClassDeclaration: core.StcSignature<base.ClassDeclarationProps>;
4
4
  export declare const Constructor: core.StcSignature<base.ConstructorProps>;
5
- export declare const ClassMember: core.StcSignature<base.ClassMemberProps>;
5
+ export declare const Field: core.StcSignature<base.FieldProps>;
6
6
  export declare const ClassMethod: core.StcSignature<base.MethodProps>;
7
7
  export declare const EnumDeclaration: core.StcSignature<base.EnumDeclarationProps>;
8
8
  export declare const EnumMember: core.StcSignature<base.EnumMemberProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,WAAW,qCAAwB,CAAC;AACjD,eAAO,MAAM,eAAe,8CAAiC,CAAC;AAC9D,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,SAAS,wCAA2B,CAAC;AAClD,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,cAAc,6CAAgC,CAAC;AAC5D,eAAO,MAAM,iBAAiB,gDAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,KAAK,oCAAuB,CAAC;AAC1C,eAAO,MAAM,WAAW,qCAAwB,CAAC;AACjD,eAAO,MAAM,eAAe,8CAAiC,CAAC;AAC9D,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,SAAS,wCAA2B,CAAC;AAClD,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,cAAc,6CAAgC,CAAC;AAC5D,eAAO,MAAM,iBAAiB,gDAAmC,CAAC"}
@@ -2,7 +2,7 @@ import * as core from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
3
  export const ClassDeclaration = core.stc(base.ClassDeclaration);
4
4
  export const Constructor = core.stc(base.Constructor);
5
- export const ClassMember = core.stc(base.ClassMember);
5
+ export const Field = core.stc(base.Field);
6
6
  export const ClassMethod = core.stc(base.Method);
7
7
  export const EnumDeclaration = core.stc(base.EnumDeclaration);
8
8
  export const EnumMember = core.stc(base.EnumMember);
@@ -43,6 +43,8 @@ export interface StructDeclarationProps extends Omit<core.DeclarationProps, "nam
43
43
  * ```
44
44
  */
45
45
  attributes?: AttributesProp;
46
+ /** Interfaces this struct implements */
47
+ interfaceTypes?: core.Children[];
46
48
  }
47
49
  /**
48
50
  * CSharp struct declaration.
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/struct/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,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;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,iBAiC9D"}
1
+ {"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/struct/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,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;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,wCAAwC;IACxC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,iBAwC9D"}
@@ -1,5 +1,6 @@
1
- import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
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 { join } from "@alloy-js/core";
3
4
  import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../../modifiers.js";
4
5
  import { useCSharpNamePolicy } from "../../name-policy.js";
5
6
  import { CSharpOutputSymbol } from "../../symbols/csharp-output-symbol.js";
@@ -42,6 +43,9 @@ export function StructDeclaration(props) {
42
43
  owner: thisStructSymbol
43
44
  });
44
45
  const modifiers = computeModifiersPrefix([getAccessModifier(props), getStructModifiers(props)]);
46
+ const base = props.interfaceTypes && props.interfaceTypes.length > 0 ? [" : ", _$memo(() => join(props.interfaceTypes, {
47
+ joiner: ", "
48
+ }))] : null;
45
49
  return _$createComponent(core.Declaration, {
46
50
  symbol: thisStructSymbol,
47
51
  get children() {
@@ -58,7 +62,7 @@ export function StructDeclaration(props) {
58
62
  get parameters() {
59
63
  return props.typeParameters;
60
64
  }
61
- })), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
65
+ })), base, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
62
66
  get parameters() {
63
67
  return props.typeParameters;
64
68
  }
@@ -1,9 +1,10 @@
1
1
  import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
- import { List, refkey } from "@alloy-js/core";
2
+ import { List, refkey, StatementList } from "@alloy-js/core";
3
3
  import { describe, expect, it } from "vitest";
4
4
  import { TestNamespace } from "../../../test/utils.js";
5
5
  import { Attribute } from "../attributes/attributes.js";
6
6
  import { Constructor } from "../constructor/constructor.js";
7
+ import { Field } from "../field/field.js";
7
8
  import { Method } from "../method/method.js";
8
9
  import { Property } from "../property/property.js";
9
10
  import { SourceFile } from "../SourceFile.js";
@@ -208,4 +209,47 @@ it("define constructor", () => {
208
209
  public Test() {}
209
210
  }
210
211
  `);
212
+ });
213
+ it("defines fields", () => {
214
+ expect(_$createComponent(TestNamespace, {
215
+ get children() {
216
+ return _$createComponent(StructDeclaration, {
217
+ "public": true,
218
+ name: "TestClass",
219
+ get children() {
220
+ return _$createComponent(StatementList, {
221
+ get children() {
222
+ return [_$createComponent(Field, {
223
+ "public": true,
224
+ name: "MemberOne",
225
+ type: "string"
226
+ }), _$createComponent(Field, {
227
+ "private": true,
228
+ name: "MemberTwo",
229
+ type: "int"
230
+ })];
231
+ }
232
+ });
233
+ }
234
+ });
235
+ }
236
+ })).toRenderTo(`
237
+ public struct TestClass
238
+ {
239
+ public string MemberOne;
240
+ private int memberTwo;
241
+ }
242
+ `);
243
+ });
244
+ it("define multiple interface types", () => {
245
+ expect(_$createComponent(TestNamespace, {
246
+ get children() {
247
+ return _$createComponent(StructDeclaration, {
248
+ name: "Test",
249
+ interfaceTypes: ["Foo", "Bar"]
250
+ });
251
+ }
252
+ })).toRenderTo(`
253
+ struct Test : Foo, Bar;
254
+ `);
211
255
  });
@@ -4,9 +4,10 @@ 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
6
  import { Attribute } from "../src/components/attributes/attributes.js";
7
+ import { Field } from "../src/components/field/field.js";
7
8
  import { Constructor } from "../src/components/stc/index.js";
8
9
  import * as csharp from "../src/index.js";
9
- import { ClassDeclaration, ClassMember, Property, SourceFile } from "../src/index.js";
10
+ import { ClassDeclaration, Property, SourceFile } from "../src/index.js";
10
11
  import * as utils from "./utils.js";
11
12
  it("declares class with no members", () => {
12
13
  expect(_$createComponent(utils.TestNamespace, {
@@ -107,11 +108,11 @@ it("declares class with some members", () => {
107
108
  get children() {
108
109
  return _$createComponent(core.StatementList, {
109
110
  get children() {
110
- return [_$createComponent(csharp.ClassMember, {
111
+ return [_$createComponent(Field, {
111
112
  "public": true,
112
113
  name: "MemberOne",
113
114
  type: "string"
114
- }), _$createComponent(csharp.ClassMember, {
115
+ }), _$createComponent(Field, {
115
116
  "private": true,
116
117
  name: "MemberTwo",
117
118
  type: "int"
@@ -212,7 +213,7 @@ it("uses refkeys for members, params, and return type", () => {
212
213
  "public": true,
213
214
  name: "TestClass",
214
215
  get children() {
215
- return [_$createComponent(csharp.ClassMember, {
216
+ return [_$createComponent(Field, {
216
217
  "private": true,
217
218
  name: "MemberOne",
218
219
  type: enumTypeRefkey
@@ -387,12 +388,12 @@ it("declares class with constructor params and assigns values to fields", () =>
387
388
  "public": true,
388
389
  name: "TestClass",
389
390
  get children() {
390
- return [_$createComponent(csharp.ClassMember, {
391
+ return [_$createComponent(Field, {
391
392
  "private": true,
392
393
  name: "name",
393
394
  type: "string",
394
395
  refkey: thisNameRefkey
395
- }), ";", _$createIntrinsic("hbr", {}), _$createComponent(csharp.ClassMember, {
396
+ }), ";", _$createIntrinsic("hbr", {}), _$createComponent(Field, {
396
397
  "private": true,
397
398
  name: "size",
398
399
  type: "int",
@@ -445,7 +446,7 @@ it("supports class member doc comments", () => {
445
446
  name: "Test",
446
447
  doc: "This is a test",
447
448
  get children() {
448
- return _$createComponent(ClassMember, {
449
+ return _$createComponent(Field, {
449
450
  name: "Member",
450
451
  "public": true,
451
452
  type: "int",