@alloy-js/csharp 0.18.0-dev.18 → 0.18.0-dev.2

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 (153) hide show
  1. package/dist/src/components/Class.d.ts +26 -0
  2. package/dist/src/components/Class.d.ts.map +1 -0
  3. package/dist/src/components/{ClassDeclaration.js → Class.js} +32 -59
  4. package/dist/src/components/ClassMethod.d.ts +4 -25
  5. package/dist/src/components/ClassMethod.d.ts.map +1 -1
  6. package/dist/src/components/ClassMethod.js +3 -22
  7. package/dist/src/components/Enum.d.ts +15 -0
  8. package/dist/src/components/Enum.d.ts.map +1 -0
  9. package/dist/src/components/{EnumDeclaration.js → Enum.js} +5 -25
  10. package/dist/src/components/Parameters.d.ts +1 -6
  11. package/dist/src/components/Parameters.d.ts.map +1 -1
  12. package/dist/src/components/Parameters.js +2 -3
  13. package/dist/src/components/index.d.ts +3 -12
  14. package/dist/src/components/index.d.ts.map +1 -1
  15. package/dist/src/components/index.js +4 -13
  16. package/dist/src/components/stc/index.d.ts +2 -2
  17. package/dist/src/components/stc/index.d.ts.map +1 -1
  18. package/dist/src/components/stc/index.js +2 -2
  19. package/dist/src/modifiers.d.ts +4 -10
  20. package/dist/src/modifiers.d.ts.map +1 -1
  21. package/dist/src/modifiers.js +32 -9
  22. package/dist/src/name-policy.d.ts +1 -1
  23. package/dist/src/name-policy.d.ts.map +1 -1
  24. package/dist/src/name-policy.js +0 -2
  25. package/dist/test/class-method.test.js +14 -37
  26. package/dist/test/class.test.d.ts +2 -0
  27. package/dist/test/class.test.d.ts.map +1 -0
  28. package/dist/test/class.test.js +298 -0
  29. package/dist/test/enum.test.js +12 -12
  30. package/dist/test/namespace.test.js +8 -8
  31. package/dist/test/projectdirectory.test.d.ts +2 -0
  32. package/dist/test/projectdirectory.test.d.ts.map +1 -0
  33. package/dist/test/{project-directory.test.js → projectdirectory.test.js} +8 -8
  34. package/dist/test/sourcefile.test.js +4 -4
  35. package/dist/test/using.test.js +9 -9
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +21 -21
  38. package/src/components/{ClassDeclaration.tsx → Class.tsx} +43 -108
  39. package/src/components/ClassMethod.tsx +12 -53
  40. package/src/components/{EnumDeclaration.tsx → Enum.tsx} +6 -30
  41. package/src/components/Parameters.tsx +3 -10
  42. package/src/components/index.ts +3 -12
  43. package/src/components/stc/index.ts +2 -2
  44. package/src/modifiers.ts +42 -25
  45. package/src/name-policy.ts +0 -5
  46. package/temp/api.json +714 -5256
  47. package/test/class-method.test.tsx +14 -24
  48. package/test/class.test.tsx +292 -0
  49. package/test/enum.test.tsx +11 -11
  50. package/test/namespace.test.tsx +4 -4
  51. package/test/{project-directory.test.tsx → projectdirectory.test.tsx} +4 -4
  52. package/test/sourcefile.test.tsx +2 -2
  53. package/test/using.test.tsx +9 -9
  54. package/vitest.config.ts +0 -3
  55. package/LICENSE +0 -7
  56. package/dist/src/components/ClassDeclaration.d.ts +0 -74
  57. package/dist/src/components/ClassDeclaration.d.ts.map +0 -1
  58. package/dist/src/components/EnumDeclaration.d.ts +0 -34
  59. package/dist/src/components/EnumDeclaration.d.ts.map +0 -1
  60. package/dist/src/components/doc/comment.d.ts +0 -70
  61. package/dist/src/components/doc/comment.d.ts.map +0 -1
  62. package/dist/src/components/doc/comment.js +0 -88
  63. package/dist/src/components/doc/comment.test.d.ts +0 -2
  64. package/dist/src/components/doc/comment.test.d.ts.map +0 -1
  65. package/dist/src/components/doc/comment.test.js +0 -348
  66. package/dist/src/components/doc/from-markdown.d.ts +0 -6
  67. package/dist/src/components/doc/from-markdown.d.ts.map +0 -1
  68. package/dist/src/components/doc/from-markdown.js +0 -58
  69. package/dist/src/components/doc/from-markdown.test.d.ts +0 -2
  70. package/dist/src/components/doc/from-markdown.test.d.ts.map +0 -1
  71. package/dist/src/components/doc/from-markdown.test.js +0 -83
  72. package/dist/src/components/interface/declaration.d.ts +0 -47
  73. package/dist/src/components/interface/declaration.d.ts.map +0 -1
  74. package/dist/src/components/interface/declaration.js +0 -77
  75. package/dist/src/components/interface/declaration.test.d.ts +0 -2
  76. package/dist/src/components/interface/declaration.test.d.ts.map +0 -1
  77. package/dist/src/components/interface/declaration.test.js +0 -153
  78. package/dist/src/components/interface/method.d.ts +0 -32
  79. package/dist/src/components/interface/method.d.ts.map +0 -1
  80. package/dist/src/components/interface/method.js +0 -69
  81. package/dist/src/components/interface/method.test.d.ts +0 -2
  82. package/dist/src/components/interface/method.test.d.ts.map +0 -1
  83. package/dist/src/components/interface/method.test.js +0 -254
  84. package/dist/src/components/interface/property.d.ts +0 -38
  85. package/dist/src/components/interface/property.d.ts.map +0 -1
  86. package/dist/src/components/interface/property.js +0 -67
  87. package/dist/src/components/interface/property.test.d.ts +0 -2
  88. package/dist/src/components/interface/property.test.d.ts.map +0 -1
  89. package/dist/src/components/interface/property.test.js +0 -165
  90. package/dist/src/components/property/property.d.ts +0 -57
  91. package/dist/src/components/property/property.d.ts.map +0 -1
  92. package/dist/src/components/property/property.js +0 -70
  93. package/dist/src/components/property/property.test.d.ts +0 -2
  94. package/dist/src/components/property/property.test.d.ts.map +0 -1
  95. package/dist/src/components/property/property.test.js +0 -218
  96. package/dist/src/components/record/declaration.d.ts +0 -35
  97. package/dist/src/components/record/declaration.d.ts.map +0 -1
  98. package/dist/src/components/record/declaration.js +0 -90
  99. package/dist/src/components/record/declaration.test.d.ts +0 -2
  100. package/dist/src/components/record/declaration.test.d.ts.map +0 -1
  101. package/dist/src/components/record/declaration.test.js +0 -94
  102. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts +0 -8
  103. package/dist/src/components/type-parameters/type-parameter-constraints.d.ts.map +0 -1
  104. package/dist/src/components/type-parameters/type-parameter-constraints.js +0 -44
  105. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts +0 -2
  106. package/dist/src/components/type-parameters/type-parameter-constraints.test.d.ts.map +0 -1
  107. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +0 -67
  108. package/dist/src/components/type-parameters/type-parameter.d.ts +0 -20
  109. package/dist/src/components/type-parameters/type-parameter.d.ts.map +0 -1
  110. package/dist/src/components/type-parameters/type-parameter.js +0 -22
  111. package/dist/src/components/type-parameters/type-parameters.d.ts +0 -17
  112. package/dist/src/components/type-parameters/type-parameters.d.ts.map +0 -1
  113. package/dist/src/components/type-parameters/type-parameters.js +0 -65
  114. package/dist/src/components/type-parameters/type-parameters.test.d.ts +0 -2
  115. package/dist/src/components/type-parameters/type-parameters.test.d.ts.map +0 -1
  116. package/dist/src/components/type-parameters/type-parameters.test.js +0 -26
  117. package/dist/src/components/var/declaration.d.ts +0 -35
  118. package/dist/src/components/var/declaration.d.ts.map +0 -1
  119. package/dist/src/components/var/declaration.js +0 -40
  120. package/dist/src/components/var/declaration.test.d.ts +0 -2
  121. package/dist/src/components/var/declaration.test.d.ts.map +0 -1
  122. package/dist/src/components/var/declaration.test.js +0 -73
  123. package/dist/test/class-declaration.test.d.ts +0 -2
  124. package/dist/test/class-declaration.test.d.ts.map +0 -1
  125. package/dist/test/class-declaration.test.js +0 -463
  126. package/dist/test/project-directory.test.d.ts +0 -2
  127. package/dist/test/project-directory.test.d.ts.map +0 -1
  128. package/dist/test/vitest.setup.d.ts +0 -2
  129. package/dist/test/vitest.setup.d.ts.map +0 -1
  130. package/dist/test/vitest.setup.js +0 -1
  131. package/src/components/doc/comment.test.tsx +0 -337
  132. package/src/components/doc/comment.tsx +0 -152
  133. package/src/components/doc/from-markdown.test.tsx +0 -103
  134. package/src/components/doc/from-markdown.tsx +0 -58
  135. package/src/components/interface/declaration.test.tsx +0 -143
  136. package/src/components/interface/declaration.tsx +0 -105
  137. package/src/components/interface/method.test.tsx +0 -250
  138. package/src/components/interface/method.tsx +0 -105
  139. package/src/components/interface/property.test.tsx +0 -144
  140. package/src/components/interface/property.tsx +0 -107
  141. package/src/components/property/property.test.tsx +0 -187
  142. package/src/components/property/property.tsx +0 -146
  143. package/src/components/record/declaration.test.tsx +0 -73
  144. package/src/components/record/declaration.tsx +0 -109
  145. package/src/components/type-parameters/type-parameter-constraints.test.tsx +0 -93
  146. package/src/components/type-parameters/type-parameter-constraints.tsx +0 -46
  147. package/src/components/type-parameters/type-parameter.tsx +0 -35
  148. package/src/components/type-parameters/type-parameters.test.tsx +0 -19
  149. package/src/components/type-parameters/type-parameters.tsx +0 -72
  150. package/src/components/var/declaration.test.tsx +0 -59
  151. package/src/components/var/declaration.tsx +0 -47
  152. package/test/class-declaration.test.tsx +0 -418
  153. package/test/vitest.setup.ts +0 -1
@@ -0,0 +1,26 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifier } from "../modifiers.js";
3
+ import { ParameterProps } from "./Parameters.js";
4
+ export interface ClassProps extends Omit<core.DeclarationProps, "nameKind"> {
5
+ name: string;
6
+ refkey?: core.Refkey;
7
+ accessModifier?: AccessModifier;
8
+ typeParameters?: Record<string, core.Refkey>;
9
+ }
10
+ export declare function Class(props: ClassProps): core.Children;
11
+ export interface ClassConstructorProps {
12
+ accessModifier?: AccessModifier;
13
+ parameters?: Array<ParameterProps>;
14
+ refkey?: core.Refkey;
15
+ symbol?: core.OutputSymbol;
16
+ children?: core.Children;
17
+ }
18
+ export declare function ClassConstructor(props: ClassConstructorProps): core.Children;
19
+ export interface ClassMemberProps {
20
+ name: string;
21
+ type: core.Children;
22
+ accessModifier?: AccessModifier;
23
+ refkey?: core.Refkey;
24
+ }
25
+ export declare function ClassMember(props: ClassMemberProps): core.Children;
26
+ //# sourceMappingURL=Class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Class.d.ts","sourceRoot":"","sources":["../../../src/components/Class.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AAKpE,OAAO,EAAE,cAAc,EAAc,MAAM,iBAAiB,CAAC;AAG7D,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;CAC9C;AAGD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,iBAoDtC;AAED,MAAM,WAAW,qBAAqB;IACpC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;IAC3B,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;CAC1B;AAGD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,iBAiC5D;AAGD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;CACtB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,iBAwBlD"}
@@ -1,44 +1,16 @@
1
- import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
1
+ import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
- import { join } from "@alloy-js/core";
4
- import { computeModifiersPrefix, getAccessModifier, makeModifiers } from "../modifiers.js";
3
+ import { getAccessModifier } from "../modifiers.js";
5
4
  import { useCSharpNamePolicy } from "../name-policy.js";
6
5
  import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
7
6
  import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
8
7
  import { Name } from "./Name.js";
9
8
  import { Parameters } from "./Parameters.js";
10
- import { DocWhen } from "./doc/comment.js";
11
- import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
12
- import { TypeParameters } from "./type-parameters/type-parameters.js";
13
- const getClassModifiers = makeModifiers(["abstract", "partial", "sealed", "static"]);
14
9
 
15
10
  // properties for creating a class
16
11
 
17
- /**
18
- * CSharp class declaration.
19
- * @example
20
- * ```tsx
21
- * <ClassDeclaration public name="MyClass">
22
- * <ClassMember public name="MyField" type="int" />
23
- * <ClassConstructor>
24
- * <Parameter name="value" type="int" />
25
- * this.MyField = value;
26
- * </ClassConstructor>
27
- * </ClassDeclaration>
28
- * ```
29
- * This will produce:
30
- * ```csharp
31
- * public class MyClass
32
- * {
33
- * public int MyField;
34
- * public MyClass(int value)
35
- * {
36
- * this.MyField = value;
37
- * }
38
- * }
39
- * ```
40
- */
41
- export function ClassDeclaration(props) {
12
+ // a C# class declaration
13
+ export function Class(props) {
42
14
  const name = useCSharpNamePolicy().getName(props.name, "class");
43
15
  const thisClassSymbol = new CSharpOutputSymbol(name, {
44
16
  refkeys: props.refkey
@@ -51,27 +23,33 @@ export function ClassDeclaration(props) {
51
23
  const thisClassScope = new CSharpMemberScope("class-decl", {
52
24
  owner: thisClassSymbol
53
25
  });
54
- const bases = [...(props.baseType ? [props.baseType] : []), ...(props.interfaceTypes || [])];
55
- const base = bases.length > 0 ? [" : ", _$memo(() => join(bases, {
56
- joiner: ", "
57
- }))] : null;
58
- const modifiers = computeModifiersPrefix([getAccessModifier(props), getClassModifiers(props)]);
26
+ let typeParams;
27
+ if (props.typeParameters) {
28
+ const typeParamNames = new Array();
29
+ for (const entry of Object.entries(props.typeParameters)) {
30
+ typeParamNames.push(useCSharpNamePolicy().getName(entry[0], "type-parameter"));
31
+ // create a symbol for each type param so its
32
+ // refkey resolves to the type param's name
33
+ new CSharpOutputSymbol(entry[0], {
34
+ scope: thisClassScope,
35
+ refkeys: entry[1]
36
+ });
37
+ }
38
+ typeParams = _$createIntrinsic("group", {
39
+ get children() {
40
+ return ["<", _$createComponent(core.For, {
41
+ each: typeParamNames,
42
+ comma: true,
43
+ line: true,
44
+ children: name => name
45
+ }), ">"];
46
+ }
47
+ });
48
+ }
59
49
  return _$createComponent(core.Declaration, {
60
50
  symbol: thisClassSymbol,
61
51
  get children() {
62
- return [_$createComponent(DocWhen, {
63
- get doc() {
64
- return props.doc;
65
- }
66
- }), modifiers, "class ", _$createComponent(Name, {}), _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
67
- get parameters() {
68
- return props.typeParameters;
69
- }
70
- })), base, _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
71
- get parameters() {
72
- return props.typeParameters;
73
- }
74
- })), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
52
+ return [_$memo(() => getAccessModifier(props.accessModifier)), "class ", _$createComponent(Name, {}), typeParams, _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Block, {
75
53
  newline: true,
76
54
  get children() {
77
55
  return _$createComponent(core.Scope, {
@@ -103,7 +81,7 @@ export function ClassConstructor(props) {
103
81
  const ctorDeclScope = new CSharpMemberScope("constructor-decl", {
104
82
  owner: ctorSymbol
105
83
  });
106
- const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
84
+ const accessModifier = getAccessModifier(props.accessModifier);
107
85
  const params = props.parameters ? _$createComponent(Parameters, {
108
86
  get parameters() {
109
87
  return props.parameters;
@@ -117,7 +95,7 @@ export function ClassConstructor(props) {
117
95
  return _$createComponent(core.Scope, {
118
96
  value: ctorDeclScope,
119
97
  get children() {
120
- return [modifiers, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
98
+ return [accessModifier, _$createComponent(Name, {}), "(", params, ")", _$createComponent(core.Block, {
121
99
  newline: true,
122
100
  get children() {
123
101
  return props.children;
@@ -134,7 +112,7 @@ export function ClassConstructor(props) {
134
112
  // a C# class member (i.e. a field within a class like "private int count")
135
113
  export function ClassMember(props) {
136
114
  let nameElement = "class-member-private";
137
- if (props.public) {
115
+ if (props.accessModifier === "public") {
138
116
  nameElement = "class-member-public";
139
117
  }
140
118
  const name = useCSharpNamePolicy().getName(props.name, nameElement);
@@ -146,15 +124,10 @@ export function ClassMember(props) {
146
124
  scope,
147
125
  refkeys: props.refkey ?? core.refkey(props.name)
148
126
  });
149
- const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
150
127
  return _$createComponent(core.Declaration, {
151
128
  symbol: memberSymbol,
152
129
  get children() {
153
- return [_$createComponent(DocWhen, {
154
- get doc() {
155
- return props.doc;
156
- }
157
- }), modifiers, _$memo(() => props.type), " ", _$createComponent(Name, {})];
130
+ return [_$memo(() => getAccessModifier(props.accessModifier)), _$memo(() => props.type), " ", _$createComponent(Name, {})];
158
131
  }
159
132
  });
160
133
  }
@@ -1,39 +1,18 @@
1
1
  import { Children, Refkey } from "@alloy-js/core";
2
- import { AccessModifiers } from "../modifiers.js";
2
+ import { AccessModifier, MethodModifier } from "../modifiers.js";
3
3
  import { ParameterProps } from "./Parameters.jsx";
4
- import { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
5
- /** Method modifiers. Can only be one. */
6
- export interface ClassMethodModifiers {
7
- readonly abstract?: boolean;
8
- readonly sealed?: boolean;
9
- readonly static?: boolean;
10
- readonly virtual?: boolean;
11
- }
12
- export interface ClassMethodProps extends AccessModifiers, ClassMethodModifiers {
4
+ export interface ClassMethodProps {
13
5
  name: string;
14
6
  refkey?: Refkey;
15
7
  children?: Children;
8
+ accessModifier?: AccessModifier;
9
+ methodModifier?: MethodModifier;
16
10
  parameters?: Array<ParameterProps>;
17
11
  returns?: Children;
18
12
  /**
19
13
  * If true, the method will be declared as an async method.
20
14
  */
21
15
  async?: boolean;
22
- /** Doc comment */
23
- doc?: Children;
24
- /**
25
- * Type parameters for the method
26
- *
27
- * @example
28
- * ```tsx
29
- * <InterfaceMethod name="Test" typeParameters={["T"]} />
30
- * ```
31
- * This will produce:
32
- * ```csharp
33
- * public void Test<T>()
34
- * ```
35
- */
36
- typeParameters?: (TypeParameterProps | string)[];
37
16
  }
38
17
  export declare function ClassMethod(props: ClassMethodProps): Children;
39
18
  //# sourceMappingURL=ClassMethod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EAKhB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAG9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,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,gBACf,SAAQ,eAAe,EACrB,oBAAoB;IACtB,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,OAAO,CAAC;IAEhB,kBAAkB;IAClB,GAAG,CAAC,EAAE,QAAQ,CAAC;IAEf;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC;CAClD;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YA4ClD"}
1
+ {"version":3,"file":"ClassMethod.d.ts","sourceRoot":"","sources":["../../../src/components/ClassMethod.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAGR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EAKd,cAAc,EACf,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAG9D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,YAsClD"}
@@ -1,17 +1,10 @@
1
1
  import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
2
  import { Block, MemberDeclaration, refkey, Scope } from "@alloy-js/core";
3
- import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, makeModifiers } from "../modifiers.js";
3
+ import { computeModifiersPrefix, getAccessModifier, getAsyncModifier, getMethodModifier } from "../modifiers.js";
4
4
  import { useCSharpNamePolicy } from "../name-policy.js";
5
5
  import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
6
6
  import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
7
7
  import { Parameters } from "./Parameters.js";
8
- import { DocWhen } from "./doc/comment.js";
9
- import { TypeParameterConstraints } from "./type-parameters/type-parameter-constraints.js";
10
- import { TypeParameters } from "./type-parameters/type-parameters.js";
11
-
12
- /** Method modifiers. Can only be one. */
13
-
14
- const getMethodModifier = makeModifiers(["abstract", "sealed", "static", "virtual"]);
15
8
 
16
9
  // properties for creating a method
17
10
 
@@ -37,7 +30,7 @@ export function ClassMethod(props) {
37
30
  }
38
31
  }) : "";
39
32
  const returns = props.returns ?? (props.async ? "Task" : "void");
40
- const modifiers = computeModifiersPrefix([getAccessModifier(props), getMethodModifier(props), getAsyncModifier(props.async)]);
33
+ const modifiers = computeModifiersPrefix([getAccessModifier(props.accessModifier), getMethodModifier(props.methodModifier), getAsyncModifier(props.async)]);
41
34
  // note that scope wraps the method decl so that the params get the correct scope
42
35
  return _$createComponent(MemberDeclaration, {
43
36
  symbol: methodSymbol,
@@ -45,19 +38,7 @@ export function ClassMethod(props) {
45
38
  return _$createComponent(Scope, {
46
39
  value: methodScope,
47
40
  get children() {
48
- return [_$createComponent(DocWhen, {
49
- get doc() {
50
- return props.doc;
51
- }
52
- }), modifiers, returns, " ", _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameters, {
53
- get parameters() {
54
- return props.typeParameters;
55
- }
56
- })), name, "(", params, ")", _$memo(() => _$memo(() => !!props.typeParameters)() && _$createComponent(TypeParameterConstraints, {
57
- get parameters() {
58
- return props.typeParameters;
59
- }
60
- })), _$memo(() => _$memo(() => !!props.abstract)() ? ";" : _$createComponent(Block, {
41
+ return [modifiers, returns, " ", name, "(", params, ")", _$memo(() => _$memo(() => props.methodModifier === "abstract")() ? ";" : _$createComponent(Block, {
61
42
  newline: true,
62
43
  get children() {
63
44
  return props.children;
@@ -0,0 +1,15 @@
1
+ import * as core from "@alloy-js/core";
2
+ import { AccessModifier } from "../modifiers.js";
3
+ export interface EnumProps {
4
+ name: string;
5
+ refkey?: core.Refkey;
6
+ children?: core.Children;
7
+ accessModifier?: AccessModifier;
8
+ }
9
+ export declare function Enum(props: EnumProps): core.Children;
10
+ export interface EnumMemberProps {
11
+ name: string;
12
+ refkey?: core.Refkey;
13
+ }
14
+ export declare function EnumMember(props: EnumMemberProps): core.Children;
15
+ //# sourceMappingURL=Enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Enum.d.ts","sourceRoot":"","sources":["../../../src/components/Enum.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAqB,MAAM,iBAAiB,CAAC;AAOpE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACzB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAGD,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,iBA8BpC;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;CACtB;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAmBhD"}
@@ -1,6 +1,6 @@
1
- import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
- import { computeModifiersPrefix, getAccessModifier } from "../modifiers.js";
3
+ import { getAccessModifier } from "../modifiers.js";
4
4
  import { useCSharpNamePolicy } from "../name-policy.js";
5
5
  import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
6
6
  import { CSharpMemberScope, useCSharpScope } from "../symbols/scopes.js";
@@ -8,27 +8,8 @@ import { Name } from "./Name.js";
8
8
 
9
9
  // properties for creating an enum
10
10
 
11
- /**
12
- * A C# enum declaration
13
- * @example
14
- * ```tsx
15
- * <EnumDeclaration public name="Color">
16
- * <EnumMember name="Red" />
17
- * <EnumMember name="Green" />
18
- * <EnumMember name="Blue" />
19
- * </EnumDeclaration>
20
- * ```
21
- * This will produce:
22
- * ```csharp
23
- * public enum Color
24
- * {
25
- * Red,
26
- * Green,
27
- * Blue
28
- * }
29
- * ```
30
- */
31
- export function EnumDeclaration(props) {
11
+ // a C# enum declaration
12
+ export function Enum(props) {
32
13
  const name = useCSharpNamePolicy().getName(props.name, "enum");
33
14
  const scope = useCSharpScope();
34
15
  const thisEnumSymbol = new CSharpOutputSymbol(name, {
@@ -44,11 +25,10 @@ export function EnumDeclaration(props) {
44
25
  parent: scope,
45
26
  owner: thisEnumSymbol
46
27
  });
47
- const modifiers = computeModifiersPrefix([getAccessModifier(props)]);
48
28
  if (thisEnumScope.owner) return _$createComponent(core.Declaration, {
49
29
  symbol: thisEnumSymbol,
50
30
  get children() {
51
- return [modifiers, "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Scope, {
31
+ return [_$memo(() => getAccessModifier(props.accessModifier)), "enum ", _$createComponent(Name, {}), _$memo(() => !props.children && ";"), _$memo(() => _$memo(() => !!props.children)() && _$createComponent(core.Scope, {
52
32
  value: thisEnumScope,
53
33
  get children() {
54
34
  return _$createComponent(core.Block, {
@@ -2,17 +2,12 @@ import * as core from "@alloy-js/core";
2
2
  export interface ParameterProps {
3
3
  name: string;
4
4
  type: core.Children;
5
- /** If the parmaeter is optional(without default value) */
6
- optional?: boolean;
7
- /** Default value for the parameter */
8
- default?: core.Children;
9
5
  refkey?: core.Refkey;
10
6
  symbol?: core.OutputSymbol;
11
7
  }
12
- /** Define a parameter to be used in class or interface method. */
13
8
  export declare function Parameter(props: ParameterProps): core.Children;
14
9
  export interface ParametersProps {
15
- parameters: ParameterProps[];
10
+ parameters: Array<ParameterProps>;
16
11
  }
17
12
  export declare function Parameters(props: ParametersProps): core.Children;
18
13
  //# sourceMappingURL=Parameters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Parameters.d.ts","sourceRoot":"","sources":["../../../src/components/Parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAOvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC;IACxB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;CAC5B;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,iBAwB9C;AAED,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAMhD"}
1
+ {"version":3,"file":"Parameters.d.ts","sourceRoot":"","sources":["../../../src/components/Parameters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAMvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC;CAC5B;AAGD,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,iBAsB9C;AAED,MAAM,WAAW,eAAe;IAE9B,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CACnC;AAGD,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAMhD"}
@@ -1,11 +1,10 @@
1
1
  import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
2
  import * as core from "@alloy-js/core";
3
- import { code } from "@alloy-js/core";
4
3
  import { useCSharpNamePolicy } from "../name-policy.js";
5
4
  import { CSharpOutputSymbol } from "../symbols/csharp-output-symbol.js";
6
5
  import { useCSharpScope } from "../symbols/scopes.js";
7
6
  import { Name } from "./Name.js";
8
- /** Define a parameter to be used in class or interface method. */
7
+ // a constructor/method parameter
9
8
  export function Parameter(props) {
10
9
  const name = useCSharpNamePolicy().getName(props.name, "parameter");
11
10
  const scope = useCSharpScope();
@@ -19,7 +18,7 @@ export function Parameter(props) {
19
18
  return _$createComponent(core.Declaration, {
20
19
  symbol: memberSymbol,
21
20
  get children() {
22
- return [_$memo(() => props.type), _$memo(() => props.optional ? "?" : ""), " ", _$createComponent(Name, {}), _$memo(() => props.default ? code` = ${props.default}` : "")];
21
+ return [_$memo(() => props.type), " ", _$createComponent(Name, {})];
23
22
  }
24
23
  });
25
24
  }
@@ -1,21 +1,12 @@
1
- export * from "./ClassDeclaration.jsx";
2
- export * from "./ClassMethod.jsx";
1
+ export * from "./Class.js";
2
+ export { ClassMethod, type ClassMethodProps } from "./ClassMethod.jsx";
3
3
  export * from "./Declaration.js";
4
- export * from "./doc/comment.jsx";
5
- export * from "./doc/from-markdown.jsx";
6
- export * from "./EnumDeclaration.jsx";
7
- export * from "./interface/declaration.js";
8
- export * from "./interface/method.js";
9
- export * from "./interface/property.js";
4
+ export * from "./Enum.js";
10
5
  export * from "./Name.js";
11
6
  export * from "./Namespace.js";
12
7
  export * from "./Parameters.js";
13
8
  export * from "./ProjectDirectory.js";
14
- export * from "./property/property.jsx";
15
- export * from "./record/declaration.js";
16
9
  export * from "./Reference.js";
17
10
  export * from "./SourceFile.js";
18
- export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
19
11
  export * from "./UsingDirective.js";
20
- export * from "./var/declaration.jsx";
21
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
@@ -1,20 +1,11 @@
1
- export * from "./ClassDeclaration.js";
2
- export * from "./ClassMethod.js";
1
+ export * from "./Class.js";
2
+ export { ClassMethod } from "./ClassMethod.js";
3
3
  export * from "./Declaration.js";
4
- export * from "./doc/comment.js";
5
- export * from "./doc/from-markdown.js";
6
- export * from "./EnumDeclaration.js";
7
- export * from "./interface/declaration.js";
8
- export * from "./interface/method.js";
9
- export * from "./interface/property.js";
4
+ export * from "./Enum.js";
10
5
  export * from "./Name.js";
11
6
  export * from "./Namespace.js";
12
7
  export * from "./Parameters.js";
13
8
  export * from "./ProjectDirectory.js";
14
- export * from "./property/property.js";
15
- export * from "./record/declaration.js";
16
9
  export * from "./Reference.js";
17
10
  export * from "./SourceFile.js";
18
- export * from "./UsingDirective.js";
19
- export * from "./var/declaration.js";
20
- export {};
11
+ export * from "./UsingDirective.js";
@@ -1,10 +1,10 @@
1
1
  import * as core from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
- export declare const ClassDeclaration: core.StcSignature<base.ClassDeclarationProps>;
3
+ export declare const Class: core.StcSignature<base.ClassProps>;
4
4
  export declare const ClassConstructor: core.StcSignature<base.ClassConstructorProps>;
5
5
  export declare const ClassMember: core.StcSignature<base.ClassMemberProps>;
6
6
  export declare const ClassMethod: core.StcSignature<base.ClassMethodProps>;
7
- export declare const EnumDeclaration: core.StcSignature<base.EnumDeclarationProps>;
7
+ export declare const Enum: core.StcSignature<base.EnumProps>;
8
8
  export declare const EnumMember: core.StcSignature<base.EnumMemberProps>;
9
9
  export declare const Parameter: core.StcSignature<base.ParameterProps>;
10
10
  export declare const Parameters: core.StcSignature<base.ParametersProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,eAAe,8CAAiC,CAAC;AAC9D,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,SAAS,wCAA2B,CAAC;AAClD,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,cAAc,6CAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,KAAK,oCAAuB,CAAC;AAC1C,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,WAAW,0CAA6B,CAAC;AACtD,eAAO,MAAM,IAAI,mCAAsB,CAAC;AACxC,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,SAAS,wCAA2B,CAAC;AAClD,eAAO,MAAM,UAAU,yCAA4B,CAAC;AACpD,eAAO,MAAM,gBAAgB,+CAAkC,CAAC;AAChE,eAAO,MAAM,cAAc,6CAAgC,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import * as core from "@alloy-js/core";
2
2
  import * as base from "../index.js";
3
- export const ClassDeclaration = core.stc(base.ClassDeclaration);
3
+ export const Class = core.stc(base.Class);
4
4
  export const ClassConstructor = core.stc(base.ClassConstructor);
5
5
  export const ClassMember = core.stc(base.ClassMember);
6
6
  export const ClassMethod = core.stc(base.ClassMethod);
7
- export const EnumDeclaration = core.stc(base.EnumDeclaration);
7
+ export const Enum = core.stc(base.Enum);
8
8
  export const EnumMember = core.stc(base.EnumMember);
9
9
  export const Parameter = core.stc(base.Parameter);
10
10
  export const Parameters = core.stc(base.Parameters);
@@ -1,14 +1,8 @@
1
- /** Access modifiers. */
2
- export interface AccessModifiers {
3
- readonly public?: boolean;
4
- readonly protected?: boolean;
5
- readonly private?: boolean;
6
- readonly internal?: boolean;
7
- readonly file?: boolean;
8
- }
9
- export declare const getAccessModifier: (data: AccessModifiers) => string;
1
+ export type AccessModifier = "public" | "protected" | "private" | "internal" | "protected-internal" | "private-protected" | "file";
2
+ export declare function getAccessModifier(accessModifier?: AccessModifier): string;
3
+ export type MethodModifier = "abstract" | "sealed" | "static" | "virtual";
4
+ export declare function getMethodModifier(methodModifier?: MethodModifier): string;
10
5
  export declare function getAsyncModifier(async?: boolean): string;
11
6
  /** Resolve the modifier prefix */
12
7
  export declare function computeModifiersPrefix(modifiers: Array<string | undefined>): string;
13
- export declare function makeModifiers<T>(obj: Array<keyof T>): (data: T) => string;
14
8
  //# sourceMappingURL=modifiers.d.ts.map
@@ -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,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":"AAEA,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,WAAW,GACX,SAAS,GACT,UAAU,GACV,oBAAoB,GACpB,mBAAmB,GACnB,MAAM,CAAC;AAgBX,wBAAgB,iBAAiB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,CAEzE;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAa1E,wBAAgB,iBAAiB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,CAEzE;AAED,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"}
@@ -1,20 +1,43 @@
1
1
  // the possible C# access modifiers
2
2
  // https://learn.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers
3
3
 
4
- /** Access modifiers. */
4
+ // maps the above access modifier value to its C# syntax.
5
+ // note that the C# keyword includes a trailing space
6
+ const accessModifierLookup = {
7
+ public: "public ",
8
+ protected: "protected ",
9
+ private: "private ",
10
+ internal: "internal ",
11
+ "protected-internal": "protected internal ",
12
+ "private-protected": "private protected ",
13
+ file: "file "
14
+ };
5
15
 
6
- export const getAccessModifier = makeModifiers(["public", "protected", "private", "internal", "file"]);
16
+ // returns the C# syntax for the specified access modifier.
17
+ // if no access modifier is specified, the empty string is returned.
18
+ export function getAccessModifier(accessModifier) {
19
+ return accessModifier ? accessModifierLookup[accessModifier] : "";
20
+ }
21
+ // maps the above method modifier value to its C# syntax.
22
+ // note that the C# keyword includes a trailing space
23
+ const methodModifierLookup = {
24
+ abstract: "abstract ",
25
+ sealed: "sealed ",
26
+ static: "static ",
27
+ virtual: "virtual "
28
+ };
29
+
30
+ // returns the C# syntax for the specified method modifier.
31
+ // if no method modifier is specified, the empty string is returned.
32
+ export function getMethodModifier(methodModifier) {
33
+ return methodModifier ? methodModifierLookup[methodModifier] : "";
34
+ }
7
35
  export function getAsyncModifier(async) {
8
- return async ? "async" : "";
36
+ return async ? "async " : "";
9
37
  }
10
38
 
11
39
  /** Resolve the modifier prefix */
12
40
  export function computeModifiersPrefix(modifiers) {
13
41
  const resolved = modifiers.filter(x => x);
14
- return resolved.length > 0 ? resolved.join(" ") + " " : "";
15
- }
16
- export function makeModifiers(obj) {
17
- return data => {
18
- return obj.map(key => data[key] ? key : undefined).filter(x => x).join(" ");
19
- };
42
+ return resolved.length > 0 ? resolved.join("") : "";
20
43
  }
@@ -1,5 +1,5 @@
1
1
  import * as core from "@alloy-js/core";
2
- export type CSharpElements = "class" | "constant" | "variable" | "enum" | "enum-member" | "function" | "interface" | "record" | "class-member-private" | "class-member-public" | "class-method" | "class-property" | "parameter" | "type-parameter";
2
+ export type CSharpElements = "class" | "constant" | "enum" | "enum-member" | "function" | "interface" | "class-member-private" | "class-member-public" | "class-method" | "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,UAAU,GACV,MAAM,GACN,aAAa,GACb,UAAU,GACV,WAAW,GACX,QAAQ,GACR,sBAAsB,GACtB,qBAAqB,GACrB,cAAc,GACd,gBAAgB,GAChB,WAAW,GACX,gBAAgB,CAAC;AAGrB,wBAAgB,sBAAsB,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAmBxE;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,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"}
@@ -11,11 +11,9 @@ export function createCSharpNamePolicy() {
11
11
  case "enum":
12
12
  case "enum-member":
13
13
  case "interface":
14
- case "record":
15
14
  case "class-member-public":
16
15
  case "class-method":
17
16
  case "type-parameter":
18
- case "class-property":
19
17
  return changecase.pascalCase(name);
20
18
  case "constant":
21
19
  return changecase.constantCase(name);