@alloy-js/csharp 0.18.0-dev.6 → 0.18.0-dev.7

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 (43) hide show
  1. package/dist/src/components/ClassMethod.d.ts +9 -2
  2. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  3. package/dist/src/components/ClassMethod.js +5 -1
  4. package/dist/src/components/index.d.ts +3 -1
  5. package/dist/src/components/index.d.ts.map +1 -1
  6. package/dist/src/components/index.js +3 -1
  7. package/dist/src/components/interface/declaration.d.ts +32 -0
  8. package/dist/src/components/interface/declaration.d.ts.map +1 -0
  9. package/dist/src/components/interface/declaration.js +85 -0
  10. package/dist/src/components/interface/declaration.test.d.ts +2 -0
  11. package/dist/src/components/interface/declaration.test.d.ts.map +1 -0
  12. package/dist/src/components/interface/declaration.test.js +56 -0
  13. package/dist/src/components/interface/method.d.ts +16 -0
  14. package/dist/src/components/interface/method.d.ts.map +1 -0
  15. package/dist/src/components/interface/method.js +54 -0
  16. package/dist/src/components/interface/method.test.d.ts +2 -0
  17. package/dist/src/components/interface/method.test.d.ts.map +1 -0
  18. package/dist/src/components/interface/method.test.js +110 -0
  19. package/dist/src/components/interface/property.d.ts +19 -0
  20. package/dist/src/components/interface/property.d.ts.map +1 -0
  21. package/dist/src/components/interface/property.js +54 -0
  22. package/dist/src/components/interface/property.test.d.ts +2 -0
  23. package/dist/src/components/interface/property.test.d.ts.map +1 -0
  24. package/dist/src/components/interface/property.test.js +141 -0
  25. package/dist/src/modifiers.d.ts +0 -8
  26. package/dist/src/modifiers.d.ts.map +1 -1
  27. package/dist/src/modifiers.js +0 -4
  28. package/dist/src/name-policy.d.ts +1 -1
  29. package/dist/src/name-policy.d.ts.map +1 -1
  30. package/dist/src/name-policy.js +1 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +2 -2
  33. package/src/components/ClassMethod.tsx +19 -3
  34. package/src/components/index.ts +3 -1
  35. package/src/components/interface/declaration.test.tsx +45 -0
  36. package/src/components/interface/declaration.tsx +104 -0
  37. package/src/components/interface/method.test.tsx +104 -0
  38. package/src/components/interface/method.tsx +77 -0
  39. package/src/components/interface/property.test.tsx +122 -0
  40. package/src/components/interface/property.tsx +85 -0
  41. package/src/modifiers.ts +0 -15
  42. package/src/name-policy.ts +2 -0
  43. package/temp/api.json +607 -101
@@ -0,0 +1,141 @@
1
+ import { memo as _$memo, createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { describe, expect, it } from "vitest";
3
+ import { TestNamespace } from "../../../test/utils.js";
4
+ import { InterfaceDeclaration } from "./declaration.js";
5
+ import { InterfaceProperty } from "./property.js";
6
+ const Wrapper = props => _$createComponent(TestNamespace, {
7
+ get children() {
8
+ return _$createComponent(InterfaceDeclaration, {
9
+ "public": true,
10
+ name: "TestInterface",
11
+ get children() {
12
+ return props.children;
13
+ }
14
+ });
15
+ }
16
+ });
17
+ describe("modifiers", () => {
18
+ describe("access modifiers", () => {
19
+ it.each(["public", "private", "protected", "internal"])("%s", accessModifier => {
20
+ expect(_$createComponent(Wrapper, {
21
+ get children() {
22
+ return _$createComponent(InterfaceProperty, _$mergeProps({
23
+ [accessModifier]: true
24
+ }, {
25
+ name: "TestProp",
26
+ type: "string",
27
+ get: true
28
+ }));
29
+ }
30
+ })).toRenderTo(`
31
+ public interface TestInterface
32
+ {
33
+ ${accessModifier} string TestProp { get; }
34
+ }
35
+ `);
36
+ });
37
+ });
38
+ describe("method modifiers", () => {
39
+ it.each(["new"])("%s", methodModifier => {
40
+ expect(_$createComponent(Wrapper, {
41
+ get children() {
42
+ return _$createComponent(InterfaceProperty, _$mergeProps({
43
+ [methodModifier]: true
44
+ }, {
45
+ name: "TestProp",
46
+ type: "string",
47
+ get: true
48
+ }));
49
+ }
50
+ })).toRenderTo(`
51
+ public interface TestInterface
52
+ {
53
+ ${methodModifier} string TestProp { get; }
54
+ }
55
+ `);
56
+ });
57
+ });
58
+ it("combine modifiers", () => {
59
+ expect(_$createComponent(Wrapper, {
60
+ get children() {
61
+ return _$createComponent(InterfaceProperty, {
62
+ "public": true,
63
+ "new": true,
64
+ name: "TestProp",
65
+ type: "string",
66
+ get: true
67
+ });
68
+ }
69
+ })).toRenderTo(`
70
+ public interface TestInterface
71
+ {
72
+ public new string TestProp { get; }
73
+ }
74
+ `);
75
+ });
76
+ });
77
+ it("applies PascalCase naming policy", () => {
78
+ expect(_$createComponent(Wrapper, {
79
+ get children() {
80
+ return _$createComponent(InterfaceProperty, {
81
+ name: "test_prop",
82
+ type: "string",
83
+ get: true
84
+ });
85
+ }
86
+ })).toRenderTo(`
87
+ public interface TestInterface
88
+ {
89
+ string TestProp { get; }
90
+ }
91
+ `);
92
+ });
93
+ it("has getter only", () => {
94
+ expect(_$createComponent(Wrapper, {
95
+ get children() {
96
+ return _$createComponent(InterfaceProperty, {
97
+ name: "TestProp",
98
+ type: "string",
99
+ get: true
100
+ });
101
+ }
102
+ })).toRenderTo(`
103
+ public interface TestInterface
104
+ {
105
+ string TestProp { get; }
106
+ }
107
+ `);
108
+ });
109
+ it("has setter only", () => {
110
+ expect(_$createComponent(Wrapper, {
111
+ get children() {
112
+ return _$createComponent(InterfaceProperty, {
113
+ name: "TestProp",
114
+ type: "string",
115
+ set: true
116
+ });
117
+ }
118
+ })).toRenderTo(`
119
+ public interface TestInterface
120
+ {
121
+ string TestProp { set; }
122
+ }
123
+ `);
124
+ });
125
+ it("has getter and setter", () => {
126
+ expect(_$createComponent(Wrapper, {
127
+ get children() {
128
+ return _$createComponent(InterfaceProperty, {
129
+ name: "TestProp",
130
+ type: "string",
131
+ get: true,
132
+ set: true
133
+ });
134
+ }
135
+ })).toRenderTo(`
136
+ public interface TestInterface
137
+ {
138
+ string TestProp { get; set; }
139
+ }
140
+ `);
141
+ });
@@ -7,14 +7,6 @@ export interface AccessModifiers {
7
7
  readonly file?: boolean;
8
8
  }
9
9
  export declare const getAccessModifier: (data: AccessModifiers) => string;
10
- /** Method modifiers. Can only be one. */
11
- export interface MethodModifiers {
12
- readonly abstract?: boolean;
13
- readonly sealed?: boolean;
14
- readonly static?: boolean;
15
- readonly virtual?: boolean;
16
- }
17
- export declare const getMethodModifier: (data: MethodModifiers) => string;
18
10
  export declare function getAsyncModifier(async?: boolean): string;
19
11
  /** Resolve the modifier prefix */
20
12
  export declare function computeModifiersPrefix(modifiers: Array<string | undefined>): string;
@@ -1 +1 @@
1
- {"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../src/modifiers.ts"],"names":[],"mappings":"AAGA,yBAAyB;AACzB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,mCAM5B,CAAC;AAEH,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;AAED,eAAO,MAAM,iBAAiB,mCAK5B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAExD;AAED,kCAAkC;AAClC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACnC,MAAM,CAGR;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAC1C,MAAM,CAAC,YAMhB"}
1
+ {"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../../src/modifiers.ts"],"names":[],"mappings":"AAGA,yBAAyB;AACzB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,mCAM5B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAExD;AAED,kCAAkC;AAClC,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GACnC,MAAM,CAGR;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAC1C,MAAM,CAAC,YAMhB"}
@@ -4,10 +4,6 @@
4
4
  /** Access modifiers. */
5
5
 
6
6
  export const getAccessModifier = makeModifiers(["public", "protected", "private", "internal", "file"]);
7
-
8
- /** Method modifiers. Can only be one. */
9
-
10
- export const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
11
7
  export function getAsyncModifier(async) {
12
8
  return async ? "async" : "";
13
9
  }
@@ -1,5 +1,5 @@
1
1
  import * as core from "@alloy-js/core";
2
- export type CSharpElements = "class" | "constant" | "enum" | "enum-member" | "function" | "interface" | "class-member-private" | "class-member-public" | "class-method" | "parameter" | "type-parameter";
2
+ export type CSharpElements = "class" | "constant" | "enum" | "enum-member" | "function" | "interface" | "class-member-private" | "class-member-public" | "class-method" | "class-property" | "parameter" | "type-parameter";
3
3
  export declare function createCSharpNamePolicy(): core.NamePolicy<CSharpElements>;
4
4
  export declare function useCSharpNamePolicy(): core.NamePolicy<CSharpElements>;
5
5
  //# sourceMappingURL=name-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAIvC,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,GACV,WAAW,GACX,sBAAsB,GACtB,qBAAqB,GACrB,cAAc,GACd,WAAW,GACX,gBAAgB,CAAC;AAGrB,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAiBxE;AAGD,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAErE"}
1
+ {"version":3,"file":"name-policy.d.ts","sourceRoot":"","sources":["../../src/name-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAIvC,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,GACV,WAAW,GACX,sBAAsB,GACtB,qBAAqB,GACrB,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,gBAAgB,CAAC;AAGrB,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAkBxE;AAGD,wBAAgB,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAErE"}
@@ -14,6 +14,7 @@ export function createCSharpNamePolicy() {
14
14
  case "class-member-public":
15
15
  case "class-method":
16
16
  case "type-parameter":
17
+ case "class-property":
17
18
  return changecase.pascalCase(name);
18
19
  case "constant":
19
20
  return changecase.constantCase(name);