@alloy-js/csharp 0.18.0-dev.9 → 0.19.0-dev.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 +3 -3
- 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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Children, DeclarationProps, Name, Refkey } from "@alloy-js/core";
|
|
2
|
+
import { useCSharpNamePolicy } from "../../name-policy.js";
|
|
3
|
+
import { Declaration } from "../Declaration.jsx";
|
|
4
|
+
|
|
5
|
+
/** Props for {@link VarDeclaration} component */
|
|
6
|
+
export interface VarDeclarationProps
|
|
7
|
+
extends Omit<DeclarationProps, "nameKind"> {
|
|
8
|
+
/** Variable name */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Type of the variable declaration. If not specified, defaults to "var" */
|
|
11
|
+
type?: Children;
|
|
12
|
+
/** Variable refkey */
|
|
13
|
+
refkey?: Refkey;
|
|
14
|
+
/** Variable value */
|
|
15
|
+
children?: Children;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Render a variable declaration
|
|
20
|
+
*
|
|
21
|
+
* @example with var
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <VarDeclaration name="myVar">42</VarDeclaration>
|
|
24
|
+
* ```
|
|
25
|
+
* This will render:
|
|
26
|
+
* ```csharp
|
|
27
|
+
* var myVar = 42;
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example with type
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <VarDeclaration name="myVar" type="int">42</VarDeclaration>
|
|
33
|
+
* ```
|
|
34
|
+
* This will render:
|
|
35
|
+
* ```csharp
|
|
36
|
+
* int myVar = 42;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function VarDeclaration(props: VarDeclarationProps) {
|
|
40
|
+
const name = useCSharpNamePolicy().getName(props.name, "variable");
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Declaration name={name} refkey={props.refkey}>
|
|
44
|
+
{props.type ?? "var"} <Name /> = {props.children};
|
|
45
|
+
</Declaration>
|
|
46
|
+
);
|
|
47
|
+
}
|
package/src/name-policy.ts
CHANGED
|
@@ -5,10 +5,12 @@ import * as changecase from "change-case";
|
|
|
5
5
|
export type CSharpElements =
|
|
6
6
|
| "class"
|
|
7
7
|
| "constant"
|
|
8
|
+
| "variable"
|
|
8
9
|
| "enum"
|
|
9
10
|
| "enum-member"
|
|
10
11
|
| "function"
|
|
11
12
|
| "interface"
|
|
13
|
+
| "record"
|
|
12
14
|
| "class-member-private"
|
|
13
15
|
| "class-member-public"
|
|
14
16
|
| "class-method"
|
|
@@ -24,6 +26,7 @@ export function createCSharpNamePolicy(): core.NamePolicy<CSharpElements> {
|
|
|
24
26
|
case "enum":
|
|
25
27
|
case "enum-member":
|
|
26
28
|
case "interface":
|
|
29
|
+
case "record":
|
|
27
30
|
case "class-member-public":
|
|
28
31
|
case "class-method":
|
|
29
32
|
case "type-parameter":
|