@alloy-js/csharp 0.19.0-dev.8 → 0.19.0-dev.9
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/test/class-declaration.test.js +2 -1
- package/dist/test/enum.test.js +4 -5
- package/dist/test/namespace.test.js +28 -29
- package/dist/test/sourcefile.test.js +15 -14
- package/dist/test/using.test.js +29 -26
- package/dist/test/utils.d.ts +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/class-declaration.test.tsx +2 -1
- package/test/enum.test.tsx +4 -5
- package/test/namespace.test.tsx +28 -32
- package/test/project-directory.test.tsx +12 -6
- package/test/sourcefile.test.tsx +15 -15
- package/test/using.test.tsx +29 -27
- package/test/utils.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/csharp",
|
|
3
|
-
"version": "0.19.0-dev.
|
|
3
|
+
"version": "0.19.0-dev.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"author": "jhendrix@microsoft.com",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@alloy-js/core": "~0.18.2 || >= 0.19.0-dev.
|
|
17
|
+
"@alloy-js/core": "~0.18.2 || >= 0.19.0-dev.12",
|
|
18
18
|
"change-case": "^5.4.4",
|
|
19
19
|
"marked": "^15.0.12",
|
|
20
20
|
"pathe": "^2.0.3"
|
|
@@ -9,6 +9,7 @@ import { TypeParameterProps } from "../src/components/type-parameters/type-param
|
|
|
9
9
|
import * as csharp from "../src/index.js";
|
|
10
10
|
import { ClassDeclaration, Property, SourceFile } from "../src/index.js";
|
|
11
11
|
import * as utils from "./utils.jsx";
|
|
12
|
+
import { findFile } from "./utils.jsx";
|
|
12
13
|
|
|
13
14
|
it("declares class with no members", () => {
|
|
14
15
|
expect(
|
|
@@ -195,7 +196,7 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
195
196
|
</core.Output>,
|
|
196
197
|
);
|
|
197
198
|
|
|
198
|
-
expect(res.
|
|
199
|
+
expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
|
|
199
200
|
namespace TestCode
|
|
200
201
|
{
|
|
201
202
|
public enum TestEnum
|
package/test/enum.test.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import * as coretest from "@alloy-js/core/testing";
|
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import * as csharp from "../src/index.js";
|
|
5
5
|
import * as utils from "./utils.js";
|
|
6
|
+
import { findFile } from "./utils.js";
|
|
6
7
|
|
|
7
8
|
it("declares enum with no members", () => {
|
|
8
9
|
const res = utils.toSourceText(
|
|
@@ -77,7 +78,7 @@ it("can reference things by refkey", () => {
|
|
|
77
78
|
</core.Output>,
|
|
78
79
|
);
|
|
79
80
|
|
|
80
|
-
expect(res.
|
|
81
|
+
expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
|
|
81
82
|
namespace TestCode
|
|
82
83
|
{
|
|
83
84
|
public enum TestEnum
|
|
@@ -120,8 +121,7 @@ it("can reference things by refkey across files", () => {
|
|
|
120
121
|
</core.Output>,
|
|
121
122
|
);
|
|
122
123
|
|
|
123
|
-
expect(res.contents
|
|
124
|
-
expect(res.contents[0].contents).toBe(coretest.d`
|
|
124
|
+
expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
|
|
125
125
|
namespace TestCode
|
|
126
126
|
{
|
|
127
127
|
public enum TestEnum
|
|
@@ -134,8 +134,7 @@ it("can reference things by refkey across files", () => {
|
|
|
134
134
|
}
|
|
135
135
|
`);
|
|
136
136
|
|
|
137
|
-
expect(res.contents
|
|
138
|
-
expect(res.contents[1].contents).toBe(coretest.d`
|
|
137
|
+
expect(findFile(res, "Other.cs").contents).toBe(coretest.d`
|
|
139
138
|
namespace TestCode
|
|
140
139
|
{
|
|
141
140
|
public enum OtherEnum
|
package/test/namespace.test.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as core from "@alloy-js/core";
|
|
2
2
|
import * as coretest from "@alloy-js/core/testing";
|
|
3
|
-
import {
|
|
3
|
+
import { it } from "vitest";
|
|
4
4
|
import * as csharp from "../src/index.js";
|
|
5
|
+
import { assertFileContents } from "./utils.jsx";
|
|
5
6
|
|
|
6
7
|
it("defines multiple namespaces and source files with unique content", () => {
|
|
7
8
|
const res = core.render(
|
|
@@ -25,35 +26,30 @@ it("defines multiple namespaces and source files with unique content", () => {
|
|
|
25
26
|
</core.Output>,
|
|
26
27
|
);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
namespace Namespace2
|
|
55
|
-
{
|
|
56
|
-
public class Model4;
|
|
57
|
-
}
|
|
58
|
-
`);
|
|
29
|
+
assertFileContents(res, {
|
|
30
|
+
"Model1.cs": coretest.d`
|
|
31
|
+
namespace Namespace1
|
|
32
|
+
{
|
|
33
|
+
public class Model1;
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
"Model2.cs": coretest.d`
|
|
37
|
+
namespace Namespace1
|
|
38
|
+
{
|
|
39
|
+
public class Model2;
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
"Model3.cs": coretest.d`
|
|
43
|
+
namespace Namespace2
|
|
44
|
+
{
|
|
45
|
+
public class Model3;
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
"Model4.cs": coretest.d`
|
|
49
|
+
namespace Namespace2
|
|
50
|
+
{
|
|
51
|
+
public class Model4;
|
|
52
|
+
}
|
|
53
|
+
`,
|
|
54
|
+
});
|
|
59
55
|
});
|
|
@@ -30,7 +30,8 @@ it("defines a project directory file with multiple source files", () => {
|
|
|
30
30
|
expect(projDir.contents[0].path).equals(
|
|
31
31
|
"~/projects/TestProject/TestProject.csproj",
|
|
32
32
|
);
|
|
33
|
-
expect(projDir.contents[0].contents)
|
|
33
|
+
expect((projDir.contents[0] as core.ContentOutputFile).contents)
|
|
34
|
+
.toBe(coretest.d`
|
|
34
35
|
<Project Sdk="Microsoft.NET.Sdk">
|
|
35
36
|
<PropertyGroup>
|
|
36
37
|
<Version>0.1.0</Version>
|
|
@@ -43,7 +44,8 @@ it("defines a project directory file with multiple source files", () => {
|
|
|
43
44
|
const srcDir = projDir.contents[1] as core.OutputDirectory;
|
|
44
45
|
|
|
45
46
|
expect(srcDir.contents[0].path).equals("~/projects/TestProject/src/Test1.cs");
|
|
46
|
-
expect(srcDir.contents[0].contents)
|
|
47
|
+
expect((srcDir.contents[0] as core.ContentOutputFile).contents)
|
|
48
|
+
.toBe(coretest.d`
|
|
47
49
|
namespace TestCode
|
|
48
50
|
{
|
|
49
51
|
public class TestClass1;
|
|
@@ -51,7 +53,8 @@ it("defines a project directory file with multiple source files", () => {
|
|
|
51
53
|
`);
|
|
52
54
|
|
|
53
55
|
expect(srcDir.contents[1].path).equals("~/projects/TestProject/src/Test2.cs");
|
|
54
|
-
expect(srcDir.contents[1].contents)
|
|
56
|
+
expect((srcDir.contents[1] as core.ContentOutputFile).contents)
|
|
57
|
+
.toBe(coretest.d`
|
|
55
58
|
namespace TestCode
|
|
56
59
|
{
|
|
57
60
|
public class TestClass2;
|
|
@@ -87,7 +90,8 @@ it("defines a project directory file with multiple source files and a custom TFM
|
|
|
87
90
|
expect(projDir.contents[0].path).equals(
|
|
88
91
|
"~/projects/TestProject/TestProject.csproj",
|
|
89
92
|
);
|
|
90
|
-
expect(projDir.contents[0].contents)
|
|
93
|
+
expect((projDir.contents[0] as core.ContentOutputFile).contents)
|
|
94
|
+
.toBe(coretest.d`
|
|
91
95
|
<Project Sdk="Microsoft.NET.Sdk">
|
|
92
96
|
<PropertyGroup>
|
|
93
97
|
<Version>0.1.0</Version>
|
|
@@ -100,7 +104,8 @@ it("defines a project directory file with multiple source files and a custom TFM
|
|
|
100
104
|
const srcDir = projDir.contents[1] as core.OutputDirectory;
|
|
101
105
|
|
|
102
106
|
expect(srcDir.contents[0].path).equals("~/projects/TestProject/src/Test1.cs");
|
|
103
|
-
expect(srcDir.contents[0].contents)
|
|
107
|
+
expect((srcDir.contents[0] as core.ContentOutputFile).contents)
|
|
108
|
+
.toBe(coretest.d`
|
|
104
109
|
namespace TestCode
|
|
105
110
|
{
|
|
106
111
|
public class TestClass1;
|
|
@@ -108,7 +113,8 @@ it("defines a project directory file with multiple source files and a custom TFM
|
|
|
108
113
|
`);
|
|
109
114
|
|
|
110
115
|
expect(srcDir.contents[1].path).equals("~/projects/TestProject/src/Test2.cs");
|
|
111
|
-
expect(srcDir.contents[1].contents)
|
|
116
|
+
expect((srcDir.contents[1] as core.ContentOutputFile).contents)
|
|
117
|
+
.toBe(coretest.d`
|
|
112
118
|
namespace TestCode
|
|
113
119
|
{
|
|
114
120
|
public class TestClass2;
|
package/test/sourcefile.test.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import * as core from "@alloy-js/core";
|
|
|
2
2
|
import * as coretest from "@alloy-js/core/testing";
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import * as csharp from "../src/index.js";
|
|
5
|
+
import { assertFileContents } from "./utils.jsx";
|
|
5
6
|
|
|
6
7
|
it("defines multiple source files with unique content", () => {
|
|
7
8
|
const res = core.render(
|
|
@@ -17,21 +18,20 @@ it("defines multiple source files with unique content", () => {
|
|
|
17
18
|
</core.Output>,
|
|
18
19
|
);
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`);
|
|
21
|
+
assertFileContents(res, {
|
|
22
|
+
"Test1.cs": coretest.d`
|
|
23
|
+
namespace TestCode
|
|
24
|
+
{
|
|
25
|
+
public class TestClass1;
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
"Test2.cs": coretest.d`
|
|
29
|
+
namespace TestCode
|
|
30
|
+
{
|
|
31
|
+
public class TestClass2;
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
34
|
+
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
it("throws when declaring a source file outside a namespace", () => {
|
package/test/using.test.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import * as core from "@alloy-js/core";
|
|
|
2
2
|
import * as coretest from "@alloy-js/core/testing";
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import * as csharp from "../src/index.js";
|
|
5
|
+
import { assertFileContents, findFile } from "./utils.jsx";
|
|
5
6
|
|
|
6
7
|
it("uses a single namespace", () => {
|
|
7
8
|
const res = core.render(
|
|
@@ -12,7 +13,7 @@ it("uses a single namespace", () => {
|
|
|
12
13
|
</core.Output>,
|
|
13
14
|
);
|
|
14
15
|
|
|
15
|
-
expect(res.
|
|
16
|
+
expect(findFile(res, "Test1.cs").contents).toBe(coretest.d`
|
|
16
17
|
using Foo;
|
|
17
18
|
|
|
18
19
|
namespace TestCode {}
|
|
@@ -28,7 +29,7 @@ it("uses multiple namespaces", () => {
|
|
|
28
29
|
</core.Output>,
|
|
29
30
|
);
|
|
30
31
|
|
|
31
|
-
expect(res.
|
|
32
|
+
expect(findFile(res, "Test1.cs").contents).toBe(coretest.d`
|
|
32
33
|
using Bar.Baz;
|
|
33
34
|
using Foo;
|
|
34
35
|
|
|
@@ -87,30 +88,31 @@ it("adds using statement across namespaces", () => {
|
|
|
87
88
|
</core.Output>,
|
|
88
89
|
);
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
assertFileContents(res, {
|
|
92
|
+
"Models.cs": coretest.d`
|
|
93
|
+
namespace Models
|
|
94
|
+
{
|
|
95
|
+
public class Input;
|
|
96
|
+
public class Output;
|
|
97
|
+
public enum TestEnum
|
|
98
|
+
{
|
|
99
|
+
One,
|
|
100
|
+
Two
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`,
|
|
104
|
+
"Client.cs": coretest.d`
|
|
105
|
+
using Models;
|
|
106
|
+
using System;
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
namespace Client
|
|
109
|
+
{
|
|
110
|
+
public class Client
|
|
111
|
+
{
|
|
112
|
+
public Output MethodOne(Input bodyParam) {}
|
|
113
|
+
}
|
|
114
|
+
TestEnum.Two;
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
117
|
+
});
|
|
116
118
|
});
|
package/test/utils.tsx
CHANGED
|
@@ -36,13 +36,13 @@ export function testRender(c: core.Children): core.OutputDirectory {
|
|
|
36
36
|
export function findFile(
|
|
37
37
|
res: core.OutputDirectory,
|
|
38
38
|
path: string,
|
|
39
|
-
): core.
|
|
39
|
+
): core.ContentOutputFile {
|
|
40
40
|
const result = findFileWorker(res, path);
|
|
41
41
|
|
|
42
42
|
if (!result) {
|
|
43
43
|
throw new Error("Expected to find file " + path);
|
|
44
44
|
}
|
|
45
|
-
return result;
|
|
45
|
+
return result as core.ContentOutputFile;
|
|
46
46
|
|
|
47
47
|
function findFileWorker(
|
|
48
48
|
res: core.OutputDirectory,
|