@alloy-js/csharp 0.18.0-dev.9 → 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.
- package/CHANGELOG.md +31 -0
- package/dist/src/components/ClassDeclaration.d.ts +39 -2
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +35 -34
- package/dist/src/components/ClassMethod.d.ts +33 -1
- package/dist/src/components/ClassMethod.d.ts.map +1 -1
- package/dist/src/components/ClassMethod.js +22 -7
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +1 -0
- package/dist/src/components/attributes/attributes.d.ts +39 -0
- package/dist/src/components/attributes/attributes.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.js +62 -0
- package/dist/src/components/attributes/attributes.test.d.ts +2 -0
- package/dist/src/components/attributes/attributes.test.d.ts.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +75 -0
- package/dist/src/components/index.d.ts +7 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +8 -2
- package/dist/src/components/interface/declaration.d.ts +32 -1
- package/dist/src/components/interface/declaration.d.ts.map +1 -1
- package/dist/src/components/interface/declaration.js +18 -25
- package/dist/src/components/interface/declaration.test.js +102 -0
- package/dist/src/components/interface/method.d.ts +33 -1
- package/dist/src/components/interface/method.d.ts.map +1 -1
- package/dist/src/components/interface/method.js +22 -7
- package/dist/src/components/interface/method.test.js +169 -0
- package/dist/src/components/interface/property.d.ts +36 -1
- package/dist/src/components/interface/property.d.ts.map +1 -1
- package/dist/src/components/interface/property.js +18 -4
- package/dist/src/components/interface/property.test.js +24 -0
- package/dist/src/components/parameters/parameters.d.ts +19 -0
- package/dist/src/components/parameters/parameters.d.ts.map +1 -0
- package/dist/src/components/parameters/parameters.js +43 -0
- package/dist/src/components/property/property.d.ts +80 -0
- package/dist/src/components/property/property.d.ts.map +1 -0
- package/dist/src/components/property/property.js +76 -0
- package/dist/src/components/property/property.test.d.ts +2 -0
- package/dist/src/components/property/property.test.d.ts.map +1 -0
- package/dist/src/components/property/property.test.js +242 -0
- package/dist/src/components/record/declaration.d.ts +35 -0
- package/dist/src/components/record/declaration.d.ts.map +1 -0
- package/dist/src/components/record/declaration.js +90 -0
- package/dist/src/components/record/declaration.test.d.ts +2 -0
- package/dist/src/components/record/declaration.test.d.ts.map +1 -0
- package/dist/src/components/record/declaration.test.js +94 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +8 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.js +44 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +2 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +67 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts +20 -0
- package/dist/src/components/type-parameters/type-parameter.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameter.js +22 -0
- package/dist/src/components/type-parameters/type-parameters.d.ts +17 -0
- package/dist/src/components/type-parameters/type-parameters.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.js +54 -0
- package/dist/src/components/type-parameters/type-parameters.test.d.ts +2 -0
- package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.test.js +48 -0
- package/dist/src/components/var/declaration.d.ts +35 -0
- package/dist/src/components/var/declaration.d.ts.map +1 -0
- package/dist/src/components/var/declaration.js +40 -0
- package/dist/src/components/var/declaration.test.d.ts +2 -0
- package/dist/src/components/var/declaration.test.d.ts.map +1 -0
- package/dist/src/components/var/declaration.test.js +73 -0
- package/dist/src/name-policy.d.ts +1 -1
- package/dist/src/name-policy.d.ts.map +1 -1
- package/dist/src/name-policy.js +1 -0
- package/dist/test/class-declaration.test.d.ts +2 -0
- package/dist/test/class-declaration.test.d.ts.map +1 -0
- package/dist/test/{class.test.js → class-declaration.test.js} +161 -33
- package/dist/test/project-directory.test.d.ts +2 -0
- package/dist/test/project-directory.test.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/ClassDeclaration.tsx +65 -33
- package/src/components/ClassMethod.tsx +46 -4
- package/src/components/SourceFile.tsx +1 -0
- package/src/components/attributes/attributes.test.tsx +61 -0
- package/src/components/attributes/attributes.tsx +100 -0
- package/src/components/index.ts +7 -1
- package/src/components/interface/declaration.test.tsx +102 -0
- package/src/components/interface/declaration.tsx +43 -27
- package/src/components/interface/method.test.tsx +173 -0
- package/src/components/interface/method.tsx +45 -5
- package/src/components/interface/property.test.tsx +21 -0
- package/src/components/interface/property.tsx +43 -6
- package/src/components/parameters/parameters.tsx +74 -0
- package/src/components/property/property.test.tsx +209 -0
- package/src/components/property/property.tsx +172 -0
- package/src/components/record/declaration.test.tsx +73 -0
- package/src/components/record/declaration.tsx +109 -0
- package/src/components/type-parameters/type-parameter-constraints.test.tsx +93 -0
- package/src/components/type-parameters/type-parameter-constraints.tsx +46 -0
- package/src/components/type-parameters/type-parameter.tsx +35 -0
- package/src/components/type-parameters/type-parameters.test.tsx +46 -0
- package/src/components/type-parameters/type-parameters.tsx +63 -0
- package/src/components/var/declaration.test.tsx +59 -0
- package/src/components/var/declaration.tsx +47 -0
- package/src/name-policy.ts +3 -0
- package/temp/api.json +4722 -2384
- package/test/{class.test.tsx → class-declaration.test.tsx} +144 -26
- package/dist/src/components/Parameters.d.ts +0 -13
- package/dist/src/components/Parameters.d.ts.map +0 -1
- package/dist/src/components/Parameters.js +0 -34
- package/dist/test/class.test.d.ts +0 -2
- package/dist/test/class.test.d.ts.map +0 -1
- package/dist/test/projectdirectory.test.d.ts +0 -2
- package/dist/test/projectdirectory.test.d.ts.map +0 -1
- package/src/components/Parameters.tsx +0 -51
- /package/dist/test/{projectdirectory.test.js → project-directory.test.js} +0 -0
- /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 {
|
|
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
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"ClassDeclaration.d.ts","sourceRoot":"","sources":["../../../src/components/ClassDeclaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EACL,eAAe,EAIhB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAiB,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,cAAc,EAAc,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAUD,MAAM,WAAW,qBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,cAAc;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAEjD,yCAAyC;IACzC,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IAEzB,uCAAuC;IACvC,cAAc,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEjC;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBA6C5D;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,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 {
|
|
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 {
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
}),
|
|
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, {}),
|
|
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 [
|
|
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 {
|
|
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;
|
|
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"}
|
|
@@ -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 {
|
|
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
|
-
}),
|
|
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,
|
|
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"}
|
|
@@ -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 @@
|
|
|
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
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from "./attributes/attributes.jsx";
|
|
1
2
|
export * from "./ClassDeclaration.jsx";
|
|
2
3
|
export * from "./ClassMethod.jsx";
|
|
3
4
|
export * from "./Declaration.js";
|
|
@@ -6,11 +7,16 @@ export * from "./doc/from-markdown.jsx";
|
|
|
6
7
|
export * from "./EnumDeclaration.jsx";
|
|
7
8
|
export * from "./interface/declaration.js";
|
|
8
9
|
export * from "./interface/method.js";
|
|
10
|
+
export * from "./interface/property.js";
|
|
9
11
|
export * from "./Name.js";
|
|
10
12
|
export * from "./Namespace.js";
|
|
11
|
-
export * from "./
|
|
13
|
+
export * from "./parameters/parameters.jsx";
|
|
12
14
|
export * from "./ProjectDirectory.js";
|
|
15
|
+
export * from "./property/property.jsx";
|
|
16
|
+
export * from "./record/declaration.js";
|
|
13
17
|
export * from "./Reference.js";
|
|
14
18
|
export * from "./SourceFile.js";
|
|
19
|
+
export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
15
20
|
export * from "./UsingDirective.js";
|
|
21
|
+
export * from "./var/declaration.jsx";
|
|
16
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,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,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,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,3 +1,4 @@
|
|
|
1
|
+
export * from "./attributes/attributes.js";
|
|
1
2
|
export * from "./ClassDeclaration.js";
|
|
2
3
|
export * from "./ClassMethod.js";
|
|
3
4
|
export * from "./Declaration.js";
|
|
@@ -6,10 +7,15 @@ export * from "./doc/from-markdown.js";
|
|
|
6
7
|
export * from "./EnumDeclaration.js";
|
|
7
8
|
export * from "./interface/declaration.js";
|
|
8
9
|
export * from "./interface/method.js";
|
|
10
|
+
export * from "./interface/property.js";
|
|
9
11
|
export * from "./Name.js";
|
|
10
12
|
export * from "./Namespace.js";
|
|
11
|
-
export * from "./
|
|
13
|
+
export * from "./parameters/parameters.js";
|
|
12
14
|
export * from "./ProjectDirectory.js";
|
|
15
|
+
export * from "./property/property.js";
|
|
16
|
+
export * from "./record/declaration.js";
|
|
13
17
|
export * from "./Reference.js";
|
|
14
18
|
export * from "./SourceFile.js";
|
|
15
|
-
export * from "./UsingDirective.js";
|
|
19
|
+
export * from "./UsingDirective.js";
|
|
20
|
+
export * from "./var/declaration.js";
|
|
21
|
+
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
2
|
import { AccessModifiers } from "../../modifiers.js";
|
|
3
|
+
import { AttributesProp } from "../attributes/attributes.jsx";
|
|
4
|
+
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
3
5
|
export interface InterfaceModifiers {
|
|
4
6
|
readonly partial?: boolean;
|
|
5
7
|
}
|
|
@@ -8,7 +10,36 @@ export interface InterfaceDeclarationProps extends Omit<core.DeclarationProps, "
|
|
|
8
10
|
/** Doc comment */
|
|
9
11
|
doc?: core.Children;
|
|
10
12
|
refkey?: core.Refkey;
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Type parameters for the interface
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <InterfaceDeclaration name="IList" typeParameters={["T"]} />
|
|
19
|
+
* ```
|
|
20
|
+
* This will produce:
|
|
21
|
+
* ```csharp
|
|
22
|
+
* public interface IList<T>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
typeParameters?: (TypeParameterProps | string)[];
|
|
26
|
+
/**
|
|
27
|
+
* Define attributes to attach
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <InterfaceDeclaration name="MyInterface" attributes={[
|
|
31
|
+
* <Attribute name="Test" />
|
|
32
|
+
* <Attribute name="Test2" args={["arg1", "arg2"]} />
|
|
33
|
+
* ]} />
|
|
34
|
+
* ```
|
|
35
|
+
* This will produce:
|
|
36
|
+
* ```csharp
|
|
37
|
+
* [Test]
|
|
38
|
+
* [Test2("arg1", "arg2")]
|
|
39
|
+
* public interface MyInterface
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
attributes?: AttributesProp;
|
|
12
43
|
}
|
|
13
44
|
/**
|
|
14
45
|
* CSharp interface declaration.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/interface/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAKD,MAAM,WAAW,yBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,EAC7C,eAAe,EACf,kBAAkB;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb,kBAAkB;IAClB,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IAErB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,iBAqCpE"}
|