@alloy-js/csharp 0.19.0-dev.7 → 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.
@@ -9,6 +9,9 @@ export interface MethodModifiers {
9
9
  readonly sealed?: boolean;
10
10
  readonly static?: boolean;
11
11
  readonly virtual?: boolean;
12
+ readonly override?: boolean;
13
+ readonly extern?: boolean;
14
+ readonly readonly?: boolean;
12
15
  }
13
16
  export interface MethodProps extends AccessModifiers, MethodModifiers {
14
17
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"method.d.ts","sourceRoot":"","sources":["../../../../src/components/method/method.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKhB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAiB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAc,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAUD,MAAM,WAAW,WAAY,SAAQ,eAAe,EAAE,eAAe;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,O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E,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;IAEjD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAGD,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,YAoDxC"}
@@ -12,7 +12,7 @@ import { TypeParameters } from "../type-parameters/type-parameters.js";
12
12
 
13
13
  /** Method modifiers. Can only be one. */
14
14
 
15
- const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
15
+ const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual", "override", "extern", "readonly"]);
16
16
 
17
17
  // properties for creating a method
18
18
 
@@ -62,7 +62,11 @@ export function Method(props) {
62
62
  get parameters() {
63
63
  return props.typeParameters;
64
64
  }
65
- })), _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$memo(() => !!props.expression)() ? [" => ", _$memo(() => props.children)] : _$createComponent(Block, {
65
+ })), _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$memo(() => !!props.expression)() ? _$createComponent(ExpressionBody, {
66
+ get children() {
67
+ return props.children;
68
+ }
69
+ }) : _$createComponent(Block, {
66
70
  newline: true,
67
71
  get children() {
68
72
  return props.children;
@@ -72,4 +76,7 @@ export function Method(props) {
72
76
  });
73
77
  }
74
78
  });
75
- }
79
+ }
80
+ const ExpressionBody = props => {
81
+ return [" => ", _$memo(() => props.children), ";"];
82
+ };
@@ -169,7 +169,7 @@ it("use expression body form", () => {
169
169
  name: "Method",
170
170
  doc: "This is a test",
171
171
  expression: true,
172
- children: "this.MyProperty.Value;"
172
+ children: "this.MyProperty.Value"
173
173
  });
174
174
  }
175
175
  });
@@ -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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