@alloy-js/csharp 0.18.0-dev.24 → 0.18.0-dev.4

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 (166) hide show
  1. package/dist/src/components/Class.d.ts +23 -0
  2. package/dist/src/components/Class.d.ts.map +1 -0
  3. package/dist/src/components/{ClassDeclaration.js → Class.js} +37 -67
  4. package/dist/src/components/ClassMethod.d.ts +3 -44
  5. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  6. package/dist/src/components/ClassMethod.js +8 -32
  7. package/dist/src/components/Enum.d.ts +14 -0
  8. package/dist/src/components/Enum.d.ts.map +1 -0
  9. package/dist/src/components/{EnumDeclaration.js → Enum.js} +2 -21
  10. package/dist/src/components/Parameters.d.ts +13 -0
  11. package/dist/src/components/Parameters.d.ts.map +1 -0
  12. package/dist/src/components/Parameters.js +34 -0
  13. package/dist/src/components/SourceFile.d.ts.map +1 -1
  14. package/dist/src/components/SourceFile.js +0 -1
  15. package/dist/src/components/index.d.ts +4 -14
  16. package/dist/src/components/index.d.ts.map +1 -1
  17. package/dist/src/components/index.js +5 -15
  18. package/dist/src/components/stc/index.d.ts +2 -2
  19. package/dist/src/components/stc/index.d.ts.map +1 -1
  20. package/dist/src/components/stc/index.js +2 -2
  21. package/dist/src/modifiers.d.ts +9 -2
  22. package/dist/src/modifiers.d.ts.map +1 -1
  23. package/dist/src/modifiers.js +9 -6
  24. package/dist/src/name-policy.d.ts +1 -1
  25. package/dist/src/name-policy.d.ts.map +1 -1
  26. package/dist/src/name-policy.js +0 -2
  27. package/dist/test/class-method.test.js +2 -23
  28. package/dist/test/class.test.d.ts +2 -0
  29. package/dist/test/class.test.d.ts.map +1 -0
  30. package/dist/test/{class-declaration.test.js → class.test.js} +51 -234
  31. package/dist/test/enum.test.js +6 -6
  32. package/dist/test/namespace.test.js +4 -4
  33. package/dist/test/projectdirectory.test.d.ts +2 -0
  34. package/dist/test/projectdirectory.test.d.ts.map +1 -0
  35. package/dist/test/{project-directory.test.js → projectdirectory.test.js} +4 -4
  36. package/dist/test/sourcefile.test.js +2 -2
  37. package/dist/test/using.test.js +4 -4
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +3 -4
  40. package/src/components/{ClassDeclaration.tsx → Class.tsx} +38 -116
  41. package/src/components/ClassMethod.tsx +7 -70
  42. package/src/components/{EnumDeclaration.tsx → Enum.tsx} +3 -22
  43. package/src/components/Parameters.tsx +51 -0
  44. package/src/components/SourceFile.tsx +0 -1
  45. package/src/components/index.ts +4 -14
  46. package/src/components/stc/index.ts +2 -2
  47. package/src/modifiers.ts +30 -16
  48. package/src/name-policy.ts +0 -5
  49. package/temp/api.json +1194 -6218
  50. package/test/class-method.test.tsx +3 -19
  51. package/test/class.test.tsx +257 -0
  52. package/test/enum.test.tsx +11 -13
  53. package/test/namespace.test.tsx +4 -4
  54. package/test/{project-directory.test.tsx → projectdirectory.test.tsx} +4 -4
  55. package/test/sourcefile.test.tsx +2 -2
  56. package/test/using.test.tsx +6 -14
  57. package/vitest.config.ts +0 -3
  58. package/dist/src/components/ClassDeclaration.d.ts +0 -92
  59. package/dist/src/components/ClassDeclaration.d.ts.map +0 -1
  60. package/dist/src/components/EnumDeclaration.d.ts +0 -34
  61. package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
  62. package/dist/src/components/attributes/attributes.d.ts +0 -39
  63. package/dist/src/components/attributes/attributes.d.ts.map +0 -1
  64. package/dist/src/components/attributes/attributes.js +0 -62
  65. package/dist/src/components/attributes/attributes.test.d.ts +0 -2
  66. package/dist/src/components/attributes/attributes.test.d.ts.map +0 -1
  67. package/dist/src/components/attributes/attributes.test.js +0 -75
  68. package/dist/src/components/doc/comment.d.ts +0 -70
  69. package/dist/src/components/doc/comment.d.ts.map +0 -1
  70. package/dist/src/components/doc/comment.js +0 -88
  71. package/dist/src/components/doc/comment.test.d.ts +0 -2
  72. package/dist/src/components/doc/comment.test.d.ts.map +0 -1
  73. package/dist/src/components/doc/comment.test.js +0 -348
  74. package/dist/src/components/doc/from-markdown.d.ts +0 -6
  75. package/dist/src/components/doc/from-markdown.d.ts.map +0 -1
  76. package/dist/src/components/doc/from-markdown.js +0 -58
  77. package/dist/src/components/doc/from-markdown.test.d.ts +0 -2
  78. package/dist/src/components/doc/from-markdown.test.d.ts.map +0 -1
  79. package/dist/src/components/doc/from-markdown.test.js +0 -83
  80. package/dist/src/components/interface/declaration.d.ts +0 -65
  81. package/dist/src/components/interface/declaration.d.ts.map +0 -1
  82. package/dist/src/components/interface/declaration.js +0 -83
  83. package/dist/src/components/interface/declaration.test.d.ts +0 -2
  84. package/dist/src/components/interface/declaration.test.d.ts.map +0 -1
  85. package/dist/src/components/interface/declaration.test.js +0 -171
  86. package/dist/src/components/interface/method.d.ts +0 -50
  87. package/dist/src/components/interface/method.d.ts.map +0 -1
  88. package/dist/src/components/interface/method.js +0 -74
  89. package/dist/src/components/interface/method.test.d.ts +0 -2
  90. package/dist/src/components/interface/method.test.d.ts.map +0 -1
  91. package/dist/src/components/interface/method.test.js +0 -300
  92. package/dist/src/components/interface/property.d.ts +0 -56
  93. package/dist/src/components/interface/property.d.ts.map +0 -1
  94. package/dist/src/components/interface/property.js +0 -73
  95. package/dist/src/components/interface/property.test.d.ts +0 -2
  96. package/dist/src/components/interface/property.test.d.ts.map +0 -1
  97. package/dist/src/components/interface/property.test.js +0 -189
  98. package/dist/src/components/parameters/parameters.d.ts +0 -19
  99. package/dist/src/components/parameters/parameters.d.ts.map +0 -1
  100. package/dist/src/components/parameters/parameters.js +0 -43
  101. package/dist/src/components/property/property.d.ts +0 -80
  102. package/dist/src/components/property/property.d.ts.map +0 -1
  103. package/dist/src/components/property/property.js +0 -76
  104. package/dist/src/components/property/property.test.d.ts +0 -2
  105. package/dist/src/components/property/property.test.d.ts.map +0 -1
  106. package/dist/src/components/property/property.test.js +0 -242
  107. package/dist/src/components/record/declaration.d.ts +0 -35
  108. package/dist/src/components/record/declaration.d.ts.map +0 -1
  109. package/dist/src/components/record/declaration.js +0 -90
  110. package/dist/src/components/record/declaration.test.d.ts +0 -2
  111. package/dist/src/components/record/declaration.test.d.ts.map +0 -1
  112. package/dist/src/components/record/declaration.test.js +0 -94
  113. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +0 -8
  114. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +0 -1
  115. package/dist/src/components/type-parameters/type-parameter-constraints.js +0 -44
  116. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +0 -2
  117. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +0 -1
  118. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +0 -67
  119. package/dist/src/components/type-parameters/type-parameter.d.ts +0 -20
  120. package/dist/src/components/type-parameters/type-parameter.d.ts.map +0 -1
  121. package/dist/src/components/type-parameters/type-parameter.js +0 -22
  122. package/dist/src/components/type-parameters/type-parameters.d.ts +0 -17
  123. package/dist/src/components/type-parameters/type-parameters.d.ts.map +0 -1
  124. package/dist/src/components/type-parameters/type-parameters.js +0 -54
  125. package/dist/src/components/type-parameters/type-parameters.test.d.ts +0 -2
  126. package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +0 -1
  127. package/dist/src/components/type-parameters/type-parameters.test.js +0 -48
  128. package/dist/src/components/var/declaration.d.ts +0 -35
  129. package/dist/src/components/var/declaration.d.ts.map +0 -1
  130. package/dist/src/components/var/declaration.js +0 -40
  131. package/dist/src/components/var/declaration.test.d.ts +0 -2
  132. package/dist/src/components/var/declaration.test.d.ts.map +0 -1
  133. package/dist/src/components/var/declaration.test.js +0 -73
  134. package/dist/test/class-declaration.test.d.ts +0 -2
  135. package/dist/test/class-declaration.test.d.ts.map +0 -1
  136. package/dist/test/project-directory.test.d.ts +0 -2
  137. package/dist/test/project-directory.test.d.ts.map +0 -1
  138. package/dist/test/vitest.setup.d.ts +0 -2
  139. package/dist/test/vitest.setup.d.ts.map +0 -1
  140. package/dist/test/vitest.setup.js +0 -1
  141. package/src/components/attributes/attributes.test.tsx +0 -61
  142. package/src/components/attributes/attributes.tsx +0 -100
  143. package/src/components/doc/comment.test.tsx +0 -337
  144. package/src/components/doc/comment.tsx +0 -152
  145. package/src/components/doc/from-markdown.test.tsx +0 -103
  146. package/src/components/doc/from-markdown.tsx +0 -58
  147. package/src/components/interface/declaration.test.tsx +0 -158
  148. package/src/components/interface/declaration.tsx +0 -125
  149. package/src/components/interface/method.test.tsx +0 -293
  150. package/src/components/interface/method.tsx +0 -122
  151. package/src/components/interface/property.test.tsx +0 -165
  152. package/src/components/interface/property.tsx +0 -127
  153. package/src/components/parameters/parameters.tsx +0 -74
  154. package/src/components/property/property.test.tsx +0 -209
  155. package/src/components/property/property.tsx +0 -172
  156. package/src/components/record/declaration.test.tsx +0 -73
  157. package/src/components/record/declaration.tsx +0 -109
  158. package/src/components/type-parameters/type-parameter-constraints.test.tsx +0 -93
  159. package/src/components/type-parameters/type-parameter-constraints.tsx +0 -46
  160. package/src/components/type-parameters/type-parameter.tsx +0 -35
  161. package/src/components/type-parameters/type-parameters.test.tsx +0 -46
  162. package/src/components/type-parameters/type-parameters.tsx +0 -63
  163. package/src/components/var/declaration.test.tsx +0 -59
  164. package/src/components/var/declaration.tsx +0 -47
  165. package/test/class-declaration.test.tsx +0 -430
  166. package/test/vitest.setup.ts +0 -1
@@ -0,0 +1,23 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifiers } from "../modifiers.js";
3
+ import { ParameterProps } from "./Parameters.js";
4
+ export interface ClassProps extends Omit<core.DeclarationProps, "nameKind">, AccessModifiers {
5
+ name: string;
6
+ refkey?: core.Refkey;
7
+ typeParameters?: Record<string, core.Refkey>;
8
+ }
9
+ export declare function Class(props: ClassProps): core.Children;
10
+ export interface ClassConstructorProps extends AccessModifiers {
11
+ parameters?: Array<ParameterProps>;
12
+ refkey?: core.Refkey;
13
+ symbol?: core.OutputSymbol;
14
+ children?: core.Children;
15
+ }
16
+ export declare function ClassConstructor(props: ClassConstructorProps): core.Children;
17
+ export interface ClassMemberProps extends AccessModifiers {
18
+ name: string;
19
+ type: core.Children;
20
+ refkey?: core.Refkey;
21
+ }
22
+ export declare function ClassMember(props: ClassMemberProps): core.Children;
23
+ //# sourceMappingURL=Class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Class.d.ts","sourceRoot":"","sources":["../../../src/components/Class.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,cAAc,EAAc,MAAM,iBAAiB,CAAC;AAG7D,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;CAC9C;AAGD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,iBAqDtC;AAED,MAAM,WAAW,qBAAsB,SAAQ,eAAe;IAC5D,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBAkC5D;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;CACtB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBAyBlD"}
@@ -1,45 +1,16 @@
1
- import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
- import { join } from "@alloy-js/core";
4
- import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../modifiers.js";
3
+ import { computeModifiersPrefix, getAccessModifier } from "../modifiers.js";
5
4
  import { useCSharpNamePolicy } from "../name-policy.js";
6
5
  import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
7
6
  import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
8
- import { AttributeList } from "./attributes/attributes.js";
9
- import { DocWhen } from "./doc/comment.js";
10
7
  import { Name } from "./Name.js";
11
- import { Parameters } from "./parameters/parameters.js";
12
- import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
13
- import { TypeParameters } from "./type-parameters/type-parameters.js";
14
- const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
8
+ import { Parameters } from "./Parameters.js";
15
9
 
16
10
  // properties for creating a class
17
11
 
18
- /**
19
- * CSharp class declaration.
20
- * @example
21
- * ```tsx
22
- * <ClassDeclaration public name="MyClass">
23
- * <ClassMember public name="MyField" type="int" />
24
- * <ClassConstructor>
25
- * <Parameter name="value" type="int" />
26
- * this.MyField = value;
27
- * </ClassConstructor>
28
- * </ClassDeclaration>
29
- * ```
30
- * This will produce:
31
- * ```csharp
32
- * public class MyClass
33
- * {
34
- * public int MyField;
35
- * public MyClass(int value)
36
- * {
37
- * this.MyField = value;
38
- * }
39
- * }
40
- * ```
41
- */
42
- export function ClassDeclaration(props) {
12
+ // a C# class declaration
13
+ export function Class(props) {
43
14
  const name = useCSharpNamePolicy().getName(props.name, "class");
44
15
  const thisClassSymbol = new CSharpOutputSymbol(name, {
45
16
  refkeys: props.refkey
@@ -52,32 +23,34 @@ export function ClassDeclaration(props) {
52
23
  const thisClassScope = new CSharpMemberScope("class-decl", {
53
24
  owner: thisClassSymbol
54
25
  });
55
- const bases = [...(props.baseType ? [props.baseType] : []), ...(props.interfaceTypes || [])];
56
- const base = bases.length > 0 ? [" : ", _$memo(() => join(bases, {
57
- joiner: ", "
58
- }))] : null;
59
- const modifiers = computeModifiersPrefix([getAccessModifier(props), getClassModifiers(props)]);
26
+ let typeParams;
27
+ if (props.typeParameters) {
28
+ const typeParamNames = new Array();
29
+ for (const entry of Object.entries(props.typeParameters)) {
30
+ typeParamNames.push(useCSharpNamePolicy().getName(entry[0], "type-parameter"));
31
+ // create a symbol for each type param so its
32
+ // refkey resolves to the type param's name
33
+ new CSharpOutputSymbol(entry[0], {
34
+ scope: thisClassScope,
35
+ refkeys: entry[1]
36
+ });
37
+ }
38
+ typeParams = _$createIntrinsic("group", {
39
+ get children() {
40
+ return ["<", _$createComponent(core.For, {
41
+ each: typeParamNames,
42
+ comma: true,
43
+ line: true,
44
+ children: name => name
45
+ }), ">"];
46
+ }
47
+ });
48
+ }
49
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
60
50
  return _$createComponent(core.Declaration, {
61
51
  symbol: thisClassSymbol,
62
52
  get children() {
63
- return [_$createComponent(DocWhen, {
64
- get doc() {
65
- return props.doc;
66
- }
67
- }), _$createComponent(AttributeList, {
68
- get attributes() {
69
- return props.attributes;
70
- },
71
- endline: true
72
- }), modifiers, "class ", _$createComponent(Name, {}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
73
- get parameters() {
74
- return props.typeParameters;
75
- }
76
- })), base, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
77
- get parameters() {
78
- return props.typeParameters;
79
- }
80
- })), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
53
+ return [modifiers, "class ", _$createComponent(Name, {}), typeParams, _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
81
54
  newline: true,
82
55
  get children() {
83
56
  return _$createComponent(core.Scope, {
@@ -110,6 +83,11 @@ export function ClassConstructor(props) {
110
83
  owner: ctorSymbol
111
84
  });
112
85
  const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
86
+ const params = props.parameters ? _$createComponent(Parameters, {
87
+ get parameters() {
88
+ return props.parameters;
89
+ }
90
+ }) : "";
113
91
 
114
92
  // note that scope wraps the ctor decl so that the params get the correct scope
115
93
  return _$createComponent(core.Declaration, {
@@ -118,11 +96,7 @@ export function ClassConstructor(props) {
118
96
  return _$createComponent(core.Scope, {
119
97
  value: ctorDeclScope,
120
98
  get children() {
121
- return [modifiers, _$createComponent(Name, {}), _$createComponent(Parameters, {
122
- get parameters() {
123
- return props.parameters;
124
- }
125
- }), _$createComponent(core.Block, {
99
+ return [modifiers, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
126
100
  newline: true,
127
101
  get children() {
128
102
  return props.children;
@@ -155,11 +129,7 @@ export function ClassMember(props) {
155
129
  return _$createComponent(core.Declaration, {
156
130
  symbol: memberSymbol,
157
131
  get children() {
158
- return [_$createComponent(DocWhen, {
159
- get doc() {
160
- return props.doc;
161
- }
162
- }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
132
+ return [modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
163
133
  }
164
134
  });
165
135
  }
@@ -1,16 +1,7 @@
1
1
  import { Children, Refkey } from "@alloy-js/core";
2
- import { AccessModifiers } from "../modifiers.js";
3
- import { AttributesProp } from "./attributes/attributes.jsx";
4
- import { ParameterProps } from "./parameters/parameters.jsx";
5
- import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
6
- /** Method modifiers. Can only be one. */
7
- export interface ClassMethodModifiers {
8
- readonly abstract?: boolean;
9
- readonly sealed?: boolean;
10
- readonly static?: boolean;
11
- readonly virtual?: boolean;
12
- }
13
- export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers {
2
+ import { AccessModifiers, MethodModifiers } from "../modifiers.js";
3
+ import { ParameterProps } from "./Parameters.jsx";
4
+ export interface ClassMethodProps extends AccessModifiers, MethodModifiers {
14
5
  name: string;
15
6
  refkey?: Refkey;
16
7
  children?: Children;
@@ -20,38 +11,6 @@ export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers
20
11
  * If true, the method will be declared as an async method.
21
12
  */
22
13
  async?: boolean;
23
- /** Doc comment */
24
- doc?: Children;
25
- /**
26
- * Type parameters for the method
27
- *
28
- * @example
29
- * ```tsx
30
- * <InterfaceMethod name="Test" typeParameters={["T"]} />
31
- * ```
32
- * This will produce:
33
- * ```csharp
34
- * public void Test<T>()
35
- * ```
36
- */
37
- typeParameters?: (TypeParameterProps | string)[];
38
- /**
39
- * Define attributes to attach
40
- * @example
41
- * ```tsx
42
- * <ClassMethod name="MyMethod" attributes={[
43
- * <Attribute name="Test" />
44
- * <Attribute name="Test2" args={["arg1", "arg2"]} />
45
- * ]} />
46
- * ```
47
- * This will produce:
48
- * ```csharp
49
- * [Test]
50
- * [Test2("arg1", "arg2")]
51
- * public void MyMethod() { }
52
- * ```
53
- */
54
- attributes?: AttributesProp;
55
14
  }
56
15
  export declare function ClassMethod(props: ClassMethodProps): Children;
57
16
  //# sourceMappingURL=ClassMethod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKhB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAiB,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE5E,OAAO,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,MAAM,WAAW,gBACf,SAAQ,eAAe,EACrB,oBAAoB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YA2ClD"}
1
+ {"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKf,eAAe,EAChB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAG9D,MAAM,WAAW,gBAAiB,SAAQ,eAAe,EAAE,eAAe;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAoClD"}
@@ -1,18 +1,10 @@
1
1
  import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import { Block, MemberDeclaration, refkey, Scope } from "@alloy-js/core";
3
- import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, makeModifiers } from "../modifiers.js";
3
+ import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, getMethodModifier } from "../modifiers.js";
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";
8
- import { DocWhen } from "./doc/comment.js";
9
- import { Parameters } from "./parameters/parameters.js";
10
- import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
11
- import { TypeParameters } from "./type-parameters/type-parameters.js";
12
-
13
- /** Method modifiers. Can only be one. */
14
-
15
- const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
7
+ import { Parameters } from "./Parameters.js";
16
8
 
17
9
  // properties for creating a method
18
10
 
@@ -32,6 +24,11 @@ export function ClassMethod(props) {
32
24
  const methodScope = new CSharpMemberScope("method-decl", {
33
25
  owner: methodSymbol
34
26
  });
27
+ const params = props.parameters ? _$createComponent(Parameters, {
28
+ get parameters() {
29
+ return props.parameters;
30
+ }
31
+ }) : "";
35
32
  const returns = props.returns ?? (props.async ? "Task" : "void");
36
33
  const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
37
34
  // note that scope wraps the method decl so that the params get the correct scope
@@ -41,28 +38,7 @@ export function ClassMethod(props) {
41
38
  return _$createComponent(Scope, {
42
39
  value: methodScope,
43
40
  get children() {
44
- return [_$createComponent(DocWhen, {
45
- get doc() {
46
- return props.doc;
47
- }
48
- }), _$createComponent(AttributeList, {
49
- get attributes() {
50
- return props.attributes;
51
- },
52
- endline: true
53
- }), modifiers, returns, " ", name, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
54
- get parameters() {
55
- return props.typeParameters;
56
- }
57
- })), _$createComponent(Parameters, {
58
- get parameters() {
59
- return props.parameters;
60
- }
61
- }), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
62
- get parameters() {
63
- return props.typeParameters;
64
- }
65
- })), _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
41
+ return [modifiers, returns, " ", name, "(", params, ")", _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
66
42
  newline: true,
67
43
  get children() {
68
44
  return props.children;
@@ -0,0 +1,14 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifiers } from "../modifiers.js";
3
+ export interface EnumProps extends AccessModifiers {
4
+ name: string;
5
+ refkey?: core.Refkey;
6
+ children?: core.Children;
7
+ }
8
+ export declare function Enum(props: EnumProps): core.Children;
9
+ export interface EnumMemberProps {
10
+ name: string;
11
+ refkey?: core.Refkey;
12
+ }
13
+ export declare function EnumMember(props: EnumMemberProps): core.Children;
14
+ //# sourceMappingURL=Enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Enum.d.ts","sourceRoot":"","sources":["../../../src/components/Enum.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAOzB,MAAM,WAAW,SAAU,SAAQ,eAAe;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAGD,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,iBAgCpC;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;CACtB;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAmBhD"}
@@ -8,27 +8,8 @@ import { Name } from "./Name.js";
8
8
 
9
9
  // properties for creating an enum
10
10
 
11
- /**
12
- * A C# enum declaration
13
- * @example
14
- * ```tsx
15
- * <EnumDeclaration public name="Color">
16
- * <EnumMember name="Red" />
17
- * <EnumMember name="Green" />
18
- * <EnumMember name="Blue" />
19
- * </EnumDeclaration>
20
- * ```
21
- * This will produce:
22
- * ```csharp
23
- * public enum Color
24
- * {
25
- * Red,
26
- * Green,
27
- * Blue
28
- * }
29
- * ```
30
- */
31
- export function EnumDeclaration(props) {
11
+ // a C# enum declaration
12
+ export function Enum(props) {
32
13
  const name = useCSharpNamePolicy().getName(props.name, "enum");
33
14
  const scope = useCSharpScope();
34
15
  const thisEnumSymbol = new CSharpOutputSymbol(name, {
@@ -0,0 +1,13 @@
1
+ import * as core from "@alloy-js/core";
2
+ export interface ParameterProps {
3
+ name: string;
4
+ type: core.Children;
5
+ refkey?: core.Refkey;
6
+ symbol?: core.OutputSymbol;
7
+ }
8
+ export declare function Parameter(props: ParameterProps): core.Children;
9
+ export interface ParametersProps {
10
+ parameters: Array<ParameterProps>;
11
+ }
12
+ export declare function Parameters(props: ParametersProps): core.Children;
13
+ //# sourceMappingURL=Parameters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Parameters.d.ts","sourceRoot":"","sources":["../../../src/components/Parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAMvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;CAC5B;AAGD,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,iBAsB9C;AAED,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CACnC;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAMhD"}
@@ -0,0 +1,34 @@
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as core 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
+ // a constructor/method parameter
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 ?? core.refkey(props.name)
17
+ });
18
+ return _$createComponent(core.Declaration, {
19
+ symbol: memberSymbol,
20
+ get children() {
21
+ return [_$memo(() => props.type), " ", _$createComponent(Name, {})];
22
+ }
23
+ });
24
+ }
25
+ // a collection of parameters
26
+ export function Parameters(props) {
27
+ return _$createComponent(core.For, {
28
+ get each() {
29
+ return props.parameters;
30
+ },
31
+ joiner: ", ",
32
+ children: param => _$createComponent(Parameter, param)
33
+ });
34
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAMvC,MAAM,WAAW,iBAAiB;IAEhC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAKD,wBAAgB,aAAa,IAAI,iBAAiB,GAAG,SAAS,CAE7D;AAED,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,kCAAkC;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEtB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBA+ChD"}
1
+ {"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAMvC,MAAM,WAAW,iBAAiB;IAEhC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAKD,wBAAgB,aAAa,IAAI,iBAAiB,GAAG,SAAS,CAE7D;AAED,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,kCAAkC;IAClC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEtB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBA8ChD"}
@@ -41,7 +41,6 @@ export function SourceFile(props) {
41
41
  filetype: "cs",
42
42
  reference: Reference,
43
43
  tabWidth: 4,
44
- printWidth: 120,
45
44
  get children() {
46
45
  return _$createComponent(SourceFileContext.Provider, {
47
46
  value: sourceFileCtx,
@@ -1,22 +1,12 @@
1
- export * from "./attributes/attributes.jsx";
2
- export * from "./ClassDeclaration.jsx";
3
- export * from "./ClassMethod.jsx";
1
+ export * from "./Class.js";
2
+ export { ClassMethod, type ClassMethodProps } from "./ClassMethod.jsx";
4
3
  export * from "./Declaration.js";
5
- export * from "./doc/comment.jsx";
6
- export * from "./doc/from-markdown.jsx";
7
- export * from "./EnumDeclaration.jsx";
8
- export * from "./interface/declaration.js";
9
- export * from "./interface/method.js";
10
- export * from "./interface/property.js";
4
+ export * from "./Enum.js";
11
5
  export * from "./Name.js";
12
6
  export * from "./Namespace.js";
13
- export * from "./parameters/parameters.jsx";
7
+ export * from "./Parameters.js";
14
8
  export * from "./ProjectDirectory.js";
15
- export * from "./property/property.jsx";
16
- export * from "./record/declaration.js";
17
9
  export * from "./Reference.js";
18
10
  export * from "./SourceFile.js";
19
- export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
20
11
  export * from "./UsingDirective.js";
21
- export * from "./var/declaration.jsx";
22
12
  //# sourceMappingURL=index.d.ts.map
@@ -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,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,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,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,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,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,21 +1,11 @@
1
- export * from "./attributes/attributes.js";
2
- export * from "./ClassDeclaration.js";
3
- export * from "./ClassMethod.js";
1
+ export * from "./Class.js";
2
+ export { ClassMethod } from "./ClassMethod.js";
4
3
  export * from "./Declaration.js";
5
- export * from "./doc/comment.js";
6
- export * from "./doc/from-markdown.js";
7
- export * from "./EnumDeclaration.js";
8
- export * from "./interface/declaration.js";
9
- export * from "./interface/method.js";
10
- export * from "./interface/property.js";
4
+ export * from "./Enum.js";
11
5
  export * from "./Name.js";
12
6
  export * from "./Namespace.js";
13
- export * from "./parameters/parameters.js";
7
+ export * from "./Parameters.js";
14
8
  export * from "./ProjectDirectory.js";
15
- export * from "./property/property.js";
16
- export * from "./record/declaration.js";
17
9
  export * from "./Reference.js";
18
10
  export * from "./SourceFile.js";
19
- export * from "./UsingDirective.js";
20
- export * from "./var/declaration.js";
21
- export {};
11
+ export * from "./UsingDirective.js";
@@ -1,10 +1,10 @@
1
1
  import * as core from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
- export declare const ClassDeclaration: core.StcSignature<base.ClassDeclarationProps>;
3
+ export declare const Class: core.StcSignature<base.ClassProps>;
4
4
  export declare const ClassConstructor: core.StcSignature<base.ClassConstructorProps>;
5
5
  export declare const ClassMember: core.StcSignature<base.ClassMemberProps>;
6
6
  export declare const ClassMethod: core.StcSignature<base.ClassMethodProps>;
7
- export declare const EnumDeclaration: core.StcSignature<base.EnumDeclarationProps>;
7
+ export declare const Enum: core.StcSignature<base.EnumProps>;
8
8
  export declare const EnumMember: core.StcSignature<base.EnumMemberProps>;
9
9
  export declare const Parameter: core.StcSignature<base.ParameterProps>;
10
10
  export declare const Parameters: core.StcSignature<base.ParametersProps>;
@@ -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,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,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"}
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,KAAK,oCAAuB,CAAC;AAC1C,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,IAAI,mCAAsB,CAAC;AACxC,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"}
@@ -1,10 +1,10 @@
1
1
  import * as core from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
- export const ClassDeclaration = core.stc(base.ClassDeclaration);
3
+ export const Class = core.stc(base.Class);
4
4
  export const ClassConstructor = core.stc(base.ClassConstructor);
5
5
  export const ClassMember = core.stc(base.ClassMember);
6
6
  export const ClassMethod = core.stc(base.ClassMethod);
7
- export const EnumDeclaration = core.stc(base.EnumDeclaration);
7
+ export const Enum = core.stc(base.Enum);
8
8
  export const EnumMember = core.stc(base.EnumMember);
9
9
  export const Parameter = core.stc(base.Parameter);
10
10
  export const Parameters = core.stc(base.Parameters);
@@ -6,9 +6,16 @@ export interface AccessModifiers {
6
6
  readonly internal?: boolean;
7
7
  readonly file?: boolean;
8
8
  }
9
- export declare const getAccessModifier: (data: AccessModifiers) => string;
9
+ export declare function getAccessModifier(data: AccessModifiers): string;
10
+ /** Method modifiers. Can only be one. */
11
+ export interface MethodModifiers {
12
+ readonly abstract?: boolean;
13
+ readonly sealed?: boolean;
14
+ readonly static?: boolean;
15
+ readonly virtual?: boolean;
16
+ }
17
+ export declare function getMethodModifier(data: MethodModifiers): string;
10
18
  export declare function getAsyncModifier(async?: boolean): string;
11
19
  /** Resolve the modifier prefix */
12
20
  export declare function computeModifiersPrefix(modifiers: Array<string | undefined>): string;
13
- export declare function makeModifiers<T>(obj: Array<keyof T>): (data: T) => string;
14
21
  //# sourceMappingURL=modifiers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../src/modifiers.ts"],"names":[],"mappings":"AAGA,yBAAyB;AACzB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,mCAM5B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAExD;AAED,kCAAkC;AAClC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACnC,MAAM,CAGR;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAC1C,MAAM,CAAC,YAMhB"}
1
+ {"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../src/modifiers.ts"],"names":[],"mappings":"AAGA,yBAAyB;AACzB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAU/D;AAED,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAS/D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAExD;AAED,kCAAkC;AAClC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACnC,MAAM,CAGR"}
@@ -3,7 +3,15 @@
3
3
 
4
4
  /** Access modifiers. */
5
5
 
6
- export const getAccessModifier = makeModifiers(["public", "protected", "private", "internal", "file"]);
6
+ export function getAccessModifier(data) {
7
+ return [data.public && "public", data.protected && "protected", data.private && "private", data.internal && "internal", data.file && "file"].filter(x => x).join(" ");
8
+ }
9
+
10
+ /** Method modifiers. Can only be one. */
11
+
12
+ export function getMethodModifier(data) {
13
+ return [data.abstract && "abstract", data.sealed && "sealed", data.static && "static", data.virtual && "virtual"].filter(x => x).join(" ");
14
+ }
7
15
  export function getAsyncModifier(async) {
8
16
  return async ? "async" : "";
9
17
  }
@@ -12,9 +20,4 @@ export function getAsyncModifier(async) {
12
20
  export function computeModifiersPrefix(modifiers) {
13
21
  const resolved = modifiers.filter(x => x);
14
22
  return resolved.length > 0 ? resolved.join(" ") + " " : "";
15
- }
16
- export function makeModifiers(obj) {
17
- return data => {
18
- return obj.map(key => data[key] ? key : undefined).filter(x => x).join(" ");
19
- };
20
23
  }
@@ -1,5 +1,5 @@
1
1
  import * as core from "@alloy-js/core";
2
- export type CSharpElements = "class" | "constant" | "variable" | "enum" | "enum-member" | "function" | "interface" | "record" | "class-member-private" | "class-member-public" | "class-method" | "class-property" | "parameter" | "type-parameter";
2
+ export type CSharpElements = "class" | "constant" | "enum" | "enum-member" | "function" | "interface" | "class-member-private" | "class-member-public" | "class-method" | "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,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"}
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,WAAW,GACX,gBAAgB,CAAC;AAGrB,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAiBxE;AAGD,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAErE"}
@@ -11,11 +11,9 @@ export function createCSharpNamePolicy() {
11
11
  case "enum":
12
12
  case "enum-member":
13
13
  case "interface":
14
- case "record":
15
14
  case "class-member-public":
16
15
  case "class-method":
17
16
  case "type-parameter":
18
- case "class-property":
19
17
  return changecase.pascalCase(name);
20
18
  case "constant":
21
19
  return changecase.constantCase(name);
@@ -1,10 +1,10 @@
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
- import { ClassDeclaration, ClassMethod } from "../src/index.js";
3
+ import { Class, ClassMethod } from "../src/index.js";
4
4
  import { TestNamespace } from "./utils.js";
5
5
  const Wrapper = props => _$createComponent(TestNamespace, {
6
6
  get children() {
7
- return _$createComponent(ClassDeclaration, {
7
+ return _$createComponent(Class, {
8
8
  "public": true,
9
9
  name: "TestClass",
10
10
  get children() {
@@ -137,25 +137,4 @@ it("defines params and return type", () => {
137
137
  public string MethodOne(int intParam, string stringParam) {}
138
138
  }
139
139
  `);
140
- });
141
- it("specify doc comment", () => {
142
- expect(_$createComponent(TestNamespace, {
143
- get children() {
144
- return _$createComponent(ClassDeclaration, {
145
- name: "Test",
146
- get children() {
147
- return _$createComponent(ClassMethod, {
148
- name: "Method",
149
- doc: "This is a test"
150
- });
151
- }
152
- });
153
- }
154
- })).toRenderTo(`
155
- class Test
156
- {
157
- /// This is a test
158
- void Method() {}
159
- }
160
- `);
161
140
  });