@alloy-js/csharp 0.18.0-dev.8 → 0.18.0

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 (127) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/src/components/ClassDeclaration.d.ts +39 -2
  3. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  4. package/dist/src/components/ClassDeclaration.js +35 -34
  5. package/dist/src/components/ClassMethod.d.ts +33 -1
  6. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  7. package/dist/src/components/ClassMethod.js +22 -7
  8. package/dist/src/components/SourceFile.d.ts.map +1 -1
  9. package/dist/src/components/SourceFile.js +1 -0
  10. package/dist/src/components/attributes/attributes.d.ts +39 -0
  11. package/dist/src/components/attributes/attributes.d.ts.map +1 -0
  12. package/dist/src/components/attributes/attributes.js +62 -0
  13. package/dist/src/components/attributes/attributes.test.d.ts +2 -0
  14. package/dist/src/components/attributes/attributes.test.d.ts.map +1 -0
  15. package/dist/src/components/attributes/attributes.test.js +75 -0
  16. package/dist/src/components/doc/comment.d.ts +12 -11
  17. package/dist/src/components/doc/comment.d.ts.map +1 -1
  18. package/dist/src/components/doc/comment.js +27 -10
  19. package/dist/src/components/doc/comment.test.js +98 -88
  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 +9 -1
  27. package/dist/src/components/index.d.ts.map +1 -1
  28. package/dist/src/components/index.js +10 -2
  29. package/dist/src/components/interface/declaration.d.ts +32 -1
  30. package/dist/src/components/interface/declaration.d.ts.map +1 -1
  31. package/dist/src/components/interface/declaration.js +18 -25
  32. package/dist/src/components/interface/declaration.test.js +102 -0
  33. package/dist/src/components/interface/method.d.ts +33 -1
  34. package/dist/src/components/interface/method.d.ts.map +1 -1
  35. package/dist/src/components/interface/method.js +22 -7
  36. package/dist/src/components/interface/method.test.js +169 -0
  37. package/dist/src/components/interface/property.d.ts +36 -1
  38. package/dist/src/components/interface/property.d.ts.map +1 -1
  39. package/dist/src/components/interface/property.js +18 -4
  40. package/dist/src/components/interface/property.test.js +24 -0
  41. package/dist/src/components/parameters/parameters.d.ts +19 -0
  42. package/dist/src/components/parameters/parameters.d.ts.map +1 -0
  43. package/dist/src/components/parameters/parameters.js +43 -0
  44. package/dist/src/components/property/property.d.ts +80 -0
  45. package/dist/src/components/property/property.d.ts.map +1 -0
  46. package/dist/src/components/property/property.js +76 -0
  47. package/dist/src/components/property/property.test.d.ts +2 -0
  48. package/dist/src/components/property/property.test.d.ts.map +1 -0
  49. package/dist/src/components/property/property.test.js +242 -0
  50. package/dist/src/components/record/declaration.d.ts +35 -0
  51. package/dist/src/components/record/declaration.d.ts.map +1 -0
  52. package/dist/src/components/record/declaration.js +90 -0
  53. package/dist/src/components/record/declaration.test.d.ts +2 -0
  54. package/dist/src/components/record/declaration.test.d.ts.map +1 -0
  55. package/dist/src/components/record/declaration.test.js +94 -0
  56. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +8 -0
  57. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +1 -0
  58. package/dist/src/components/type-parameters/type-parameter-constraints.js +44 -0
  59. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +2 -0
  60. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +1 -0
  61. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +67 -0
  62. package/dist/src/components/type-parameters/type-parameter.d.ts +20 -0
  63. package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -0
  64. package/dist/src/components/type-parameters/type-parameter.js +22 -0
  65. package/dist/src/components/type-parameters/type-parameters.d.ts +17 -0
  66. package/dist/src/components/type-parameters/type-parameters.d.ts.map +1 -0
  67. package/dist/src/components/type-parameters/type-parameters.js +54 -0
  68. package/dist/src/components/type-parameters/type-parameters.test.d.ts +2 -0
  69. package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +1 -0
  70. package/dist/src/components/type-parameters/type-parameters.test.js +48 -0
  71. package/dist/src/components/var/declaration.d.ts +35 -0
  72. package/dist/src/components/var/declaration.d.ts.map +1 -0
  73. package/dist/src/components/var/declaration.js +40 -0
  74. package/dist/src/components/var/declaration.test.d.ts +2 -0
  75. package/dist/src/components/var/declaration.test.d.ts.map +1 -0
  76. package/dist/src/components/var/declaration.test.js +73 -0
  77. package/dist/src/name-policy.d.ts +1 -1
  78. package/dist/src/name-policy.d.ts.map +1 -1
  79. package/dist/src/name-policy.js +1 -0
  80. package/dist/test/class-declaration.test.d.ts +2 -0
  81. package/dist/test/class-declaration.test.d.ts.map +1 -0
  82. package/dist/test/{class.test.js → class-declaration.test.js} +161 -33
  83. package/dist/test/project-directory.test.d.ts +2 -0
  84. package/dist/test/project-directory.test.d.ts.map +1 -0
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +7 -6
  87. package/src/components/ClassDeclaration.tsx +65 -33
  88. package/src/components/ClassMethod.tsx +46 -4
  89. package/src/components/SourceFile.tsx +1 -0
  90. package/src/components/attributes/attributes.test.tsx +61 -0
  91. package/src/components/attributes/attributes.tsx +100 -0
  92. package/src/components/doc/comment.test.tsx +80 -79
  93. package/src/components/doc/comment.tsx +44 -14
  94. package/src/components/doc/from-markdown.test.tsx +103 -0
  95. package/src/components/doc/from-markdown.tsx +58 -0
  96. package/src/components/index.ts +9 -1
  97. package/src/components/interface/declaration.test.tsx +102 -0
  98. package/src/components/interface/declaration.tsx +43 -27
  99. package/src/components/interface/method.test.tsx +173 -0
  100. package/src/components/interface/method.tsx +45 -5
  101. package/src/components/interface/property.test.tsx +21 -0
  102. package/src/components/interface/property.tsx +43 -6
  103. package/src/components/parameters/parameters.tsx +74 -0
  104. package/src/components/property/property.test.tsx +209 -0
  105. package/src/components/property/property.tsx +172 -0
  106. package/src/components/record/declaration.test.tsx +73 -0
  107. package/src/components/record/declaration.tsx +109 -0
  108. package/src/components/type-parameters/type-parameter-constraints.test.tsx +93 -0
  109. package/src/components/type-parameters/type-parameter-constraints.tsx +46 -0
  110. package/src/components/type-parameters/type-parameter.tsx +35 -0
  111. package/src/components/type-parameters/type-parameters.test.tsx +46 -0
  112. package/src/components/type-parameters/type-parameters.tsx +63 -0
  113. package/src/components/var/declaration.test.tsx +59 -0
  114. package/src/components/var/declaration.tsx +47 -0
  115. package/src/name-policy.ts +3 -0
  116. package/temp/api.json +5838 -1626
  117. package/test/{class.test.tsx → class-declaration.test.tsx} +144 -26
  118. package/dist/src/components/Parameters.d.ts +0 -13
  119. package/dist/src/components/Parameters.d.ts.map +0 -1
  120. package/dist/src/components/Parameters.js +0 -34
  121. package/dist/test/class.test.d.ts +0 -2
  122. package/dist/test/class.test.d.ts.map +0 -1
  123. package/dist/test/projectdirectory.test.d.ts +0 -2
  124. package/dist/test/projectdirectory.test.d.ts.map +0 -1
  125. package/src/components/Parameters.tsx +0 -51
  126. /package/dist/test/{projectdirectory.test.js → project-directory.test.js} +0 -0
  127. /package/test/{projectdirectory.test.tsx → project-directory.test.tsx} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog - @alloy-js/csharp
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Bug Fixes
6
+
7
+ - [#205](https://github.com/alloy-framework/alloy/pull/205) Add doc support to class members
8
+ - [#182](https://github.com/alloy-framework/alloy/pull/182) Fix abstract class method rendering with a body `{}`
9
+ - [#201](https://github.com/alloy-framework/alloy/pull/201) Add support for csharp doc comments with various `<Doc*>` components
10
+
11
+ ### Features
12
+
13
+ - [#228](https://github.com/alloy-framework/alloy/pull/228) Add `<Attribute />` and `<AttributeList />` components to support c# attributes
14
+ - [#212](https://github.com/alloy-framework/alloy/pull/212) Add support for class base type(s)
15
+ - [#182](https://github.com/alloy-framework/alloy/pull/182) Add support for `async` class methods
16
+ - [#193](https://github.com/alloy-framework/alloy/pull/193) Add support for class modifiers `abstract`, `partial`, `sealed` and `static`
17
+ - [#209](https://github.com/alloy-framework/alloy/pull/209) Add `<ClassProperty />` component
18
+ - [#227](https://github.com/alloy-framework/alloy/pull/227) CSharp SourceFile use 120 lines split by default
19
+ - [#191](https://github.com/alloy-framework/alloy/pull/191) Access and method modifiers have been converted to flags `<Class public />` instead of `<Class accessModifier="public" />`
20
+ - [#220](https://github.com/alloy-framework/alloy/pull/220) Add `<VarDeclaration />` component to render variables
21
+ - [#198](https://github.com/alloy-framework/alloy/pull/198) Add `<InterfaceDeclaration />`, `<InterfaceMethod />` and `<InterfaceProperty />` components
22
+ - [#213](https://github.com/alloy-framework/alloy/pull/213) Add support for optional parameters
23
+ - [#202](https://github.com/alloy-framework/alloy/pull/202) Add `<DocFromMarkdown>` component allowing conversion from markdown to csharp doc comment syntax
24
+ - [#225](https://github.com/alloy-framework/alloy/pull/225) Parameter improved formatting when using multi lines
25
+ - [#216](https://github.com/alloy-framework/alloy/pull/216) Add support for `init` properties
26
+ - [#215](https://github.com/alloy-framework/alloy/pull/215) Add support for `record` with `<RecordDeclaration>` component
27
+ - [#222](https://github.com/alloy-framework/alloy/pull/222) Support for type parameters for interface, class methods, interface methods
28
+
29
+ ### Breaking Changes
30
+
31
+ - [#192](https://github.com/alloy-framework/alloy/pull/192) Rename `Class` -> `ClassDeclaration` and `Enum` -> `EnumDeclaration`
32
+
33
+
3
34
  ## 0.17.0
4
35
 
5
36
  No changes, version bump only.
@@ -1,6 +1,8 @@
1
1
  import * as core from "@alloy-js/core";
2
2
  import { AccessModifiers } from "../modifiers.js";
3
- import { ParameterProps } from "./Parameters.jsx";
3
+ import { AttributesProp } from "./attributes/attributes.jsx";
4
+ import { ParameterProps } from "./parameters/parameters.jsx";
5
+ import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
4
6
  export interface ClassModifiers {
5
7
  readonly abstract?: boolean;
6
8
  readonly partial?: boolean;
@@ -12,7 +14,40 @@ export interface ClassDeclarationProps extends Omit<core.DeclarationProps, "name
12
14
  /** Doc comment */
13
15
  doc?: core.Children;
14
16
  refkey?: core.Refkey;
15
- typeParameters?: Record<string, core.Refkey>;
17
+ /**
18
+ * Type parameters for the class
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <ClassDeclaration name="MyClass" typeParameters={["T"]} />
23
+ * ```
24
+ * This will produce:
25
+ * ```csharp
26
+ * public class MyClass<T>
27
+ * ```
28
+ */
29
+ typeParameters?: (string | TypeParameterProps)[];
30
+ /** Base class that this class extends */
31
+ baseType?: core.Children;
32
+ /** Interfaces this class implements */
33
+ interfaceTypes?: core.Children[];
34
+ /**
35
+ * Define attributes to attach
36
+ * @example
37
+ * ```tsx
38
+ * <ClassDeclaration name="MyClass" attributes={[
39
+ * <Attribute name="Test" />
40
+ * <Attribute name="Test2" args={["arg1", "arg2"]} />
41
+ * ]}>
42
+ * ```
43
+ * This will produce:
44
+ * ```csharp
45
+ * [Test]
46
+ * [Test2("arg1", "arg2")]
47
+ * public class MyClass
48
+ * ```
49
+ */
50
+ attributes?: AttributesProp;
16
51
  }
17
52
  /**
18
53
  * CSharp class declaration.
@@ -50,6 +85,8 @@ export interface ClassMemberProps extends AccessModifiers {
50
85
  name: string;
51
86
  type: core.Children;
52
87
  refkey?: core.Refkey;
88
+ /** Doc comment */
89
+ doc?: core.Children;
53
90
  }
54
91
  export declare function ClassMember(props: ClassMemberProps): core.Children;
55
92
  //# 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;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,cAAc,EAAc,MA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AAQ,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,iBAiC5D;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,12 +1,16 @@
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 { 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";
6
7
  import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
7
- import { Name } from "./Name.js";
8
- import { Parameters } from "./Parameters.js";
8
+ import { AttributeList } from "./attributes/attributes.js";
9
9
  import { DocWhen } from "./doc/comment.js";
10
+ 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";
10
14
  const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
11
15
 
12
16
  // properties for creating a class
@@ -48,29 +52,10 @@ export function ClassDeclaration(props) {
48
52
  const thisClassScope = new CSharpMemberScope("class-decl", {
49
53
  owner: thisClassSymbol
50
54
  });
51
- let typeParams;
52
- if (props.typeParameters) {
53
- const typeParamNames = new Array();
54
- for (const entry of Object.entries(props.typeParameters)) {
55
- typeParamNames.push(useCSharpNamePolicy().getName(entry[0], "type-parameter"));
56
- // create a symbol for each type param so its
57
- // refkey resolves to the type param's name
58
- new CSharpOutputSymbol(entry[0], {
59
- scope: thisClassScope,
60
- refkeys: entry[1]
61
- });
62
- }
63
- typeParams = _$createIntrinsic("group", {
64
- get children() {
65
- return ["<", _$createComponent(core.For, {
66
- each: typeParamNames,
67
- comma: true,
68
- line: true,
69
- children: name => name
70
- }), ">"];
71
- }
72
- });
73
- }
55
+ const bases = [...(props.baseType ? [props.baseType] : []), ...(props.interfaceTypes || [])];
56
+ const base = bases.length > 0 ? [" : ", _$memo(() => join(bases, {
57
+ joiner: ", "
58
+ }))] : null;
74
59
  const modifiers = computeModifiersPrefix([getAccessModifier(props), getClassModifiers(props)]);
75
60
  return _$createComponent(core.Declaration, {
76
61
  symbol: thisClassSymbol,
@@ -79,7 +64,20 @@ export function ClassDeclaration(props) {
79
64
  get doc() {
80
65
  return props.doc;
81
66
  }
82
- }), modifiers, "class ", _$createComponent(Name, {}), typeParams, _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
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, {
83
81
  newline: true,
84
82
  get children() {
85
83
  return _$createComponent(core.Scope, {
@@ -112,11 +110,6 @@ export function ClassConstructor(props) {
112
110
  owner: ctorSymbol
113
111
  });
114
112
  const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
115
- const params = props.parameters ? _$createComponent(Parameters, {
116
- get parameters() {
117
- return props.parameters;
118
- }
119
- }) : "";
120
113
 
121
114
  // note that scope wraps the ctor decl so that the params get the correct scope
122
115
  return _$createComponent(core.Declaration, {
@@ -125,7 +118,11 @@ export function ClassConstructor(props) {
125
118
  return _$createComponent(core.Scope, {
126
119
  value: ctorDeclScope,
127
120
  get children() {
128
- return [modifiers, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
121
+ return [modifiers, _$createComponent(Name, {}), _$createComponent(Parameters, {
122
+ get parameters() {
123
+ return props.parameters;
124
+ }
125
+ }), _$createComponent(core.Block, {
129
126
  newline: true,
130
127
  get children() {
131
128
  return props.children;
@@ -158,7 +155,11 @@ export function ClassMember(props) {
158
155
  return _$createComponent(core.Declaration, {
159
156
  symbol: memberSymbol,
160
157
  get children() {
161
- return [modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
158
+ return [_$createComponent(DocWhen, {
159
+ get doc() {
160
+ return props.doc;
161
+ }
162
+ }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
162
163
  }
163
164
  });
164
165
  }
@@ -1,6 +1,8 @@
1
1
  import { Children, Refkey } from "@alloy-js/core";
2
2
  import { AccessModifiers } from "../modifiers.js";
3
- import { ParameterProps } from "./Parameters.jsx";
3
+ import { AttributesProp } from "./attributes/attributes.jsx";
4
+ import { ParameterProps } from "./parameters/parameters.jsx";
5
+ import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
4
6
  /** Method modifiers. Can only be one. */
5
7
  export interface ClassMethodModifiers {
6
8
  readonly abstract?: boolean;
@@ -20,6 +22,36 @@ export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers
20
22
  async?: boolean;
21
23
  /** Doc comment */
22
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;
23
55
  }
24
56
  export declare function ClassMethod(props: ClassMethodProps): Children;
25
57
  //# 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,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAG9D,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,MA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AAO,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"}
@@ -4,8 +4,11 @@ import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, makeModifi
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 { Parameters } from "./Parameters.js";
7
+ import { AttributeList } from "./attributes/attributes.js";
8
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";
9
12
 
10
13
  /** Method modifiers. Can only be one. */
11
14
 
@@ -29,11 +32,6 @@ export function ClassMethod(props) {
29
32
  const methodScope = new CSharpMemberScope("method-decl", {
30
33
  owner: methodSymbol
31
34
  });
32
- const params = props.parameters ? _$createComponent(Parameters, {
33
- get parameters() {
34
- return props.parameters;
35
- }
36
- }) : "";
37
35
  const returns = props.returns ?? (props.async ? "Task" : "void");
38
36
  const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
39
37
  // note that scope wraps the method decl so that the params get the correct scope
@@ -47,7 +45,24 @@ export function ClassMethod(props) {
47
45
  get doc() {
48
46
  return props.doc;
49
47
  }
50
- }), modifiers, returns, " ", name, "(", params, ")", _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
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, {
51
66
  newline: true,
52
67
  get children() {
53
68
  return props.children;
@@ -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,iBA8ChD"}
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"}
@@ -41,6 +41,7 @@ export function SourceFile(props) {
41
41
  filetype: "cs",
42
42
  reference: Reference,
43
43
  tabWidth: 4,
44
+ printWidth: 120,
44
45
  get children() {
45
46
  return _$createComponent(SourceFileContext.Provider, {
46
47
  value: sourceFileCtx,
@@ -0,0 +1,39 @@
1
+ import { Children } from "@alloy-js/core";
2
+ export interface AttributeItem {
3
+ name: string;
4
+ args?: string[];
5
+ }
6
+ export type AttributesProp = Array<string | AttributeProps | Children>;
7
+ export interface AttributeListProps {
8
+ /** If the attribute list should finish with a hard line if there is any attribute */
9
+ endline?: boolean;
10
+ attributes?: AttributesProp;
11
+ children?: Children[];
12
+ }
13
+ /**
14
+ * Render each attributes in a new line.
15
+ */
16
+ export declare function AttributeList(props: AttributeListProps): Children;
17
+ export interface AttributeProps {
18
+ /** Attribute name */
19
+ name: Children;
20
+ /** Argument */
21
+ args?: Children[];
22
+ }
23
+ /**
24
+ * Render a csharp attribute.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * <Attribute name="Test" /><hbr/>
29
+ * <Attribute name="Test" args={["arg1", "arg2"]} />
30
+ * ```
31
+ *
32
+ * will render:
33
+ * ```csharp
34
+ * [Test]
35
+ * [Test("arg1", "arg2")]
36
+ * ```
37
+ */
38
+ export declare const Attribute: import("@alloy-js/core").Component<AttributeProps> & Required<Pick<import("@alloy-js/core").Component<AttributeProps>, "tag">>;
39
+ //# sourceMappingURL=attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../src/components/attributes/attributes.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,GAAG,cAAc,GAAG,QAAQ,CAAC,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAiBtD;AAYD,MAAM,WAAW,cAAc;IAC7B,qBAAqB;IACrB,IAAI,EAAE,QAAQ,CAAC;IAEf,eAAe;IACf,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;CACnB;AAGD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,gIAqBrB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { createComponent as _$createComponent, memo as _$memo, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
+ import { findKeyedChildren, For, Indent, taggedComponent } from "@alloy-js/core";
3
+ /**
4
+ * Render each attributes in a new line.
5
+ */
6
+ export function AttributeList(props) {
7
+ const attributes = props.attributes ?? (props.children && findKeyedChildren(props.children, Attribute.tag));
8
+ if (!attributes) {
9
+ return null;
10
+ }
11
+ return [_$createComponent(For, {
12
+ each: attributes,
13
+ line: true,
14
+ children: arg => renderAttribute(arg)
15
+ }), _$memo(() => _$memo(() => !!(props.endline && attributes.length > 0))() && _$createIntrinsic("hbr", {}))];
16
+ }
17
+ function renderAttribute(attr) {
18
+ if (typeof attr === "string") {
19
+ return _$createComponent(Attribute, {
20
+ name: attr
21
+ });
22
+ } else if (typeof attr === "object" && attr && "name" in attr) {
23
+ return _$createComponent(Attribute, attr);
24
+ } else {
25
+ return attr;
26
+ }
27
+ }
28
+ const AttributeTag = Symbol("AttributeTag");
29
+ /**
30
+ * Render a csharp attribute.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * <Attribute name="Test" /><hbr/>
35
+ * <Attribute name="Test" args={["arg1", "arg2"]} />
36
+ * ```
37
+ *
38
+ * will render:
39
+ * ```csharp
40
+ * [Test]
41
+ * [Test("arg1", "arg2")]
42
+ * ```
43
+ */
44
+ export const Attribute = taggedComponent(AttributeTag, props => {
45
+ return _$createIntrinsic("group", {
46
+ get children() {
47
+ return ["[", _$memo(() => props.name), _$memo(() => _$memo(() => !!(props.args && props.args.length > 0))() && ["(", _$createComponent(Indent, {
48
+ softline: true,
49
+ get children() {
50
+ return _$createComponent(For, {
51
+ get each() {
52
+ return props.args ?? [];
53
+ },
54
+ comma: true,
55
+ line: true,
56
+ children: arg => arg
57
+ });
58
+ }
59
+ }), ")"]), "]"];
60
+ }
61
+ });
62
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=attributes.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.test.d.ts","sourceRoot":"","sources":["../../../../src/components/attributes/attributes.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,75 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { expect, it } from "vitest";
3
+ import { Attribute, AttributeList } from "./attributes.js";
4
+ it("define attribute", () => {
5
+ expect(_$createComponent(Attribute, {
6
+ name: "Test"
7
+ })).toRenderTo(`
8
+ [Test]
9
+ `);
10
+ });
11
+ it("define attribute with single arg", () => {
12
+ expect(_$createComponent(Attribute, {
13
+ name: "Test",
14
+ args: [`"abc"`]
15
+ })).toRenderTo(`
16
+ [Test("abc")]
17
+ `);
18
+ });
19
+ it("define attribute with multiple arg", () => {
20
+ expect(_$createComponent(Attribute, {
21
+ name: "Test",
22
+ args: [`"abc"`, `"def"`]
23
+ })).toRenderTo(`
24
+ [Test("abc", "def")]
25
+ `);
26
+ });
27
+ it("define attribute list with Attribute components", () => {
28
+ expect(_$createComponent(AttributeList, {
29
+ get attributes() {
30
+ return [_$createComponent(Attribute, {
31
+ name: "TestA"
32
+ }), _$createComponent(Attribute, {
33
+ name: "TestB"
34
+ })];
35
+ }
36
+ })).toRenderTo(`
37
+ [TestA]
38
+ [TestB]
39
+ `);
40
+ });
41
+ it("define attribute list with attribute names", () => {
42
+ expect(_$createComponent(AttributeList, {
43
+ attributes: ["TestA", "TestB"]
44
+ })).toRenderTo(`
45
+ [TestA]
46
+ [TestB]
47
+ `);
48
+ });
49
+ it("define attribute list with attribute props", () => {
50
+ expect(_$createComponent(AttributeList, {
51
+ attributes: [{
52
+ name: "TestA"
53
+ }, {
54
+ name: "TestB",
55
+ args: [`"test"`]
56
+ }]
57
+ })).toRenderTo(`
58
+ [TestA]
59
+ [TestB("test")]
60
+ `);
61
+ });
62
+ it("define attribute list with children", () => {
63
+ expect(_$createComponent(AttributeList, {
64
+ get children() {
65
+ return [_$createComponent(Attribute, {
66
+ name: "TestA"
67
+ }), _$createComponent(Attribute, {
68
+ name: "TestB"
69
+ })];
70
+ }
71
+ })).toRenderTo(`
72
+ [TestA]
73
+ [TestB]
74
+ `);
75
+ });
@@ -15,7 +15,7 @@ export declare function makeDocCommentTag(name: string): (props: DocCommentProps
15
15
  export declare function makeInlineDocCommentTag(name: string): (props: DocCommentProps) => string;
16
16
  export declare const DocSummary: (props: DocCommentProps) => Children;
17
17
  export declare const DocCode: (props: DocCommentProps) => Children;
18
- export declare const DocC: (props: DocCommentProps) => Children;
18
+ export declare const DocC: (props: DocCommentProps) => string;
19
19
  export declare const DocExample: (props: DocCommentProps) => Children;
20
20
  export declare const DocException: (props: DocCommentProps) => Children;
21
21
  export interface DocIncludeProps {
@@ -39,25 +39,21 @@ export declare const DocReturns: (props: DocCommentProps) => Children;
39
39
  export declare const DocRemarks: (props: DocCommentProps) => Children;
40
40
  export declare const DocValue: (props: DocCommentProps) => Children;
41
41
  export declare const DocPermission: (props: DocCommentProps) => Children;
42
- export declare const DocResponse: (props: DocCommentProps) => Children;
43
- export declare const DocCompletionList: (props: DocCommentProps) => Children;
44
- export declare const DocList: (props: DocCommentProps) => Children;
45
- export declare const DocItem: (props: DocCommentProps) => Children;
46
- export declare const DocTerm: (props: DocCommentProps) => Children;
47
42
  export declare const DocDescription: (props: DocCommentProps) => Children;
48
43
  export declare const DocPara: (props: DocCommentProps) => Children;
49
44
  export interface DocSeeProps {
50
- cref: string;
45
+ cref?: string;
46
+ href?: string;
51
47
  langword?: string;
52
48
  children?: Children;
53
49
  }
54
- export declare const DocSee: (props: DocSeeProps) => string;
50
+ export declare const DocSee: (props: DocSeeProps) => Children;
55
51
  export interface DocSeeAlsoProps {
56
- cref: string;
57
- langword?: string;
52
+ cref?: string;
53
+ href?: string;
58
54
  children?: Children;
59
55
  }
60
- export declare const DocSeeAlso: (props: DocSeeAlsoProps) => string;
56
+ export declare const DocSeeAlso: (props: DocSeeAlsoProps) => Children;
61
57
  export interface DocParamRefProps {
62
58
  name: string;
63
59
  }
@@ -66,4 +62,9 @@ export interface DocTypeParamRefProps {
66
62
  name: string;
67
63
  }
68
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;
69
70
  //# sourceMappingURL=comment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../../src/components/doc/comment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,gBAAgB,CAAC;AAEnE,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;CAC3B;AAED,4FAA4F;AAC5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,CAAC;AAC7D,eAAO,MAAM,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"}
@@ -1,5 +1,5 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
- import { code, List, Prose, Show } from "@alloy-js/core";
2
+ import { code, For, Indent, List, Prose, Show } from "@alloy-js/core";
3
3
  export function DocComment(props) {
4
4
  return ["/// ", _$createIntrinsic("align", {
5
5
  string: "/// ",
@@ -46,7 +46,7 @@ export function makeInlineDocCommentTag(name) {
46
46
  }
47
47
  export const DocSummary = makeDocCommentTag("summary");
48
48
  export const DocCode = makeDocCommentTag("code");
49
- export const DocC = makeDocCommentTag("c");
49
+ export const DocC = makeInlineDocCommentTag("c");
50
50
  export const DocExample = makeDocCommentTag("example");
51
51
  export const DocException = makeDocCommentTag("exception");
52
52
  export const DocInclude = props => {
@@ -58,14 +58,31 @@ export const DocReturns = makeDocCommentTag("returns");
58
58
  export const DocRemarks = makeDocCommentTag("remarks");
59
59
  export const DocValue = makeDocCommentTag("value");
60
60
  export const DocPermission = makeDocCommentTag("permission");
61
- export const DocResponse = makeDocCommentTag("response");
62
- export const DocCompletionList = makeDocCommentTag("completionlist");
63
- export const DocList = makeDocCommentTag("list");
64
- export const DocItem = makeDocCommentTag("item");
65
- export const DocTerm = makeDocCommentTag("term");
66
61
  export const DocDescription = makeDocCommentTag("description");
67
62
  export const DocPara = makeDocCommentTag("para");
68
- export const DocSee = props => `<see cref="${props.cref}"${props.langword ? ` langword="${props.langword}"` : ""}${props.children ? `>${props.children}</see>` : " />"}`;
69
- export const DocSeeAlso = props => `<seealso cref="${props.cref}"${props.langword ? ` langword="${props.langword}"` : ""}${props.children ? `>${props.children}</seealso>` : " />"}`;
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
+ };
70
71
  export const DocParamRef = props => `<paramref name="${props.name}" />`;
71
- export const DocTypeParamRef = props => `<typeparamref 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
+ }