@alloy-js/csharp 0.19.0-dev.8 → 0.19.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog - @alloy-js/csharp
2
2
 
3
+ ## 0.19.0
4
+
5
+ ### Features
6
+
7
+ - [#246](https://github.com/alloy-framework/alloy/pull/246) Add support for `struct` declaration
8
+ - [#250](https://github.com/alloy-framework/alloy/pull/250) Fields support `new`, `readonly`, `static` and `volatile` modifier
9
+ - [#250](https://github.com/alloy-framework/alloy/pull/250) Private field respect c# naming convention of `_camelCase`
10
+ - [#251](https://github.com/alloy-framework/alloy/pull/251) Support `readonly`, `override` and `extern` modifier for `Method`
11
+ - [#247](https://github.com/alloy-framework/alloy/pull/247) Add support for expression body syntax in methods
12
+
13
+ ### Breaking Changes
14
+
15
+ - [#249](https://github.com/alloy-framework/alloy/pull/249) Rename `ClassMember` to `Field` to allow using it with `StructDeclaration`
16
+ - [#248](https://github.com/alloy-framework/alloy/pull/248) Rename `ClassConstructor` to `Constructor` to allow using it with `StructDeclaration`
17
+ - [#248](https://github.com/alloy-framework/alloy/pull/248) Rename `ClassMethod` to `Method` to allow using it with `StructDeclaration`
18
+
19
+
3
20
  ## 0.18.0
4
21
 
5
22
  ### Bug Fixes
@@ -9,6 +9,7 @@ import { Constructor } from "../src/components/stc/index.js";
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.js";
12
+ import { findFile } from "./utils.js";
12
13
  it("declares class with no members", () => {
13
14
  expect(_$createComponent(utils.TestNamespace, {
14
15
  get children() {
@@ -234,7 +235,7 @@ it("uses refkeys for members, params, and return type", () => {
234
235
  });
235
236
  }
236
237
  }));
237
- expect(res.contents[0].contents).toBe(coretest.d`
238
+ expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
238
239
  namespace TestCode
239
240
  {
240
241
  public enum TestEnum
@@ -4,6 +4,7 @@ import * as coretest from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as csharp from "../src/index.js";
6
6
  import * as utils from "./utils.js";
7
+ import { findFile } from "./utils.js";
7
8
  it("declares enum with no members", () => {
8
9
  const res = utils.toSourceText(_$createComponent(csharp.EnumDeclaration, {
9
10
  "public": true,
@@ -92,7 +93,7 @@ it("can reference things by refkey", () => {
92
93
  });
93
94
  }
94
95
  }));
95
- expect(res.contents[0].contents).toBe(coretest.d`
96
+ expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
96
97
  namespace TestCode
97
98
  {
98
99
  public enum TestEnum
@@ -150,8 +151,7 @@ it("can reference things by refkey across files", () => {
150
151
  });
151
152
  }
152
153
  }));
153
- expect(res.contents[0].path).toBe("Test.cs");
154
- expect(res.contents[0].contents).toBe(coretest.d`
154
+ expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
155
155
  namespace TestCode
156
156
  {
157
157
  public enum TestEnum
@@ -163,8 +163,7 @@ it("can reference things by refkey across files", () => {
163
163
  OtherEnum.Bar;
164
164
  }
165
165
  `);
166
- expect(res.contents[1].path).toBe("Other.cs");
167
- expect(res.contents[1].contents).toBe(coretest.d`
166
+ expect(findFile(res, "Other.cs").contents).toBe(coretest.d`
168
167
  namespace TestCode
169
168
  {
170
169
  public enum OtherEnum
@@ -1,8 +1,9 @@
1
1
  import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
3
  import * as coretest from "@alloy-js/core/testing";
4
- import { expect, it } from "vitest";
4
+ import { it } from "vitest";
5
5
  import * as csharp from "../src/index.js";
6
+ import { assertFileContents } from "./utils.js";
6
7
  it("defines multiple namespaces and source files with unique content", () => {
7
8
  const res = core.render(_$createComponent(core.Output, {
8
9
  get children() {
@@ -51,32 +52,30 @@ it("defines multiple namespaces and source files with unique content", () => {
51
52
  })];
52
53
  }
53
54
  }));
54
- expect(res.contents[0].path).equals("Model1.cs");
55
- expect(res.contents[0].contents).toBe(coretest.d`
56
- namespace Namespace1
57
- {
58
- public class Model1;
59
- }
60
- `);
61
- expect(res.contents[1].path).equals("Model2.cs");
62
- expect(res.contents[1].contents).toBe(coretest.d`
63
- namespace Namespace1
64
- {
65
- public class Model2;
66
- }
67
- `);
68
- expect(res.contents[2].path).equals("Model3.cs");
69
- expect(res.contents[2].contents).toBe(coretest.d`
70
- namespace Namespace2
71
- {
72
- public class Model3;
73
- }
74
- `);
75
- expect(res.contents[3].path).equals("Model4.cs");
76
- expect(res.contents[3].contents).toBe(coretest.d`
77
- namespace Namespace2
78
- {
79
- public class Model4;
80
- }
81
- `);
55
+ assertFileContents(res, {
56
+ "Model1.cs": coretest.d`
57
+ namespace Namespace1
58
+ {
59
+ public class Model1;
60
+ }
61
+ `,
62
+ "Model2.cs": coretest.d`
63
+ namespace Namespace1
64
+ {
65
+ public class Model2;
66
+ }
67
+ `,
68
+ "Model3.cs": coretest.d`
69
+ namespace Namespace2
70
+ {
71
+ public class Model3;
72
+ }
73
+ `,
74
+ "Model4.cs": coretest.d`
75
+ namespace Namespace2
76
+ {
77
+ public class Model4;
78
+ }
79
+ `
80
+ });
82
81
  });
@@ -3,6 +3,7 @@ import * as core from "@alloy-js/core";
3
3
  import * as coretest from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as csharp from "../src/index.js";
6
+ import { assertFileContents } from "./utils.js";
6
7
  it("defines multiple source files with unique content", () => {
7
8
  const res = core.render(_$createComponent(core.Output, {
8
9
  get children() {
@@ -30,20 +31,20 @@ it("defines multiple source files with unique content", () => {
30
31
  });
31
32
  }
32
33
  }));
33
- expect(res.contents[0].path).equals("Test1.cs");
34
- expect(res.contents[0].contents).toBe(coretest.d`
35
- namespace TestCode
36
- {
37
- public class TestClass1;
38
- }
39
- `);
40
- expect(res.contents[1].path).equals("Test2.cs");
41
- expect(res.contents[1].contents).toBe(coretest.d`
42
- namespace TestCode
43
- {
44
- public class TestClass2;
45
- }
46
- `);
34
+ assertFileContents(res, {
35
+ "Test1.cs": coretest.d`
36
+ namespace TestCode
37
+ {
38
+ public class TestClass1;
39
+ }
40
+ `,
41
+ "Test2.cs": coretest.d`
42
+ namespace TestCode
43
+ {
44
+ public class TestClass2;
45
+ }
46
+ `
47
+ });
47
48
  });
48
49
  it("throws when declaring a source file outside a namespace", () => {
49
50
  const decl = _$createComponent(core.Output, {
@@ -3,6 +3,7 @@ import * as core from "@alloy-js/core";
3
3
  import * as coretest from "@alloy-js/core/testing";
4
4
  import { expect, it } from "vitest";
5
5
  import * as csharp from "../src/index.js";
6
+ import { assertFileContents, findFile } from "./utils.js";
6
7
  it("uses a single namespace", () => {
7
8
  const res = core.render(_$createComponent(core.Output, {
8
9
  get children() {
@@ -17,7 +18,7 @@ it("uses a single namespace", () => {
17
18
  });
18
19
  }
19
20
  }));
20
- expect(res.contents[0].contents).toBe(coretest.d`
21
+ expect(findFile(res, "Test1.cs").contents).toBe(coretest.d`
21
22
  using Foo;
22
23
 
23
24
  namespace TestCode {}
@@ -37,7 +38,7 @@ it("uses multiple namespaces", () => {
37
38
  });
38
39
  }
39
40
  }));
40
- expect(res.contents[0].contents).toBe(coretest.d`
41
+ expect(findFile(res, "Test1.cs").contents).toBe(coretest.d`
41
42
  using Bar.Baz;
42
43
  using Foo;
43
44
 
@@ -111,29 +112,31 @@ it("adds using statement across namespaces", () => {
111
112
  })];
112
113
  }
113
114
  }));
114
- expect(res.contents[0].contents).toBe(coretest.d`
115
- namespace Models
116
- {
117
- public class Input;
118
- public class Output;
119
- public enum TestEnum
120
- {
121
- One,
122
- Two
123
- }
124
- }
125
- `);
126
- expect(res.contents[1].contents).toBe(coretest.d`
127
- using Models;
128
- using System;
115
+ assertFileContents(res, {
116
+ "Models.cs": coretest.d`
117
+ namespace Models
118
+ {
119
+ public class Input;
120
+ public class Output;
121
+ public enum TestEnum
122
+ {
123
+ One,
124
+ Two
125
+ }
126
+ }
127
+ `,
128
+ "Client.cs": coretest.d`
129
+ using Models;
130
+ using System;
129
131
 
130
- namespace Client
131
- {
132
- public class Client
133
- {
134
- public Output MethodOne(Input bodyParam) {}
135
- }
136
- TestEnum.Two;
137
- }
138
- `);
132
+ namespace Client
133
+ {
134
+ public class Client
135
+ {
136
+ public Output MethodOne(Input bodyParam) {}
137
+ }
138
+ TestEnum.Two;
139
+ }
140
+ `
141
+ });
139
142
  });
@@ -4,6 +4,6 @@ export declare function TestNamespace(props: {
4
4
  }): core.Children;
5
5
  export declare function toSourceText(c: core.Children): string;
6
6
  export declare function testRender(c: core.Children): core.OutputDirectory;
7
- export declare function findFile(res: core.OutputDirectory, path: string): core.OutputFile;
7
+ export declare function findFile(res: core.OutputDirectory, path: string): core.ContentOutputFile;
8
8
  export declare function assertFileContents(res: core.OutputDirectory, expectedFiles: Record<string, string>): void;
9
9
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAKvC,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;CACzB,GAAG,IAAI,CAAC,QAAQ,CAMhB;AACD,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAWrD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAMjE;AAED,wBAAgB,QAAQ,CACtB,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE,MAAM,GACX,IAAI,CAAC,UAAU,CA2BjB;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,IAAI,CAKN"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAKvC,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC;CACzB,GAAG,IAAI,CAAC,QAAQ,CAMhB;AACD,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,MAAM,CAWrD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAMjE;AAED,wBAAgB,QAAQ,CACtB,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE,MAAM,GACX,IAAI,CAAC,iBAAiB,CA2BxB;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,IAAI,CAKN"}