@alloy-js/csharp 0.18.0-dev.2 → 0.18.0-dev.20

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 (153) hide show
  1. package/LICENSE +7 -0
  2. package/dist/src/components/ClassDeclaration.d.ts +74 -0
  3. package/dist/src/components/ClassDeclaration.d.ts.map +1 -0
  4. package/dist/src/components/{Class.js → ClassDeclaration.js} +59 -32
  5. package/dist/src/components/ClassMethod.d.ts +25 -4
  6. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  7. package/dist/src/components/ClassMethod.js +22 -3
  8. package/dist/src/components/EnumDeclaration.d.ts +34 -0
  9. package/dist/src/components/EnumDeclaration.d.ts.map +1 -0
  10. package/dist/src/components/{Enum.js → EnumDeclaration.js} +25 -5
  11. package/dist/src/components/Parameters.d.ts +6 -1
  12. package/dist/src/components/Parameters.d.ts.map +1 -1
  13. package/dist/src/components/Parameters.js +3 -2
  14. package/dist/src/components/doc/comment.d.ts +70 -0
  15. package/dist/src/components/doc/comment.d.ts.map +1 -0
  16. package/dist/src/components/doc/comment.js +88 -0
  17. package/dist/src/components/doc/comment.test.d.ts +2 -0
  18. package/dist/src/components/doc/comment.test.d.ts.map +1 -0
  19. package/dist/src/components/doc/comment.test.js +348 -0
  20. package/dist/src/components/doc/from-markdown.d.ts +6 -0
  21. package/dist/src/components/doc/from-markdown.d.ts.map +1 -0
  22. package/dist/src/components/doc/from-markdown.js +58 -0
  23. package/dist/src/components/doc/from-markdown.test.d.ts +2 -0
  24. package/dist/src/components/doc/from-markdown.test.d.ts.map +1 -0
  25. package/dist/src/components/doc/from-markdown.test.js +83 -0
  26. package/dist/src/components/index.d.ts +12 -3
  27. package/dist/src/components/index.d.ts.map +1 -1
  28. package/dist/src/components/index.js +13 -4
  29. package/dist/src/components/interface/declaration.d.ts +47 -0
  30. package/dist/src/components/interface/declaration.d.ts.map +1 -0
  31. package/dist/src/components/interface/declaration.js +77 -0
  32. package/dist/src/components/interface/declaration.test.d.ts +2 -0
  33. package/dist/src/components/interface/declaration.test.d.ts.map +1 -0
  34. package/dist/src/components/interface/declaration.test.js +153 -0
  35. package/dist/src/components/interface/method.d.ts +32 -0
  36. package/dist/src/components/interface/method.d.ts.map +1 -0
  37. package/dist/src/components/interface/method.js +69 -0
  38. package/dist/src/components/interface/method.test.d.ts +2 -0
  39. package/dist/src/components/interface/method.test.d.ts.map +1 -0
  40. package/dist/src/components/interface/method.test.js +254 -0
  41. package/dist/src/components/interface/property.d.ts +38 -0
  42. package/dist/src/components/interface/property.d.ts.map +1 -0
  43. package/dist/src/components/interface/property.js +67 -0
  44. package/dist/src/components/interface/property.test.d.ts +2 -0
  45. package/dist/src/components/interface/property.test.d.ts.map +1 -0
  46. package/dist/src/components/interface/property.test.js +165 -0
  47. package/dist/src/components/property/property.d.ts +57 -0
  48. package/dist/src/components/property/property.d.ts.map +1 -0
  49. package/dist/src/components/property/property.js +70 -0
  50. package/dist/src/components/property/property.test.d.ts +2 -0
  51. package/dist/src/components/property/property.test.d.ts.map +1 -0
  52. package/dist/src/components/property/property.test.js +218 -0
  53. package/dist/src/components/record/declaration.d.ts +35 -0
  54. package/dist/src/components/record/declaration.d.ts.map +1 -0
  55. package/dist/src/components/record/declaration.js +90 -0
  56. package/dist/src/components/record/declaration.test.d.ts +2 -0
  57. package/dist/src/components/record/declaration.test.d.ts.map +1 -0
  58. package/dist/src/components/record/declaration.test.js +94 -0
  59. package/dist/src/components/stc/index.d.ts +2 -2
  60. package/dist/src/components/stc/index.d.ts.map +1 -1
  61. package/dist/src/components/stc/index.js +2 -2
  62. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +8 -0
  63. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +1 -0
  64. package/dist/src/components/type-parameters/type-parameter-constraints.js +44 -0
  65. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +2 -0
  66. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +1 -0
  67. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +67 -0
  68. package/dist/src/components/type-parameters/type-parameter.d.ts +20 -0
  69. package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -0
  70. package/dist/src/components/type-parameters/type-parameter.js +22 -0
  71. package/dist/src/components/type-parameters/type-parameters.d.ts +17 -0
  72. package/dist/src/components/type-parameters/type-parameters.d.ts.map +1 -0
  73. package/dist/src/components/type-parameters/type-parameters.js +54 -0
  74. package/dist/src/components/type-parameters/type-parameters.test.d.ts +2 -0
  75. package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +1 -0
  76. package/dist/src/components/type-parameters/type-parameters.test.js +48 -0
  77. package/dist/src/components/var/declaration.d.ts +35 -0
  78. package/dist/src/components/var/declaration.d.ts.map +1 -0
  79. package/dist/src/components/var/declaration.js +40 -0
  80. package/dist/src/components/var/declaration.test.d.ts +2 -0
  81. package/dist/src/components/var/declaration.test.d.ts.map +1 -0
  82. package/dist/src/components/var/declaration.test.js +73 -0
  83. package/dist/src/modifiers.d.ts +10 -4
  84. package/dist/src/modifiers.d.ts.map +1 -1
  85. package/dist/src/modifiers.js +9 -32
  86. package/dist/src/name-policy.d.ts +1 -1
  87. package/dist/src/name-policy.d.ts.map +1 -1
  88. package/dist/src/name-policy.js +2 -0
  89. package/dist/test/class-declaration.test.d.ts +2 -0
  90. package/dist/test/class-declaration.test.d.ts.map +1 -0
  91. package/dist/test/class-declaration.test.js +463 -0
  92. package/dist/test/class-method.test.js +37 -14
  93. package/dist/test/enum.test.js +12 -12
  94. package/dist/test/namespace.test.js +8 -8
  95. package/dist/test/project-directory.test.d.ts +2 -0
  96. package/dist/test/project-directory.test.d.ts.map +1 -0
  97. package/dist/test/{projectdirectory.test.js → project-directory.test.js} +8 -8
  98. package/dist/test/sourcefile.test.js +4 -4
  99. package/dist/test/using.test.js +9 -9
  100. package/dist/test/vitest.setup.d.ts +2 -0
  101. package/dist/test/vitest.setup.d.ts.map +1 -0
  102. package/dist/test/vitest.setup.js +1 -0
  103. package/dist/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +21 -21
  105. package/src/components/{Class.tsx → ClassDeclaration.tsx} +108 -43
  106. package/src/components/ClassMethod.tsx +53 -12
  107. package/src/components/{Enum.tsx → EnumDeclaration.tsx} +30 -6
  108. package/src/components/Parameters.tsx +10 -3
  109. package/src/components/doc/comment.test.tsx +337 -0
  110. package/src/components/doc/comment.tsx +152 -0
  111. package/src/components/doc/from-markdown.test.tsx +103 -0
  112. package/src/components/doc/from-markdown.tsx +58 -0
  113. package/src/components/index.ts +12 -3
  114. package/src/components/interface/declaration.test.tsx +143 -0
  115. package/src/components/interface/declaration.tsx +105 -0
  116. package/src/components/interface/method.test.tsx +250 -0
  117. package/src/components/interface/method.tsx +105 -0
  118. package/src/components/interface/property.test.tsx +144 -0
  119. package/src/components/interface/property.tsx +107 -0
  120. package/src/components/property/property.test.tsx +187 -0
  121. package/src/components/property/property.tsx +146 -0
  122. package/src/components/record/declaration.test.tsx +73 -0
  123. package/src/components/record/declaration.tsx +109 -0
  124. package/src/components/stc/index.ts +2 -2
  125. package/src/components/type-parameters/type-parameter-constraints.test.tsx +93 -0
  126. package/src/components/type-parameters/type-parameter-constraints.tsx +46 -0
  127. package/src/components/type-parameters/type-parameter.tsx +35 -0
  128. package/src/components/type-parameters/type-parameters.test.tsx +46 -0
  129. package/src/components/type-parameters/type-parameters.tsx +63 -0
  130. package/src/components/var/declaration.test.tsx +59 -0
  131. package/src/components/var/declaration.tsx +47 -0
  132. package/src/modifiers.ts +25 -42
  133. package/src/name-policy.ts +5 -0
  134. package/temp/api.json +5227 -685
  135. package/test/class-declaration.test.tsx +418 -0
  136. package/test/class-method.test.tsx +24 -14
  137. package/test/enum.test.tsx +11 -11
  138. package/test/namespace.test.tsx +4 -4
  139. package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +4 -4
  140. package/test/sourcefile.test.tsx +2 -2
  141. package/test/using.test.tsx +9 -9
  142. package/test/vitest.setup.ts +1 -0
  143. package/vitest.config.ts +3 -0
  144. package/dist/src/components/Class.d.ts +0 -26
  145. package/dist/src/components/Class.d.ts.map +0 -1
  146. package/dist/src/components/Enum.d.ts +0 -15
  147. package/dist/src/components/Enum.d.ts.map +0 -1
  148. package/dist/test/class.test.d.ts +0 -2
  149. package/dist/test/class.test.d.ts.map +0 -1
  150. package/dist/test/class.test.js +0 -298
  151. package/dist/test/projectdirectory.test.d.ts +0 -2
  152. package/dist/test/projectdirectory.test.d.ts.map +0 -1
  153. package/test/class.test.tsx +0 -292
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2024 Microsoft
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,74 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifiers } from "../modifiers.js";
3
+ import { ParameterProps } from "./Parameters.jsx";
4
+ import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
5
+ export interface ClassModifiers {
6
+ readonly abstract?: boolean;
7
+ readonly partial?: boolean;
8
+ readonly sealed?: boolean;
9
+ readonly static?: boolean;
10
+ }
11
+ export interface ClassDeclarationProps extends Omit<core.DeclarationProps, "nameKind">, AccessModifiers, ClassModifiers {
12
+ name: string;
13
+ /** Doc comment */
14
+ doc?: core.Children;
15
+ refkey?: core.Refkey;
16
+ /**
17
+ * Type parameters for the class
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <ClassDeclaration name="MyClass" typeParameters={["T"]} />
22
+ * ```
23
+ * This will produce:
24
+ * ```csharp
25
+ * public class MyClass<T>
26
+ * ```
27
+ */
28
+ typeParameters?: (string | TypeParameterProps)[];
29
+ /** Base class that this class extends */
30
+ baseType?: core.Children;
31
+ /** Interfaces this class implements */
32
+ interfaceTypes?: core.Children[];
33
+ }
34
+ /**
35
+ * CSharp class declaration.
36
+ * @example
37
+ * ```tsx
38
+ * <ClassDeclaration public name="MyClass">
39
+ * <ClassMember public name="MyField" type="int" />
40
+ * <ClassConstructor>
41
+ * <Parameter name="value" type="int" />
42
+ * this.MyField = value;
43
+ * </ClassConstructor>
44
+ * </ClassDeclaration>
45
+ * ```
46
+ * This will produce:
47
+ * ```csharp
48
+ * public class MyClass
49
+ * {
50
+ * public int MyField;
51
+ * public MyClass(int value)
52
+ * {
53
+ * this.MyField = value;
54
+ * }
55
+ * }
56
+ * ```
57
+ */
58
+ export declare function ClassDeclaration(props: ClassDeclarationProps): core.Children;
59
+ export interface ClassConstructorProps extends AccessModifiers {
60
+ parameters?: Array<ParameterProps>;
61
+ refkey?: core.Refkey;
62
+ symbol?: core.OutputSymbol;
63
+ children?: core.Children;
64
+ }
65
+ export declare function ClassConstructor(props: ClassConstructorProps): core.Children;
66
+ export interface ClassMemberProps extends AccessModifiers {
67
+ name: string;
68
+ type: core.Children;
69
+ refkey?: core.Refkey;
70
+ /** Doc comment */
71
+ doc?: core.Children;
72
+ }
73
+ export declare function ClassMember(props: ClassMemberProps): core.Children;
74
+ //# sourceMappingURL=ClassDeclaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassDeclaration.d.ts","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AE,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;IACrB,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CACrB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBA0BlD"}
@@ -1,16 +1,44 @@
1
- import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, 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 { getAccessModifier } from "../modifiers.js";
3
+ import { join } from "@alloy-js/core";
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";
6
7
  import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
7
8
  import { Name } from "./Name.js";
8
9
  import { Parameters } from "./Parameters.js";
10
+ import { DocWhen } from "./doc/comment.js";
11
+ import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
12
+ import { TypeParameters } from "./type-parameters/type-parameters.js";
13
+ const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
9
14
 
10
15
  // properties for creating a class
11
16
 
12
- // a C# class declaration
13
- export function Class(props) {
17
+ /**
18
+ * CSharp class declaration.
19
+ * @example
20
+ * ```tsx
21
+ * <ClassDeclaration public name="MyClass">
22
+ * <ClassMember public name="MyField" type="int" />
23
+ * <ClassConstructor>
24
+ * <Parameter name="value" type="int" />
25
+ * this.MyField = value;
26
+ * </ClassConstructor>
27
+ * </ClassDeclaration>
28
+ * ```
29
+ * This will produce:
30
+ * ```csharp
31
+ * public class MyClass
32
+ * {
33
+ * public int MyField;
34
+ * public MyClass(int value)
35
+ * {
36
+ * this.MyField = value;
37
+ * }
38
+ * }
39
+ * ```
40
+ */
41
+ export function ClassDeclaration(props) {
14
42
  const name = useCSharpNamePolicy().getName(props.name, "class");
15
43
  const thisClassSymbol = new CSharpOutputSymbol(name, {
16
44
  refkeys: props.refkey
@@ -23,33 +51,27 @@ export function Class(props) {
23
51
  const thisClassScope = new CSharpMemberScope("class-decl", {
24
52
  owner: thisClassSymbol
25
53
  });
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
- }
54
+ const bases = [...(props.baseType ? [props.baseType] : []), ...(props.interfaceTypes || [])];
55
+ const base = bases.length > 0 ? [" : ", _$memo(() => join(bases, {
56
+ joiner: ", "
57
+ }))] : null;
58
+ const modifiers = computeModifiersPrefix([getAccessModifier(props), getClassModifiers(props)]);
49
59
  return _$createComponent(core.Declaration, {
50
60
  symbol: thisClassSymbol,
51
61
  get children() {
52
- return [_$memo(() => getAccessModifier(props.accessModifier)), "class ", _$createComponent(Name, {}), typeParams, _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
62
+ return [_$createComponent(DocWhen, {
63
+ get doc() {
64
+ return props.doc;
65
+ }
66
+ }), modifiers, "class ", _$createComponent(Name, {}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
67
+ get parameters() {
68
+ return props.typeParameters;
69
+ }
70
+ })), base, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
71
+ get parameters() {
72
+ return props.typeParameters;
73
+ }
74
+ })), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
53
75
  newline: true,
54
76
  get children() {
55
77
  return _$createComponent(core.Scope, {
@@ -81,7 +103,7 @@ export function ClassConstructor(props) {
81
103
  const ctorDeclScope = new CSharpMemberScope("constructor-decl", {
82
104
  owner: ctorSymbol
83
105
  });
84
- const accessModifier = getAccessModifier(props.accessModifier);
106
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
85
107
  const params = props.parameters ? _$createComponent(Parameters, {
86
108
  get parameters() {
87
109
  return props.parameters;
@@ -95,7 +117,7 @@ export function ClassConstructor(props) {
95
117
  return _$createComponent(core.Scope, {
96
118
  value: ctorDeclScope,
97
119
  get children() {
98
- return [accessModifier, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
120
+ return [modifiers, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
99
121
  newline: true,
100
122
  get children() {
101
123
  return props.children;
@@ -112,7 +134,7 @@ export function ClassConstructor(props) {
112
134
  // a C# class member (i.e. a field within a class like "private int count")
113
135
  export function ClassMember(props) {
114
136
  let nameElement = "class-member-private";
115
- if (props.accessModifier === "public") {
137
+ if (props.public) {
116
138
  nameElement = "class-member-public";
117
139
  }
118
140
  const name = useCSharpNamePolicy().getName(props.name, nameElement);
@@ -124,10 +146,15 @@ export function ClassMember(props) {
124
146
  scope,
125
147
  refkeys: props.refkey ?? core.refkey(props.name)
126
148
  });
149
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
127
150
  return _$createComponent(core.Declaration, {
128
151
  symbol: memberSymbol,
129
152
  get children() {
130
- return [_$memo(() => getAccessModifier(props.accessModifier)), _$memo(() => props.type), " ", _$createComponent(Name, {})];
153
+ return [_$createComponent(DocWhen, {
154
+ get doc() {
155
+ return props.doc;
156
+ }
157
+ }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
131
158
  }
132
159
  });
133
160
  }
@@ -1,18 +1,39 @@
1
1
  import { Children, Refkey } from "@alloy-js/core";
2
- import { AccessModifier, MethodModifier } from "../modifiers.js";
2
+ import { AccessModifiers } from "../modifiers.js";
3
3
  import { ParameterProps } from "./Parameters.jsx";
4
- export interface ClassMethodProps {
4
+ import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
5
+ /** Method modifiers. Can only be one. */
6
+ export interface ClassMethodModifiers {
7
+ readonly abstract?: boolean;
8
+ readonly sealed?: boolean;
9
+ readonly static?: boolean;
10
+ readonly virtual?: boolean;
11
+ }
12
+ export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers {
5
13
  name: string;
6
14
  refkey?: Refkey;
7
15
  children?: Children;
8
- accessModifier?: AccessModifier;
9
- methodModifier?: MethodModifier;
10
16
  parameters?: Array<ParameterProps>;
11
17
  returns?: Children;
12
18
  /**
13
19
  * If true, the method will be declared as an async method.
14
20
  */
15
21
  async?: boolean;
22
+ /** Doc comment */
23
+ doc?: Children;
24
+ /**
25
+ * Type parameters for the method
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * <InterfaceMethod name="Test" typeParameters={["T"]} />
30
+ * ```
31
+ * This will produce:
32
+ * ```csharp
33
+ * public void Test<T>()
34
+ * ```
35
+ */
36
+ typeParameters?: (TypeParameterProps | string)[];
16
37
  }
17
38
  export declare function ClassMethod(props: ClassMethodProps): Children;
18
39
  //# 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,QAA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;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;CAClD;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YA4ClD"}
@@ -1,10 +1,17 @@
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, getMethodModifier } from "../modifiers.js";
3
+ import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, makeModifiers } 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
7
  import { Parameters } from "./Parameters.js";
8
+ import { DocWhen } from "./doc/comment.js";
9
+ import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
10
+ import { TypeParameters } from "./type-parameters/type-parameters.js";
11
+
12
+ /** Method modifiers. Can only be one. */
13
+
14
+ const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
8
15
 
9
16
  // properties for creating a method
10
17
 
@@ -30,7 +37,7 @@ export function ClassMethod(props) {
30
37
  }
31
38
  }) : "";
32
39
  const returns = props.returns ?? (props.async ? "Task" : "void");
33
- const modifiers = computeModifiersPrefix([getAccessModifier(props.accessModifier), getMethodModifier(props.methodModifier), getAsyncModifier(props.async)]);
40
+ const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
34
41
  // note that scope wraps the method decl so that the params get the correct scope
35
42
  return _$createComponent(MemberDeclaration, {
36
43
  symbol: methodSymbol,
@@ -38,7 +45,19 @@ export function ClassMethod(props) {
38
45
  return _$createComponent(Scope, {
39
46
  value: methodScope,
40
47
  get children() {
41
- return [modifiers, returns, " ", name, "(", params, ")", _$memo(() => _$memo(() => props.methodModifier === "abstract")() ? ";" : _$createComponent(Block, {
48
+ return [_$createComponent(DocWhen, {
49
+ get doc() {
50
+ return props.doc;
51
+ }
52
+ }), modifiers, returns, " ", name, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
53
+ get parameters() {
54
+ return props.typeParameters;
55
+ }
56
+ })), "(", params, ")", _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
57
+ get parameters() {
58
+ return props.typeParameters;
59
+ }
60
+ })), _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
42
61
  newline: true,
43
62
  get children() {
44
63
  return props.children;
@@ -0,0 +1,34 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifiers } from "../modifiers.js";
3
+ export interface EnumDeclarationProps extends AccessModifiers {
4
+ name: string;
5
+ refkey?: core.Refkey;
6
+ children?: core.Children;
7
+ }
8
+ /**
9
+ * A C# enum declaration
10
+ * @example
11
+ * ```tsx
12
+ * <EnumDeclaration public name="Color">
13
+ * <EnumMember name="Red" />
14
+ * <EnumMember name="Green" />
15
+ * <EnumMember name="Blue" />
16
+ * </EnumDeclaration>
17
+ * ```
18
+ * This will produce:
19
+ * ```csharp
20
+ * public enum Color
21
+ * {
22
+ * Red,
23
+ * Green,
24
+ * Blue
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function EnumDeclaration(props: EnumDeclarationProps): core.Children;
29
+ export interface EnumMemberProps {
30
+ name: string;
31
+ refkey?: core.Refkey;
32
+ }
33
+ export declare function EnumMember(props: EnumMemberProps): core.Children;
34
+ //# sourceMappingURL=EnumDeclaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnumDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/EnumDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAOzB,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,iBAgC1D;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"}
@@ -1,6 +1,6 @@
1
- import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
- import { getAccessModifier } from "../modifiers.js";
3
+ import { computeModifiersPrefix, getAccessModifier } 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";
@@ -8,8 +8,27 @@ import { Name } from "./Name.js";
8
8
 
9
9
  // properties for creating an enum
10
10
 
11
- // a C# enum declaration
12
- export function Enum(props) {
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) {
13
32
  const name = useCSharpNamePolicy().getName(props.name, "enum");
14
33
  const scope = useCSharpScope();
15
34
  const thisEnumSymbol = new CSharpOutputSymbol(name, {
@@ -25,10 +44,11 @@ export function Enum(props) {
25
44
  parent: scope,
26
45
  owner: thisEnumSymbol
27
46
  });
47
+ const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
28
48
  if (thisEnumScope.owner) return _$createComponent(core.Declaration, {
29
49
  symbol: thisEnumSymbol,
30
50
  get children() {
31
- return [_$memo(() => getAccessModifier(props.accessModifier)), "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Scope, {
51
+ return [modifiers, "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Scope, {
32
52
  value: thisEnumScope,
33
53
  get children() {
34
54
  return _$createComponent(core.Block, {
@@ -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: Array<ParameterProps>;
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;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"}
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
- // a constructor/method parameter
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
  }
@@ -0,0 +1,70 @@
1
+ import { Children } from "@alloy-js/core";
2
+ export interface DocCommentProps {
3
+ children: Children;
4
+ }
5
+ export declare function DocComment(props: DocCommentProps): Children;
6
+ export interface DocWhenProps {
7
+ doc: Children | undefined;
8
+ }
9
+ /** Conditionally render the given doc in a <DocComment /> component and tail with a line */
10
+ export declare function DocWhen(props: DocWhenProps): Children;
11
+ export interface DocCommentTagProps {
12
+ children: Children;
13
+ }
14
+ export declare function makeDocCommentTag(name: string): (props: DocCommentProps) => Children;
15
+ export declare function makeInlineDocCommentTag(name: string): (props: DocCommentProps) => string;
16
+ export declare const DocSummary: (props: DocCommentProps) => Children;
17
+ export declare const DocCode: (props: DocCommentProps) => Children;
18
+ export declare const DocC: (props: DocCommentProps) => string;
19
+ export declare const DocExample: (props: DocCommentProps) => Children;
20
+ export declare const DocException: (props: DocCommentProps) => Children;
21
+ export interface DocIncludeProps {
22
+ /** is the file name of an external XML file. The file name is interpreted relative to the file that contains the include tag. */
23
+ file: string;
24
+ /** is an XPath expression that selects some of the XML in the external XML file. */
25
+ path?: string;
26
+ }
27
+ export declare const DocInclude: (props: DocIncludeProps) => string;
28
+ export interface DocParamProps {
29
+ name: string;
30
+ children: Children;
31
+ }
32
+ export declare const DocParam: (props: DocParamProps) => Children;
33
+ export interface DocTypeParamProps {
34
+ name: string;
35
+ children: Children;
36
+ }
37
+ export declare const DocTypeParam: (props: DocTypeParamProps) => Children;
38
+ export declare const DocReturns: (props: DocCommentProps) => Children;
39
+ export declare const DocRemarks: (props: DocCommentProps) => Children;
40
+ export declare const DocValue: (props: DocCommentProps) => Children;
41
+ export declare const DocPermission: (props: DocCommentProps) => Children;
42
+ export declare const DocDescription: (props: DocCommentProps) => Children;
43
+ export declare const DocPara: (props: DocCommentProps) => Children;
44
+ export interface DocSeeProps {
45
+ cref?: string;
46
+ href?: string;
47
+ langword?: string;
48
+ children?: Children;
49
+ }
50
+ export declare const DocSee: (props: DocSeeProps) => Children;
51
+ export interface DocSeeAlsoProps {
52
+ cref?: string;
53
+ href?: string;
54
+ children?: Children;
55
+ }
56
+ export declare const DocSeeAlso: (props: DocSeeAlsoProps) => Children;
57
+ export interface DocParamRefProps {
58
+ name: string;
59
+ }
60
+ export declare const DocParamRef: (props: DocParamRefProps) => string;
61
+ export interface DocTypeParamRefProps {
62
+ name: string;
63
+ }
64
+ export declare const DocTypeParamRef: (props: DocTypeParamRefProps) => string;
65
+ export interface DocListProps {
66
+ type?: "bullet" | "number";
67
+ items: Children[];
68
+ }
69
+ export declare function DocList(props: DocListProps): Children;
70
+ //# sourceMappingURL=comment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwC,MAAM,gBAAgB,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAShD;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;C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cAAc,UAnDY,eAAe,aAmDQ,CAAC;AAC/D,eAAO,MAAM,OAAO,UApDmB,eAAe,aAoDN,CAAC;AAEjD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AACD,eAAO,MAAM,MAAM,GAAI,OAAO,WAAW,aASxC,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AACD,eAAO,MAAM,UAAU,GAAI,OAAO,eAAe,aAQhD,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AACD,eAAO,MAAM,WAAW,GAAI,OAAO,gBAAgB,WACd,CAAC;AAEtC,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AACD,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,WAClB,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,YAa1C"}
@@ -0,0 +1,88 @@
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { code, For, Indent, List, Prose, Show } from "@alloy-js/core";
3
+ export function DocComment(props) {
4
+ return ["/// ", _$createIntrinsic("align", {
5
+ string: "/// ",
6
+ get children() {
7
+ return _$createComponent(List, {
8
+ get children() {
9
+ return props.children;
10
+ }
11
+ });
12
+ }
13
+ })];
14
+ }
15
+ /** Conditionally render the given doc in a <DocComment /> component and tail with a line */
16
+ export function DocWhen(props) {
17
+ return _$createComponent(Show, {
18
+ get when() {
19
+ return Boolean(props.doc);
20
+ },
21
+ get children() {
22
+ return [_$createComponent(DocComment, {
23
+ get children() {
24
+ return props.doc;
25
+ }
26
+ }), _$createIntrinsic("hbr", {})];
27
+ }
28
+ });
29
+ }
30
+ export function makeDocCommentTag(name) {
31
+ return function DocCommentTag(props) {
32
+ return _$createComponent(Prose, {
33
+ get children() {
34
+ return code`
35
+ <${name}>
36
+ ${props.children}
37
+ </${name}>`;
38
+ }
39
+ });
40
+ };
41
+ }
42
+ export function makeInlineDocCommentTag(name) {
43
+ return function DocCommentTag(props) {
44
+ return `<${name}>${props.children}</${name}>`;
45
+ };
46
+ }
47
+ export const DocSummary = makeDocCommentTag("summary");
48
+ export const DocCode = makeDocCommentTag("code");
49
+ export const DocC = makeInlineDocCommentTag("c");
50
+ export const DocExample = makeDocCommentTag("example");
51
+ export const DocException = makeDocCommentTag("exception");
52
+ export const DocInclude = props => {
53
+ return `<include file="${props.file}" path="${props.path}" />`;
54
+ };
55
+ export const DocParam = props => code`<param name="${props.name}">${props.children}</param>`;
56
+ export const DocTypeParam = props => code`<typeparam name="${props.name}">${props.children}</typeparam>`;
57
+ export const DocReturns = makeDocCommentTag("returns");
58
+ export const DocRemarks = makeDocCommentTag("remarks");
59
+ export const DocValue = makeDocCommentTag("value");
60
+ export const DocPermission = makeDocCommentTag("permission");
61
+ export const DocDescription = makeDocCommentTag("description");
62
+ export const DocPara = makeDocCommentTag("para");
63
+ export const DocSee = props => {
64
+ const attributes = [props.cref ? `cref="${props.cref}"` : undefined, props.href ? `href="${props.href}"` : undefined, props.langword ? `langword="${props.langword}"` : undefined].filter(Boolean).join(" ");
65
+ return code`<see ${attributes}${props.children ? code`>${props.children}</see>` : " />"}`;
66
+ };
67
+ export const DocSeeAlso = props => {
68
+ const attributes = [props.cref ? `cref="${props.cref}"` : undefined, props.href ? `href="${props.href}"` : undefined].filter(Boolean).join(" ");
69
+ return code`<seealso ${attributes}${props.children ? code`>${props.children}</seealso>` : " />"}`;
70
+ };
71
+ export const DocParamRef = props => `<paramref name="${props.name}" />`;
72
+ export const DocTypeParamRef = props => `<typeparamref name="${props.name}" />`;
73
+ export function DocList(props) {
74
+ return _$createComponent(Prose, {
75
+ get children() {
76
+ return [_$memo(() => `<list type="${props.type ?? "bullet"}">`), _$createComponent(Indent, {
77
+ get children() {
78
+ return _$createComponent(For, {
79
+ get each() {
80
+ return props.items;
81
+ },
82
+ children: item => code`<item><description>${item}</description></item>`
83
+ });
84
+ }
85
+ }), _$createIntrinsic("hbr", {}), `</list>`];
86
+ }
87
+ });
88
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=comment.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment.test.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.test.tsx"],"names":[],"mappings":""}