@typespec/emitter-framework 0.9.0-dev.6 → 0.9.0-dev.8
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/dist/src/core/components/output.d.ts +4 -4
- package/dist/src/core/components/output.d.ts.map +1 -1
- package/dist/src/core/components/output.js +3 -3
- package/dist/src/core/context/name-policy-context.d.ts +2 -2
- package/dist/src/core/context/name-policy-context.d.ts.map +1 -1
- package/dist/src/core/context/tsp-context.d.ts +2 -2
- package/dist/src/core/context/tsp-context.d.ts.map +1 -1
- package/dist/src/core/transport-name-policy.d.ts +1 -1
- package/dist/src/core/transport-name-policy.d.ts.map +1 -1
- package/dist/src/core/write-output.d.ts +2 -2
- package/dist/src/core/write-output.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.d.ts +3 -3
- package/dist/src/csharp/components/class/declaration.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.js +2 -2
- package/dist/src/csharp/components/class/declaration.test.js +100 -115
- package/dist/src/csharp/components/{enum-declaration.d.ts → enum/declaration.d.ts} +4 -4
- package/dist/src/csharp/components/enum/declaration.d.ts.map +1 -0
- package/dist/src/csharp/components/{enum-declaration.js → enum/declaration.js} +6 -6
- package/dist/src/csharp/components/enum/declaration.test.d.ts +2 -0
- package/dist/src/csharp/components/enum/declaration.test.d.ts.map +1 -0
- package/dist/src/csharp/components/enum/declaration.test.js +309 -0
- package/dist/src/csharp/components/index.d.ts +1 -1
- package/dist/src/csharp/components/index.js +1 -1
- package/dist/src/csharp/components/property/property.d.ts +2 -2
- package/dist/src/csharp/components/property/property.d.ts.map +1 -1
- package/dist/src/csharp/components/property/property.test.js +14 -14
- package/dist/src/csharp/components/type-expression.d.ts +3 -3
- package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
- package/dist/src/csharp/components/utils/doc-comments.d.ts +4 -4
- package/dist/src/csharp/components/utils/doc-comments.d.ts.map +1 -1
- package/dist/src/csharp/components/utils/doc-comments.js +2 -2
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/harness.d.ts +2 -2
- package/dist/src/testing/scenario-test/harness.d.ts.map +1 -1
- package/dist/src/testing/scenario-test/test-host.d.ts +2 -2
- package/dist/src/testing/scenario-test/test-host.d.ts.map +1 -1
- package/dist/src/typescript/components/array-expression.d.ts +2 -3
- package/dist/src/typescript/components/array-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/array-expression.js +2 -2
- package/dist/src/typescript/components/arrow-function.d.ts +1 -1
- package/dist/src/typescript/components/arrow-function.d.ts.map +1 -1
- package/dist/src/typescript/components/class-method.d.ts +1 -1
- package/dist/src/typescript/components/class-method.d.ts.map +1 -1
- package/dist/src/typescript/components/enum-declaration.d.ts +6 -6
- package/dist/src/typescript/components/enum-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/enum-declaration.js +2 -2
- package/dist/src/typescript/components/function-declaration.d.ts +1 -1
- package/dist/src/typescript/components/function-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/function-expression.d.ts +1 -1
- package/dist/src/typescript/components/function-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/function-type.d.ts +1 -1
- package/dist/src/typescript/components/function-type.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-declaration.d.ts +4 -4
- package/dist/src/typescript/components/interface-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-declaration.js +3 -4
- package/dist/src/typescript/components/interface-member.d.ts +2 -2
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-method.d.ts +2 -2
- package/dist/src/typescript/components/interface-method.d.ts.map +1 -1
- package/dist/src/typescript/components/record-expression.d.ts +1 -1
- package/dist/src/typescript/components/record-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-alias-declaration.d.ts +1 -1
- package/dist/src/typescript/components/type-alias-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts +1 -1
- package/dist/src/typescript/components/type-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/type-expression.d.ts +1 -1
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-transform.d.ts +2 -2
- package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
- package/dist/src/typescript/components/union-declaration.d.ts +2 -2
- package/dist/src/typescript/components/union-declaration.d.ts.map +1 -1
- package/dist/src/typescript/components/union-expression.d.ts +3 -4
- package/dist/src/typescript/components/union-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/union-expression.js +3 -3
- package/dist/src/typescript/components/value-expression.d.ts +2 -2
- package/dist/src/typescript/components/value-expression.d.ts.map +1 -1
- package/dist/src/typescript/utils/operation.d.ts +2 -2
- package/dist/src/typescript/utils/operation.d.ts.map +1 -1
- package/dist/test/typescript/components/member-expression.test.js +5 -5
- package/dist/test/typescript/test-host.d.ts +1 -1
- package/dist/test/typescript/test-host.d.ts.map +1 -1
- package/dist/test/utils.d.ts +2 -2
- package/dist/test/utils.d.ts.map +1 -1
- package/package.json +7 -4
- package/src/core/components/output.tsx +9 -5
- package/src/core/context/name-policy-context.ts +2 -2
- package/src/core/context/tsp-context.ts +2 -2
- package/src/core/transport-name-policy.ts +1 -1
- package/src/core/write-output.ts +2 -2
- package/src/csharp/components/class/declaration.test.tsx +107 -169
- package/src/csharp/components/class/declaration.tsx +8 -8
- package/src/csharp/components/enum/declaration.test.tsx +267 -0
- package/src/csharp/components/{enum-declaration.tsx → enum/declaration.tsx} +9 -9
- package/src/csharp/components/index.ts +1 -1
- package/src/csharp/components/property/property.test.tsx +16 -16
- package/src/csharp/components/property/property.tsx +2 -2
- package/src/csharp/components/type-expression.test.tsx +3 -3
- package/src/csharp/components/type-expression.tsx +3 -3
- package/src/csharp/components/utils/doc-comments.tsx +6 -6
- package/src/testing/index.ts +1 -1
- package/src/testing/scenario-test/harness.ts +2 -2
- package/src/testing/scenario-test/test-host.ts +4 -4
- package/src/typescript/components/array-expression.tsx +3 -3
- package/src/typescript/components/arrow-function.tsx +1 -1
- package/src/typescript/components/class-method.tsx +1 -1
- package/src/typescript/components/enum-declaration.tsx +6 -6
- package/src/typescript/components/function-declaration.tsx +1 -1
- package/src/typescript/components/function-expression.tsx +1 -1
- package/src/typescript/components/function-type.tsx +1 -1
- package/src/typescript/components/interface-declaration.tsx +11 -12
- package/src/typescript/components/interface-member.tsx +2 -2
- package/src/typescript/components/interface-method.tsx +2 -2
- package/src/typescript/components/record-expression.tsx +1 -1
- package/src/typescript/components/type-alias-declaration.tsx +1 -1
- package/src/typescript/components/type-declaration.tsx +1 -1
- package/src/typescript/components/type-expression.tsx +2 -2
- package/src/typescript/components/type-transform.tsx +3 -3
- package/src/typescript/components/union-declaration.tsx +2 -2
- package/src/typescript/components/union-expression.tsx +12 -7
- package/src/typescript/components/value-expression.tsx +2 -2
- package/src/typescript/utils/operation.ts +2 -2
- package/test/testing/snippet-extractor-csharp.test.ts +1 -1
- package/test/testing/snippet-extractor-java.test.ts +1 -1
- package/test/testing/snippet-extractor-python.test.ts +1 -1
- package/test/testing/snippet-extractor-typescript.test.ts +1 -1
- package/test/typescript/components/arrow-function.test.tsx +2 -2
- package/test/typescript/components/enum-declaration.test.tsx +1 -1
- package/test/typescript/components/function-declaration.test.tsx +1 -1
- package/test/typescript/components/function-expression.test.tsx +2 -2
- package/test/typescript/components/function-type.test.tsx +2 -2
- package/test/typescript/components/interface-declaration.test.tsx +1 -1
- package/test/typescript/components/interface-method.test.tsx +2 -2
- package/test/typescript/components/member-expression.test.tsx +10 -10
- package/test/typescript/components/type-alias-declaration.test.tsx +1 -1
- package/test/typescript/components/type-transform.test.tsx +2 -2
- package/test/typescript/components/union-declaration.test.tsx +2 -2
- package/test/typescript/components/value-expression.test.tsx +6 -6
- package/test/typescript/test-host.ts +1 -1
- package/test/utils.ts +2 -2
- package/tsconfig.json +1 -0
- package/dist/src/csharp/components/enum-declaration.d.ts.map +0 -1
- package/dist/test/csharp/components/enum-declaration.test.d.ts +0 -2
- package/dist/test/csharp/components/enum-declaration.test.d.ts.map +0 -1
- package/dist/test/csharp/components/enum-declaration.test.js +0 -403
- package/dist/test/csharp/test-host.d.ts +0 -11
- package/dist/test/csharp/test-host.d.ts.map +0 -1
- package/dist/test/csharp/test-host.js +0 -32
- package/dist/test/csharp/utils.d.ts +0 -3
- package/dist/test/csharp/utils.d.ts.map +0 -1
- package/dist/test/csharp/utils.js +0 -6
- package/test/csharp/components/enum-declaration.test.tsx +0 -337
- package/test/csharp/test-host.ts +0 -42
- package/test/csharp/utils.ts +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Program } from "@typespec/compiler";
|
|
3
|
-
export interface OutputProps extends
|
|
1
|
+
import { type OutputProps as CoreOutputProps } from "@alloy-js/core";
|
|
2
|
+
import type { Program } from "@typespec/compiler";
|
|
3
|
+
export interface OutputProps extends CoreOutputProps {
|
|
4
4
|
/**
|
|
5
5
|
* TypeSpec program.
|
|
6
6
|
*/
|
|
7
7
|
program: Program;
|
|
8
8
|
}
|
|
9
|
-
export declare function Output(props: OutputProps):
|
|
9
|
+
export declare function Output(props: OutputProps): import("@alloy-js/core").Children;
|
|
10
10
|
//# sourceMappingURL=output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/core/components/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../../src/core/components/output.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,IAAI,eAAe,EACpC,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,qCAOxC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { Output as CoreOutput, splitProps } from "@alloy-js/core";
|
|
3
3
|
import { TspContext } from "../context/tsp-context.js";
|
|
4
4
|
export function Output(props) {
|
|
5
5
|
const [{
|
|
6
6
|
program
|
|
7
|
-
}, rest] =
|
|
7
|
+
}, rest] = splitProps(props, ["program"]);
|
|
8
8
|
return _$createComponent(TspContext.Provider, {
|
|
9
9
|
value: {
|
|
10
10
|
program
|
|
11
11
|
},
|
|
12
12
|
get children() {
|
|
13
|
-
return _$createComponent(
|
|
13
|
+
return _$createComponent(CoreOutput, rest);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentContext } from "@alloy-js/core";
|
|
2
|
-
import { TransformNamePolicy } from "../transport-name-policy.js";
|
|
1
|
+
import { type ComponentContext } from "@alloy-js/core";
|
|
2
|
+
import type { TransformNamePolicy } from "../transport-name-policy.js";
|
|
3
3
|
export declare const TransformNamePolicyContext: ComponentContext<TransformNamePolicy>;
|
|
4
4
|
export declare function useTransformNamePolicy(): TransformNamePolicy;
|
|
5
5
|
//# sourceMappingURL=name-policy-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-policy-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/name-policy-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"name-policy-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/name-policy-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,eAAO,MAAM,0BAA0B,EAAE,gBAAgB,CAAC,mBAAmB,CAQzE,CAAC;AAEL,wBAAgB,sBAAsB,wBAErC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentContext } from "@alloy-js/core";
|
|
2
|
-
import { Program } from "@typespec/compiler";
|
|
1
|
+
import { type ComponentContext } from "@alloy-js/core";
|
|
2
|
+
import type { Program } from "@typespec/compiler";
|
|
3
3
|
import { type Typekit } from "@typespec/compiler/typekit";
|
|
4
4
|
export type TspContext = {
|
|
5
5
|
program: Program;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsp-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/tsp-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"tsp-context.d.ts","sourceRoot":"","sources":["../../../../src/core/context/tsp-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AACvF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,EAAE,OAAO,CAAC;CACZ,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,CAAC,CAAC,EAAE,OAAO,CAAA;CAAE,CAG3D,CAAC;AAEjB,wBAAgB,MAAM,IAaF,UAAU,CAC7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type } from "@typespec/compiler";
|
|
1
|
+
import type { Type } from "@typespec/compiler";
|
|
2
2
|
/**
|
|
3
3
|
* A type that extends `Type` and includes a `name` property that can either be a `string` or `symbol`.
|
|
4
4
|
* This type is used to represent objects that have a `name` of type `string` or `symbol`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-name-policy.d.ts","sourceRoot":"","sources":["../../../src/core/transport-name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"transport-name-policy.d.ts","sourceRoot":"","sources":["../../../src/core/transport-name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,gBAAgB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;IAE3D;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,cAAc,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC7D,gBAAgB,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CAChE,GAAG,mBAAmB,CAsBtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { Program } from "@typespec/compiler";
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
import { type Program } from "@typespec/compiler";
|
|
3
3
|
export declare function writeOutput(program: Program, rootComponent: Children, emitterOutputDir: string): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=write-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"write-output.d.ts","sourceRoot":"","sources":["../../../src/core/write-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAgC,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEvE,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,QAAQ,EACvB,gBAAgB,EAAE,MAAM,iBAIzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
2
|
import * as cs from "@alloy-js/csharp";
|
|
3
|
-
import { Interface, Model } from "@typespec/compiler";
|
|
3
|
+
import type { Interface, Model } from "@typespec/compiler";
|
|
4
4
|
export interface ClassDeclarationProps extends Omit<cs.ClassDeclarationProps, "name"> {
|
|
5
5
|
/** Set an alternative name for the class. Otherwise default to the type name. */
|
|
6
6
|
name?: string;
|
|
@@ -9,5 +9,5 @@ export interface ClassDeclarationProps extends Omit<cs.ClassDeclarationProps, "n
|
|
|
9
9
|
/** If set the property will add the json serialization attributes(using System.Text.Json). */
|
|
10
10
|
jsonAttributes?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare function ClassDeclaration(props: ClassDeclarationProps):
|
|
12
|
+
export declare function ClassDeclaration(props: ClassDeclarationProps): Children;
|
|
13
13
|
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/class/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/class/declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAO3D,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,EAAE,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACnF,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAYD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,QAAQ,CAuBvE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { For } from "@alloy-js/core";
|
|
3
3
|
import * as cs from "@alloy-js/csharp";
|
|
4
4
|
import { useTsp } from "../../../core/index.js";
|
|
5
5
|
import { Property } from "../property/property.js";
|
|
@@ -37,7 +37,7 @@ export function ClassDeclaration(props) {
|
|
|
37
37
|
}))];
|
|
38
38
|
}
|
|
39
39
|
function ClassProperties(props) {
|
|
40
|
-
return _$createComponent(
|
|
40
|
+
return _$createComponent(For, {
|
|
41
41
|
get each() {
|
|
42
42
|
return props.type.properties.entries();
|
|
43
43
|
},
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Tester } from "#test/test-host.js";
|
|
3
|
-
import { render } from "@alloy-js/core";
|
|
4
|
-
import { d } from "@alloy-js/core/testing";
|
|
5
3
|
import { createCSharpNamePolicy, Namespace, SourceFile } from "@alloy-js/csharp";
|
|
6
4
|
import { t } from "@typespec/compiler/testing";
|
|
7
|
-
import { beforeEach, describe, it } from "vitest";
|
|
8
|
-
import { assertFileContents } from "../../../../test/csharp/utils.js";
|
|
5
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
9
6
|
import { Output } from "../../../core/index.js";
|
|
10
7
|
import { ClassDeclaration, EnumDeclaration } from "../../index.js";
|
|
11
8
|
let runner;
|
|
@@ -40,22 +37,21 @@ it("renders an empty class declaration", async () => {
|
|
|
40
37
|
} = await runner.compile(t.code`
|
|
41
38
|
model ${t.model("TestModel")} {}
|
|
42
39
|
`);
|
|
43
|
-
|
|
40
|
+
expect(_$createComponent(Wrapper, {
|
|
44
41
|
get children() {
|
|
45
42
|
return _$createComponent(ClassDeclaration, {
|
|
46
43
|
type: TestModel
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{
|
|
46
|
+
})).toRenderTo(`
|
|
47
|
+
namespace TestNamespace
|
|
48
|
+
{
|
|
49
|
+
class TestModel
|
|
50
|
+
{
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`);
|
|
59
55
|
});
|
|
60
56
|
it("renders a class declaration with properties", async () => {
|
|
61
57
|
const {
|
|
@@ -66,23 +62,22 @@ it("renders a class declaration with properties", async () => {
|
|
|
66
62
|
@test Prop2: int32;
|
|
67
63
|
}
|
|
68
64
|
`);
|
|
69
|
-
|
|
65
|
+
expect(_$createComponent(Wrapper, {
|
|
70
66
|
get children() {
|
|
71
67
|
return _$createComponent(ClassDeclaration, {
|
|
72
68
|
type: TestModel
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
|
-
}))
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
`);
|
|
71
|
+
})).toRenderTo(`
|
|
72
|
+
namespace TestNamespace
|
|
73
|
+
{
|
|
74
|
+
class TestModel
|
|
75
|
+
{
|
|
76
|
+
public required string Prop1 { get; set; }
|
|
77
|
+
public required int Prop2 { get; set; }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`);
|
|
86
81
|
});
|
|
87
82
|
it("can override class name", async () => {
|
|
88
83
|
const {
|
|
@@ -90,23 +85,22 @@ it("can override class name", async () => {
|
|
|
90
85
|
} = await runner.compile(t.code`
|
|
91
86
|
model ${t.model("TestModel")} {}
|
|
92
87
|
`);
|
|
93
|
-
|
|
88
|
+
expect(_$createComponent(Wrapper, {
|
|
94
89
|
get children() {
|
|
95
90
|
return _$createComponent(ClassDeclaration, {
|
|
96
91
|
type: TestModel,
|
|
97
92
|
name: "CustomClassName"
|
|
98
93
|
});
|
|
99
94
|
}
|
|
100
|
-
}))
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
{
|
|
95
|
+
})).toRenderTo(`
|
|
96
|
+
namespace TestNamespace
|
|
97
|
+
{
|
|
98
|
+
class CustomClassName
|
|
99
|
+
{
|
|
106
100
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`);
|
|
110
104
|
});
|
|
111
105
|
it("renders a class with access modifiers", async () => {
|
|
112
106
|
const {
|
|
@@ -115,23 +109,22 @@ it("renders a class with access modifiers", async () => {
|
|
|
115
109
|
model ${t.model("TestModel")} {
|
|
116
110
|
}
|
|
117
111
|
`);
|
|
118
|
-
|
|
112
|
+
expect(_$createComponent(Wrapper, {
|
|
119
113
|
get children() {
|
|
120
114
|
return _$createComponent(ClassDeclaration, {
|
|
121
115
|
type: TestModel,
|
|
122
116
|
"protected": true
|
|
123
117
|
});
|
|
124
118
|
}
|
|
125
|
-
}))
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
{
|
|
119
|
+
})).toRenderTo(`
|
|
120
|
+
namespace TestNamespace
|
|
121
|
+
{
|
|
122
|
+
protected class TestModel
|
|
123
|
+
{
|
|
131
124
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`);
|
|
135
128
|
});
|
|
136
129
|
describe("from an interface", () => {
|
|
137
130
|
it("renders an empty class", async () => {
|
|
@@ -141,14 +134,13 @@ describe("from an interface", () => {
|
|
|
141
134
|
interface ${t.interface("TestInterface")} {
|
|
142
135
|
}
|
|
143
136
|
`);
|
|
144
|
-
|
|
137
|
+
expect(_$createComponent(Wrapper, {
|
|
145
138
|
get children() {
|
|
146
139
|
return _$createComponent(ClassDeclaration, {
|
|
147
140
|
type: TestInterface
|
|
148
141
|
});
|
|
149
142
|
}
|
|
150
|
-
}))
|
|
151
|
-
assertFileContents(res, d`
|
|
143
|
+
})).toRenderTo(`
|
|
152
144
|
namespace TestNamespace
|
|
153
145
|
{
|
|
154
146
|
class TestInterface
|
|
@@ -166,14 +158,13 @@ describe("from an interface", () => {
|
|
|
166
158
|
op getName(id: string): string;
|
|
167
159
|
}
|
|
168
160
|
`);
|
|
169
|
-
|
|
161
|
+
expect(_$createComponent(Wrapper, {
|
|
170
162
|
get children() {
|
|
171
163
|
return _$createComponent(ClassDeclaration, {
|
|
172
164
|
type: TestInterface
|
|
173
165
|
});
|
|
174
166
|
}
|
|
175
|
-
}))
|
|
176
|
-
assertFileContents(res, d`
|
|
167
|
+
})).toRenderTo(`
|
|
177
168
|
namespace TestNamespace
|
|
178
169
|
{
|
|
179
170
|
class TestInterface
|
|
@@ -194,7 +185,7 @@ it("renders a class with model members", async () => {
|
|
|
194
185
|
prop1: TestReference;
|
|
195
186
|
}
|
|
196
187
|
`);
|
|
197
|
-
|
|
188
|
+
expect(_$createComponent(Wrapper, {
|
|
198
189
|
get children() {
|
|
199
190
|
return [_$createComponent(ClassDeclaration, {
|
|
200
191
|
type: TestReference
|
|
@@ -202,20 +193,19 @@ it("renders a class with model members", async () => {
|
|
|
202
193
|
type: TestModel
|
|
203
194
|
})];
|
|
204
195
|
}
|
|
205
|
-
}))
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
{
|
|
196
|
+
})).toRenderTo(`
|
|
197
|
+
namespace TestNamespace
|
|
198
|
+
{
|
|
199
|
+
class TestReference
|
|
200
|
+
{
|
|
211
201
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
202
|
+
}
|
|
203
|
+
class TestModel
|
|
204
|
+
{
|
|
205
|
+
public required TestReference Prop1 { get; set; }
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
`);
|
|
219
209
|
});
|
|
220
210
|
it("renders a class with enum members", async () => {
|
|
221
211
|
const {
|
|
@@ -230,7 +220,7 @@ it("renders a class with enum members", async () => {
|
|
|
230
220
|
@test prop1: TestEnum;
|
|
231
221
|
}
|
|
232
222
|
`);
|
|
233
|
-
|
|
223
|
+
expect(_$createComponent(Wrapper, {
|
|
234
224
|
get children() {
|
|
235
225
|
return [_$createComponent(EnumDeclaration, {
|
|
236
226
|
type: TestEnum
|
|
@@ -238,21 +228,20 @@ it("renders a class with enum members", async () => {
|
|
|
238
228
|
type: TestModel
|
|
239
229
|
})];
|
|
240
230
|
}
|
|
241
|
-
}))
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
`);
|
|
231
|
+
})).toRenderTo(`
|
|
232
|
+
namespace TestNamespace
|
|
233
|
+
{
|
|
234
|
+
enum TestEnum
|
|
235
|
+
{
|
|
236
|
+
Value1,
|
|
237
|
+
Value2
|
|
238
|
+
}
|
|
239
|
+
class TestModel
|
|
240
|
+
{
|
|
241
|
+
public required TestEnum Prop1 { get; set; }
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
`);
|
|
256
245
|
});
|
|
257
246
|
it("maps prop: string | null to nullable property", async () => {
|
|
258
247
|
const {
|
|
@@ -262,22 +251,21 @@ it("maps prop: string | null to nullable property", async () => {
|
|
|
262
251
|
prop1: string | null;
|
|
263
252
|
}
|
|
264
253
|
`);
|
|
265
|
-
|
|
254
|
+
expect(_$createComponent(Wrapper, {
|
|
266
255
|
get children() {
|
|
267
256
|
return _$createComponent(ClassDeclaration, {
|
|
268
257
|
type: TestModel
|
|
269
258
|
});
|
|
270
259
|
}
|
|
271
|
-
}))
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
`);
|
|
260
|
+
})).toRenderTo(`
|
|
261
|
+
namespace TestNamespace
|
|
262
|
+
{
|
|
263
|
+
class TestModel
|
|
264
|
+
{
|
|
265
|
+
public required string? Prop1 { get; set; }
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
`);
|
|
281
269
|
});
|
|
282
270
|
it("renders a class with string enums", async () => {
|
|
283
271
|
const {
|
|
@@ -292,7 +280,7 @@ it("renders a class with string enums", async () => {
|
|
|
292
280
|
@test prop1: TestEnum;
|
|
293
281
|
}
|
|
294
282
|
`);
|
|
295
|
-
|
|
283
|
+
expect(_$createComponent(Wrapper, {
|
|
296
284
|
get children() {
|
|
297
285
|
return [_$createComponent(EnumDeclaration, {
|
|
298
286
|
type: TestEnum
|
|
@@ -300,21 +288,20 @@ it("renders a class with string enums", async () => {
|
|
|
300
288
|
type: TestModel
|
|
301
289
|
})];
|
|
302
290
|
}
|
|
303
|
-
}))
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
`);
|
|
291
|
+
})).toRenderTo(`
|
|
292
|
+
namespace TestNamespace
|
|
293
|
+
{
|
|
294
|
+
enum TestEnum
|
|
295
|
+
{
|
|
296
|
+
Value1,
|
|
297
|
+
Value2
|
|
298
|
+
}
|
|
299
|
+
class TestModel
|
|
300
|
+
{
|
|
301
|
+
public required TestEnum Prop1 { get; set; }
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
`);
|
|
318
305
|
});
|
|
319
306
|
describe("with doc comments", () => {
|
|
320
307
|
it("renders a model with docs", async () => {
|
|
@@ -328,14 +315,13 @@ describe("with doc comments", () => {
|
|
|
328
315
|
}
|
|
329
316
|
|
|
330
317
|
`);
|
|
331
|
-
|
|
318
|
+
expect(_$createComponent(Wrapper, {
|
|
332
319
|
get children() {
|
|
333
320
|
return _$createComponent(ClassDeclaration, {
|
|
334
321
|
type: TestModel
|
|
335
322
|
});
|
|
336
323
|
}
|
|
337
|
-
}))
|
|
338
|
-
assertFileContents(res, d`
|
|
324
|
+
})).toRenderTo(`
|
|
339
325
|
namespace TestNamespace
|
|
340
326
|
{
|
|
341
327
|
/// <summary>
|
|
@@ -362,14 +348,13 @@ describe("with doc comments", () => {
|
|
|
362
348
|
op getName(id: string): string;
|
|
363
349
|
}
|
|
364
350
|
`);
|
|
365
|
-
|
|
351
|
+
expect(_$createComponent(Wrapper, {
|
|
366
352
|
get children() {
|
|
367
353
|
return _$createComponent(ClassDeclaration, {
|
|
368
354
|
type: TestInterface
|
|
369
355
|
});
|
|
370
356
|
}
|
|
371
|
-
}))
|
|
372
|
-
assertFileContents(res, d`
|
|
357
|
+
})).toRenderTo(`
|
|
373
358
|
namespace TestNamespace
|
|
374
359
|
{
|
|
375
360
|
/// <summary>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
2
|
import * as cs from "@alloy-js/csharp";
|
|
3
|
-
import { Enum, Union } from "@typespec/compiler";
|
|
3
|
+
import type { Enum, Union } from "@typespec/compiler";
|
|
4
4
|
export interface EnumDeclarationProps extends Omit<cs.EnumDeclarationProps, "name"> {
|
|
5
5
|
name?: string;
|
|
6
6
|
type: Union | Enum;
|
|
7
7
|
}
|
|
8
|
-
export declare function EnumDeclaration(props: EnumDeclarationProps):
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export declare function EnumDeclaration(props: EnumDeclarationProps): Children;
|
|
9
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/enum/declaration.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAO,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAKtD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,QAAQ,CA0CrE"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, mergeProps as _$mergeProps, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { useTsp } from "#core/context/tsp-context.js";
|
|
3
|
+
import { For } from "@alloy-js/core";
|
|
3
4
|
import * as cs from "@alloy-js/csharp";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { declarationRefkeys, efRefkey } from "./utils/refkey.js";
|
|
5
|
+
import { reportDiagnostic } from "../../../lib.js";
|
|
6
|
+
import { getDocComments } from "../utils/doc-comments.js";
|
|
7
|
+
import { declarationRefkeys, efRefkey } from "../utils/refkey.js";
|
|
8
8
|
export function EnumDeclaration(props) {
|
|
9
9
|
const {
|
|
10
10
|
$
|
|
@@ -32,7 +32,7 @@ export function EnumDeclaration(props) {
|
|
|
32
32
|
refkey: refkeys
|
|
33
33
|
}, props, {
|
|
34
34
|
get children() {
|
|
35
|
-
return _$createComponent(
|
|
35
|
+
return _$createComponent(For, {
|
|
36
36
|
each: members,
|
|
37
37
|
joiner: ",\n",
|
|
38
38
|
children: ([key, value]) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/csharp/components/enum/declaration.test.tsx"],"names":[],"mappings":""}
|