@alloy-js/csharp 0.20.0 → 0.21.0-dev.1

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 (39) hide show
  1. package/dist/src/components/index.d.ts +1 -1
  2. package/dist/src/components/index.d.ts.map +1 -1
  3. package/dist/src/components/index.js +1 -1
  4. package/dist/src/components/index.js.map +1 -1
  5. package/dist/src/components/source-file/source-file.js +2 -2
  6. package/dist/src/components/source-file/source-file.js.map +1 -1
  7. package/dist/src/components/source-file/using.test.d.ts.map +1 -0
  8. package/dist/{test → src/components/source-file}/using.test.js +30 -49
  9. package/dist/src/components/source-file/using.test.js.map +1 -0
  10. package/dist/src/components/stc/index.d.ts +1 -1
  11. package/dist/src/components/stc/index.d.ts.map +1 -1
  12. package/dist/src/components/stc/index.js +1 -1
  13. package/dist/src/components/stc/index.js.map +1 -1
  14. package/dist/src/components/using/using.d.ts +28 -0
  15. package/dist/src/components/using/using.d.ts.map +1 -0
  16. package/dist/src/components/using/using.js +37 -0
  17. package/dist/src/components/using/using.js.map +1 -0
  18. package/dist/src/components/using/using.test.d.ts +2 -0
  19. package/dist/src/components/using/using.test.d.ts.map +1 -0
  20. package/dist/src/components/using/using.test.js +19 -0
  21. package/dist/src/components/using/using.test.js.map +1 -0
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +6 -6
  24. package/src/components/index.ts +1 -1
  25. package/src/components/source-file/source-file.tsx +2 -2
  26. package/src/components/source-file/using.test.tsx +94 -0
  27. package/src/components/stc/index.ts +1 -1
  28. package/src/components/using/using.test.tsx +15 -0
  29. package/src/components/using/using.tsx +52 -0
  30. package/temp/api.json +110 -15
  31. package/dist/src/components/UsingDirective.d.ts +0 -10
  32. package/dist/src/components/UsingDirective.d.ts.map +0 -1
  33. package/dist/src/components/UsingDirective.js +0 -15
  34. package/dist/src/components/UsingDirective.js.map +0 -1
  35. package/dist/test/using.test.d.ts.map +0 -1
  36. package/dist/test/using.test.js.map +0 -1
  37. package/src/components/UsingDirective.tsx +0 -28
  38. package/test/using.test.tsx +0 -118
  39. /package/dist/{test → src/components/source-file}/using.test.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alloy-js/csharp",
3
- "version": "0.20.0",
3
+ "version": "0.21.0-dev.1",
4
4
  "description": "Alloy components for CSharp language.",
5
5
  "exports": {
6
6
  ".": {
@@ -20,19 +20,19 @@
20
20
  "author": "jhendrix@microsoft.com",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
+ "@alloy-js/core": "~0.20.0 || >= 0.21.0-dev.0",
23
24
  "change-case": "^5.4.4",
24
25
  "marked": "^16.1.1",
25
- "pathe": "^2.0.3",
26
- "@alloy-js/core": "~0.20.0"
26
+ "pathe": "^2.0.3"
27
27
  },
28
28
  "devDependencies": {
29
+ "@alloy-js/cli": "~0.20.0 || >= 0.21.0-dev.0",
30
+ "@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.0",
29
31
  "@microsoft/api-extractor": "~7.52.8",
30
32
  "@rollup/plugin-typescript": "^12.1.2",
31
33
  "concurrently": "^9.2.0",
32
34
  "typescript": "^5.8.3",
33
- "vitest": "^3.2.4",
34
- "@alloy-js/cli": "~0.20.0",
35
- "@alloy-js/rollup-plugin": "~0.1.0"
35
+ "vitest": "^3.2.4"
36
36
  },
37
37
  "type": "module",
38
38
  "scripts": {
@@ -24,5 +24,5 @@ export * from "./Reference.js";
24
24
  export * from "./source-file/source-file.jsx";
25
25
  export * from "./struct/declaration.jsx";
26
26
  export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
27
- export * from "./UsingDirective.js";
27
+ export * from "./using/using.jsx";
28
28
  export * from "./var/declaration.jsx";
@@ -1,6 +1,6 @@
1
1
  import { NamespaceScopes } from "#components/namespace-scopes.jsx";
2
2
  import { Reference } from "#components/Reference.jsx";
3
- import { UsingDirective } from "#components/UsingDirective.jsx";
3
+ import { Usings } from "#components/using/using.jsx";
4
4
  import {
5
5
  Block,
6
6
  Children,
@@ -70,7 +70,7 @@ export function SourceFile(props: SourceFileProps) {
70
70
  {(sourceFileScope.usings.size > 0 ||
71
71
  (props.using && props.using.length > 0)) && (
72
72
  <>
73
- <UsingDirective namespaces={usings.value} />
73
+ <Usings namespaces={usings.value} />
74
74
  <hbr />
75
75
  <hbr />
76
76
  </>
@@ -0,0 +1,94 @@
1
+ import { ClassDeclaration } from "#components/class/declaration.jsx";
2
+ import { EnumDeclaration } from "#components/enum/declaration.jsx";
3
+ import { EnumMember } from "#components/enum/member.jsx";
4
+ import { Method } from "#components/method/method.jsx";
5
+ import { Namespace } from "#components/namespace.jsx";
6
+ import { SourceFile } from "#components/source-file/source-file.jsx";
7
+ import { Output, refkey } from "@alloy-js/core";
8
+ import * as coretest from "@alloy-js/core/testing";
9
+ import { expect, it } from "vitest";
10
+ import { createCSharpNamePolicy } from "../../name-policy.js";
11
+
12
+ it("using on source file are placed above file namespace statement", () => {
13
+ expect(
14
+ <Output>
15
+ <Namespace name="TestCode">
16
+ <SourceFile path="Test1.cs" using={["Foo"]} />
17
+ </Namespace>
18
+ </Output>,
19
+ ).toRenderTo(`
20
+ using Foo;
21
+
22
+ namespace TestCode;
23
+
24
+
25
+ `);
26
+ });
27
+
28
+ it("adds using statement across namespaces", () => {
29
+ const inputTypeRefkey = refkey();
30
+ const outputTypeRefkey = refkey();
31
+ const twoValRefkey = refkey();
32
+
33
+ const params = [
34
+ {
35
+ name: "BodyParam",
36
+ type: inputTypeRefkey,
37
+ },
38
+ ];
39
+
40
+ expect(
41
+ <Output namePolicy={createCSharpNamePolicy()}>
42
+ <Namespace name="Models">
43
+ <SourceFile path="Models.cs">
44
+ <ClassDeclaration public name="Input" refkey={inputTypeRefkey} />
45
+ <hbr />
46
+ <ClassDeclaration public name="Output" refkey={outputTypeRefkey} />
47
+ <hbr />
48
+ <EnumDeclaration public name="TestEnum">
49
+ <EnumMember name="One" />,<hbr />
50
+ <EnumMember name="Two" refkey={twoValRefkey} />
51
+ </EnumDeclaration>
52
+ </SourceFile>
53
+ </Namespace>
54
+ <Namespace name="Client">
55
+ <SourceFile path="Client.cs" using={["System"]}>
56
+ <ClassDeclaration public name="Client">
57
+ <Method
58
+ public
59
+ name="MethodOne"
60
+ parameters={params}
61
+ returns={outputTypeRefkey}
62
+ />
63
+ </ClassDeclaration>
64
+ <hbr />
65
+ {twoValRefkey};
66
+ </SourceFile>
67
+ </Namespace>
68
+ </Output>,
69
+ ).toRenderTo({
70
+ "Models.cs": coretest.d`
71
+ namespace Models;
72
+
73
+ public class Input;
74
+ public class Output;
75
+ public enum TestEnum
76
+ {
77
+ One,
78
+ Two
79
+ }
80
+ `,
81
+ "Client.cs": coretest.d`
82
+ using Models;
83
+ using System;
84
+
85
+ namespace Client;
86
+
87
+ public class Client
88
+ {
89
+ public Output MethodOne(Input bodyParam) {}
90
+ }
91
+ TestEnum.Two;
92
+ `,
93
+ });
94
+ });
@@ -10,5 +10,5 @@ export const EnumMember = core.stc(base.EnumMember);
10
10
  export const Parameter = core.stc(base.Parameter);
11
11
  export const Parameters = core.stc(base.Parameters);
12
12
  export const ProjectDirectory = core.stc(base.ProjectDirectory);
13
- export const UsingDirective = core.stc(base.UsingDirective);
13
+ export const UsingDirective = core.stc(base.Usings);
14
14
  export const StructDeclaration = core.stc(base.StructDeclaration);
@@ -0,0 +1,15 @@
1
+ import { expect, it } from "vitest";
2
+ import { Usings } from "./using.jsx";
3
+
4
+ it("single using", () => {
5
+ expect(<Usings namespaces={["Foo"]} />).toRenderTo(`
6
+ using Foo;
7
+ `);
8
+ });
9
+
10
+ it("multiple using", () => {
11
+ expect(<Usings namespaces={["Foo", "Bar"]} />).toRenderTo(`
12
+ using Bar;
13
+ using Foo;
14
+ `);
15
+ });
@@ -0,0 +1,52 @@
1
+ import { computed, For } from "@alloy-js/core";
2
+ import { NamespaceSymbol } from "../../symbols/namespace.js";
3
+
4
+ export interface UsingsProps {
5
+ /**
6
+ * Namespace symbols or namespace names to use to generate using statements.
7
+ */
8
+ namespaces: (NamespaceSymbol | string)[];
9
+ }
10
+
11
+ /**
12
+ * Component rendering csharp using directive
13
+ * @example
14
+ *
15
+ * ```tsx
16
+ * <Usings namespaces={["System", "Models"]} />
17
+ * ```
18
+ *
19
+ * will render
20
+ *
21
+ * ```csharp
22
+ * using Models;
23
+ * using System;
24
+ * ```
25
+ */
26
+ export function Usings(props: UsingsProps) {
27
+ const sortedNamespaces = computed(() => {
28
+ return props.namespaces
29
+ .map(getNamespaceName)
30
+ .sort((n1, n2) => n1.localeCompare(n2));
31
+ });
32
+
33
+ return (
34
+ <For each={sortedNamespaces}>
35
+ {(namespace) => <UsingNamespaceDirective namespace={namespace} />}
36
+ </For>
37
+ );
38
+ }
39
+
40
+ export interface UsingNamespaceDirective {
41
+ namespace: string;
42
+ }
43
+
44
+ export function UsingNamespaceDirective(props: UsingNamespaceDirective) {
45
+ return `using ${getNamespaceName(props.namespace)};`;
46
+ }
47
+
48
+ function getNamespaceName(namespace: string | NamespaceSymbol): string {
49
+ return typeof namespace === "string" ? namespace : (
50
+ namespace.getFullyQualifiedName({ omitGlobal: true })
51
+ );
52
+ }
package/temp/api.json CHANGED
@@ -13436,25 +13436,120 @@
13436
13436
  },
13437
13437
  {
13438
13438
  "kind": "Function",
13439
- "canonicalReference": "@alloy-js/csharp!UsingDirective:function(1)",
13439
+ "canonicalReference": "@alloy-js/csharp!UsingNamespaceDirective:function(1)",
13440
13440
  "docComment": "",
13441
13441
  "excerptTokens": [
13442
13442
  {
13443
13443
  "kind": "Content",
13444
- "text": "export declare function UsingDirective(props: "
13444
+ "text": "export declare function UsingNamespaceDirective(props: "
13445
13445
  },
13446
13446
  {
13447
13447
  "kind": "Reference",
13448
- "text": "UsingDirectiveProps",
13449
- "canonicalReference": "@alloy-js/csharp!UsingDirectiveProps:interface"
13448
+ "text": "UsingNamespaceDirective",
13449
+ "canonicalReference": "@alloy-js/csharp!UsingNamespaceDirective:interface"
13450
13450
  },
13451
13451
  {
13452
13452
  "kind": "Content",
13453
13453
  "text": "): "
13454
13454
  },
13455
+ {
13456
+ "kind": "Content",
13457
+ "text": "string"
13458
+ },
13459
+ {
13460
+ "kind": "Content",
13461
+ "text": ";"
13462
+ }
13463
+ ],
13464
+ "fileUrlPath": "src/components/using/using.tsx",
13465
+ "returnTypeTokenRange": {
13466
+ "startIndex": 3,
13467
+ "endIndex": 4
13468
+ },
13469
+ "releaseTag": "Public",
13470
+ "overloadIndex": 1,
13471
+ "parameters": [
13472
+ {
13473
+ "parameterName": "props",
13474
+ "parameterTypeTokenRange": {
13475
+ "startIndex": 1,
13476
+ "endIndex": 2
13477
+ },
13478
+ "isOptional": false
13479
+ }
13480
+ ],
13481
+ "name": "UsingNamespaceDirective"
13482
+ },
13483
+ {
13484
+ "kind": "Interface",
13485
+ "canonicalReference": "@alloy-js/csharp!UsingNamespaceDirective:interface",
13486
+ "docComment": "",
13487
+ "excerptTokens": [
13488
+ {
13489
+ "kind": "Content",
13490
+ "text": "export interface UsingNamespaceDirective "
13491
+ }
13492
+ ],
13493
+ "fileUrlPath": "src/components/using/using.tsx",
13494
+ "releaseTag": "Public",
13495
+ "name": "UsingNamespaceDirective",
13496
+ "preserveMemberOrder": false,
13497
+ "members": [
13498
+ {
13499
+ "kind": "PropertySignature",
13500
+ "canonicalReference": "@alloy-js/csharp!UsingNamespaceDirective#namespace:member",
13501
+ "docComment": "",
13502
+ "excerptTokens": [
13503
+ {
13504
+ "kind": "Content",
13505
+ "text": "namespace: "
13506
+ },
13507
+ {
13508
+ "kind": "Content",
13509
+ "text": "string"
13510
+ },
13511
+ {
13512
+ "kind": "Content",
13513
+ "text": ";"
13514
+ }
13515
+ ],
13516
+ "isReadonly": false,
13517
+ "isOptional": false,
13518
+ "releaseTag": "Public",
13519
+ "name": "namespace",
13520
+ "propertyTypeTokenRange": {
13521
+ "startIndex": 1,
13522
+ "endIndex": 2
13523
+ }
13524
+ }
13525
+ ],
13526
+ "extendsTokenRanges": []
13527
+ },
13528
+ {
13529
+ "kind": "Function",
13530
+ "canonicalReference": "@alloy-js/csharp!Usings:function(1)",
13531
+ "docComment": "/**\n * Component rendering csharp using directive\n *\n * @example\n *\n *\n *\n * ```tsx\n * <Usings namespaces={[\"System\", \"Models\"]} />\n * ```\n *\n *\n * will render\n *\n * ```csharp\n * using Models;\n * using System;\n * ```\n *\n */\n",
13532
+ "excerptTokens": [
13533
+ {
13534
+ "kind": "Content",
13535
+ "text": "export declare function Usings(props: "
13536
+ },
13455
13537
  {
13456
13538
  "kind": "Reference",
13457
- "text": "core.Children",
13539
+ "text": "UsingsProps",
13540
+ "canonicalReference": "@alloy-js/csharp!UsingsProps:interface"
13541
+ },
13542
+ {
13543
+ "kind": "Content",
13544
+ "text": "): "
13545
+ },
13546
+ {
13547
+ "kind": "Content",
13548
+ "text": "import(\"@alloy-js/core\")."
13549
+ },
13550
+ {
13551
+ "kind": "Reference",
13552
+ "text": "Children",
13458
13553
  "canonicalReference": "@alloy-js/core!Children:type"
13459
13554
  },
13460
13555
  {
@@ -13462,10 +13557,10 @@
13462
13557
  "text": ";"
13463
13558
  }
13464
13559
  ],
13465
- "fileUrlPath": "src/components/UsingDirective.tsx",
13560
+ "fileUrlPath": "src/components/using/using.tsx",
13466
13561
  "returnTypeTokenRange": {
13467
13562
  "startIndex": 3,
13468
- "endIndex": 4
13563
+ "endIndex": 5
13469
13564
  },
13470
13565
  "releaseTag": "Public",
13471
13566
  "overloadIndex": 1,
@@ -13479,31 +13574,31 @@
13479
13574
  "isOptional": false
13480
13575
  }
13481
13576
  ],
13482
- "name": "UsingDirective"
13577
+ "name": "Usings"
13483
13578
  },
13484
13579
  {
13485
13580
  "kind": "Interface",
13486
- "canonicalReference": "@alloy-js/csharp!UsingDirectiveProps:interface",
13581
+ "canonicalReference": "@alloy-js/csharp!UsingsProps:interface",
13487
13582
  "docComment": "",
13488
13583
  "excerptTokens": [
13489
13584
  {
13490
13585
  "kind": "Content",
13491
- "text": "export interface UsingDirectiveProps "
13586
+ "text": "export interface UsingsProps "
13492
13587
  }
13493
13588
  ],
13494
- "fileUrlPath": "src/components/UsingDirective.tsx",
13589
+ "fileUrlPath": "src/components/using/using.tsx",
13495
13590
  "releaseTag": "Public",
13496
- "name": "UsingDirectiveProps",
13591
+ "name": "UsingsProps",
13497
13592
  "preserveMemberOrder": false,
13498
13593
  "members": [
13499
13594
  {
13500
13595
  "kind": "PropertySignature",
13501
- "canonicalReference": "@alloy-js/csharp!UsingDirectiveProps#namespaces:member",
13596
+ "canonicalReference": "@alloy-js/csharp!UsingsProps#namespaces:member",
13502
13597
  "docComment": "/**\n * Namespace symbols or namespace names to use to generate using statements.\n */\n",
13503
13598
  "excerptTokens": [
13504
13599
  {
13505
13600
  "kind": "Content",
13506
- "text": "namespaces?: "
13601
+ "text": "namespaces: "
13507
13602
  },
13508
13603
  {
13509
13604
  "kind": "Content",
@@ -13524,7 +13619,7 @@
13524
13619
  }
13525
13620
  ],
13526
13621
  "isReadonly": false,
13527
- "isOptional": true,
13622
+ "isOptional": false,
13528
13623
  "releaseTag": "Public",
13529
13624
  "name": "namespaces",
13530
13625
  "propertyTypeTokenRange": {
@@ -1,10 +0,0 @@
1
- import * as core from "@alloy-js/core";
2
- import { NamespaceSymbol } from "../symbols/namespace.js";
3
- export interface UsingDirectiveProps {
4
- /**
5
- * Namespace symbols or namespace names to use to generate using statements.
6
- */
7
- namespaces?: (NamespaceSymbol | string)[];
8
- }
9
- export declare function UsingDirective(props: UsingDirectiveProps): core.Children;
10
- //# sourceMappingURL=UsingDirective.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UsingDirective.d.ts","sourceRoot":"","sources":["../../../src/components/UsingDirective.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC;CAC3C;AAGD,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,iBAgBxD"}
@@ -1,15 +0,0 @@
1
- import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
- import * as core from "@alloy-js/core";
3
- // one ore more C# using directives
4
- export function UsingDirective(props) {
5
- const sortedNamespaces = core.computed(() => {
6
- return props.namespaces.map(ns => typeof ns === "string" ? ns : ns.getFullyQualifiedName({
7
- omitGlobal: true
8
- })).sort((n1, n2) => n1.localeCompare(n2));
9
- });
10
- return _$createComponent(core.For, {
11
- each: sortedNamespaces,
12
- children: namespace => `using ${namespace};`
13
- });
14
- }
15
- //# sourceMappingURL=UsingDirective.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["core","UsingDirective","props","sortedNamespaces","computed","namespaces","map","ns","getFullyQualifiedName","omitGlobal","sort","n1","n2","localeCompare","_$createComponent","For","each","children","namespace"],"sources":["../../../src/components/UsingDirective.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,IAAI,MAAM,gBAAgB;AAUtC;AACA,OAAO,SAASC,cAAcA,CAACC,KAA0B,EAAE;EACzD,MAAMC,gBAAgB,GAAGH,IAAI,CAACI,QAAQ,CAAC,MAAM;IAC3C,OAAOF,KAAK,CACTG,UAAU,CAAEC,GAAG,CAAEC,EAAE,IAClB,OAAOA,EAAE,KAAK,QAAQ,GAAGA,EAAE,GACzBA,EAAE,CAACC,qBAAqB,CAAC;MAAEC,UAAU,EAAE;IAAK,CAAC,CAEjD,CAAC,CACAC,IAAI,CAAC,CAACC,EAAE,EAAEC,EAAE,KAAKD,EAAE,CAACE,aAAa,CAACD,EAAE,CAAC,CAAC;EAC3C,CAAC,CAAC;EAEF,OAAAE,iBAAA,CACGd,IAAI,CAACe,GAAG;IAACC,IAAI,EAAEb,gBAAgB;IAAAc,QAAA,EAC5BC,SAAS,IAAK,SAASA,SAAS;EAAG;AAG3C","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"using.test.d.ts","sourceRoot":"","sources":["../../test/using.test.tsx"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"names":["core","coretest","expect","it","csharp","findFile","res","render","_$createComponent","Output","children","Namespace","name","SourceFile","path","using","contents","toBe","d","inputTypeRefkey","refkey","outputTypeRefkey","twoValRefkey","params","type","namePolicy","createCSharpNamePolicy","ClassDeclaration","_$createIntrinsic","EnumDeclaration","EnumMember","Method","parameters","returns","toRenderTo"],"sources":["../../test/using.test.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
@@ -1,28 +0,0 @@
1
- import * as core from "@alloy-js/core";
2
- import { NamespaceSymbol } from "../symbols/namespace.js";
3
-
4
- export interface UsingDirectiveProps {
5
- /**
6
- * Namespace symbols or namespace names to use to generate using statements.
7
- */
8
- namespaces?: (NamespaceSymbol | string)[];
9
- }
10
-
11
- // one ore more C# using directives
12
- export function UsingDirective(props: UsingDirectiveProps) {
13
- const sortedNamespaces = core.computed(() => {
14
- return props
15
- .namespaces!.map((ns) =>
16
- typeof ns === "string" ? ns : (
17
- ns.getFullyQualifiedName({ omitGlobal: true })
18
- ),
19
- )
20
- .sort((n1, n2) => n1.localeCompare(n2));
21
- });
22
-
23
- return (
24
- <core.For each={sortedNamespaces}>
25
- {(namespace) => `using ${namespace};`}
26
- </core.For>
27
- );
28
- }
@@ -1,118 +0,0 @@
1
- import * as core from "@alloy-js/core";
2
- import * as coretest from "@alloy-js/core/testing";
3
- import { expect, it } from "vitest";
4
- import * as csharp from "../src/index.js";
5
- import { findFile } from "./utils.jsx";
6
-
7
- it("uses a single namespace", () => {
8
- const res = core.render(
9
- <core.Output>
10
- <csharp.Namespace name="TestCode">
11
- <csharp.SourceFile path="Test1.cs" using={["Foo"]} />
12
- </csharp.Namespace>
13
- </core.Output>,
14
- );
15
-
16
- expect(findFile(res, "Test1.cs").contents).toBe(coretest.d`
17
- using Foo;
18
-
19
- namespace TestCode;
20
-
21
-
22
- `);
23
- });
24
-
25
- it("uses multiple namespaces", () => {
26
- const res = core.render(
27
- <core.Output>
28
- <csharp.Namespace name="TestCode">
29
- <csharp.SourceFile path="Test1.cs" using={["Foo", "Bar.Baz"]} />
30
- </csharp.Namespace>
31
- </core.Output>,
32
- );
33
-
34
- expect(findFile(res, "Test1.cs").contents).toBe(coretest.d`
35
- using Bar.Baz;
36
- using Foo;
37
-
38
- namespace TestCode;
39
-
40
-
41
- `);
42
- });
43
-
44
- it("adds using statement across namespaces", () => {
45
- const inputTypeRefkey = core.refkey();
46
- const outputTypeRefkey = core.refkey();
47
- const twoValRefkey = core.refkey();
48
-
49
- const params = [
50
- {
51
- name: "BodyParam",
52
- type: inputTypeRefkey,
53
- },
54
- ];
55
-
56
- expect(
57
- <core.Output namePolicy={csharp.createCSharpNamePolicy()}>
58
- <csharp.Namespace name="Models">
59
- <csharp.SourceFile path="Models.cs">
60
- <csharp.ClassDeclaration
61
- public
62
- name="Input"
63
- refkey={inputTypeRefkey}
64
- />
65
- <hbr />
66
- <csharp.ClassDeclaration
67
- public
68
- name="Output"
69
- refkey={outputTypeRefkey}
70
- />
71
- <hbr />
72
- <csharp.EnumDeclaration public name="TestEnum">
73
- <csharp.EnumMember name="One" />,<hbr />
74
- <csharp.EnumMember name="Two" refkey={twoValRefkey} />
75
- </csharp.EnumDeclaration>
76
- </csharp.SourceFile>
77
- </csharp.Namespace>
78
- <csharp.Namespace name="Client">
79
- <csharp.SourceFile path="Client.cs" using={["System"]}>
80
- <csharp.ClassDeclaration public name="Client">
81
- <csharp.Method
82
- public
83
- name="MethodOne"
84
- parameters={params}
85
- returns={outputTypeRefkey}
86
- />
87
- </csharp.ClassDeclaration>
88
- <hbr />
89
- {twoValRefkey};
90
- </csharp.SourceFile>
91
- </csharp.Namespace>
92
- </core.Output>,
93
- ).toRenderTo({
94
- "Models.cs": coretest.d`
95
- namespace Models;
96
-
97
- public class Input;
98
- public class Output;
99
- public enum TestEnum
100
- {
101
- One,
102
- Two
103
- }
104
- `,
105
- "Client.cs": coretest.d`
106
- using Models;
107
- using System;
108
-
109
- namespace Client;
110
-
111
- public class Client
112
- {
113
- public Output MethodOne(Input bodyParam) {}
114
- }
115
- TestEnum.Two;
116
- `,
117
- });
118
- });