@alloy-js/csharp 0.20.0-dev.4 → 0.20.0-dev.6

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 (173) hide show
  1. package/dist/src/components/Declaration.js +2 -1
  2. package/dist/src/components/Declaration.js.map +1 -0
  3. package/dist/src/components/Name.js +2 -1
  4. package/dist/src/components/Name.js.map +1 -0
  5. package/dist/src/components/ProjectDirectory.js +2 -1
  6. package/dist/src/components/ProjectDirectory.js.map +1 -0
  7. package/dist/src/components/Reference.js +2 -1
  8. package/dist/src/components/Reference.js.map +1 -0
  9. package/dist/src/components/SourceFile.d.ts +5 -0
  10. package/dist/src/components/SourceFile.d.ts.map +1 -1
  11. package/dist/src/components/SourceFile.js +20 -59
  12. package/dist/src/components/SourceFile.js.map +1 -0
  13. package/dist/src/components/UsingDirective.js +2 -1
  14. package/dist/src/components/UsingDirective.js.map +1 -0
  15. package/dist/src/components/attributes/attributes.js +2 -1
  16. package/dist/src/components/attributes/attributes.js.map +1 -0
  17. package/dist/src/components/attributes/attributes.test.js +2 -1
  18. package/dist/src/components/attributes/attributes.test.js.map +1 -0
  19. package/dist/src/components/class/declaration.d.ts.map +1 -1
  20. package/dist/src/components/class/declaration.js +2 -1
  21. package/dist/src/components/class/declaration.js.map +1 -0
  22. package/dist/src/components/class/declaration.test.js +2 -1
  23. package/dist/src/components/class/declaration.test.js.map +1 -0
  24. package/dist/src/components/constructor/constructor.js +2 -1
  25. package/dist/src/components/constructor/constructor.js.map +1 -0
  26. package/dist/src/components/constructor/constructor.test.js +2 -1
  27. package/dist/src/components/constructor/constructor.test.js.map +1 -0
  28. package/dist/src/components/doc/comment.js +2 -1
  29. package/dist/src/components/doc/comment.js.map +1 -0
  30. package/dist/src/components/doc/comment.test.js +2 -1
  31. package/dist/src/components/doc/comment.test.js.map +1 -0
  32. package/dist/src/components/doc/from-markdown.js +2 -1
  33. package/dist/src/components/doc/from-markdown.js.map +1 -0
  34. package/dist/src/components/doc/from-markdown.test.js +2 -1
  35. package/dist/src/components/doc/from-markdown.test.js.map +1 -0
  36. package/dist/src/components/enum/declaration.js +2 -1
  37. package/dist/src/components/enum/declaration.js.map +1 -0
  38. package/dist/src/components/enum/declaration.ref.test.js +2 -1
  39. package/dist/src/components/enum/declaration.ref.test.js.map +1 -0
  40. package/dist/src/components/enum/declaration.test.js +2 -1
  41. package/dist/src/components/enum/declaration.test.js.map +1 -0
  42. package/dist/src/components/enum/member.js +2 -1
  43. package/dist/src/components/enum/member.js.map +1 -0
  44. package/dist/src/components/enum/member.test.js +2 -1
  45. package/dist/src/components/enum/member.test.js.map +1 -0
  46. package/dist/src/components/field/field.js +2 -1
  47. package/dist/src/components/field/field.js.map +1 -0
  48. package/dist/src/components/field/field.test.js +2 -1
  49. package/dist/src/components/field/field.test.js.map +1 -0
  50. package/dist/src/components/index.js +2 -1
  51. package/dist/src/components/index.js.map +1 -0
  52. package/dist/src/components/interface/declaration.js +2 -1
  53. package/dist/src/components/interface/declaration.js.map +1 -0
  54. package/dist/src/components/interface/declaration.test.js +2 -1
  55. package/dist/src/components/interface/declaration.test.js.map +1 -0
  56. package/dist/src/components/interface/method.js +2 -1
  57. package/dist/src/components/interface/method.js.map +1 -0
  58. package/dist/src/components/interface/method.test.js +2 -1
  59. package/dist/src/components/interface/method.test.js.map +1 -0
  60. package/dist/src/components/interface/property.js +2 -1
  61. package/dist/src/components/interface/property.js.map +1 -0
  62. package/dist/src/components/interface/property.test.js +2 -1
  63. package/dist/src/components/interface/property.test.js.map +1 -0
  64. package/dist/src/components/lexical-scope.js +2 -1
  65. package/dist/src/components/lexical-scope.js.map +1 -0
  66. package/dist/src/components/method/method.js +2 -1
  67. package/dist/src/components/method/method.js.map +1 -0
  68. package/dist/src/components/method/method.test.js +2 -1
  69. package/dist/src/components/method/method.test.js.map +1 -0
  70. package/dist/src/components/method-scope.js +2 -1
  71. package/dist/src/components/method-scope.js.map +1 -0
  72. package/dist/src/components/namespace-scopes.js +2 -1
  73. package/dist/src/components/namespace-scopes.js.map +1 -0
  74. package/dist/src/components/namespace.js +2 -1
  75. package/dist/src/components/namespace.js.map +1 -0
  76. package/dist/src/components/namespace.ref.test.js +2 -1
  77. package/dist/src/components/namespace.ref.test.js.map +1 -0
  78. package/dist/src/components/namespace.test.js +2 -1
  79. package/dist/src/components/namespace.test.js.map +1 -0
  80. package/dist/src/components/parameters/parameters.js +2 -1
  81. package/dist/src/components/parameters/parameters.js.map +1 -0
  82. package/dist/src/components/parameters/parameters.test.js +2 -1
  83. package/dist/src/components/parameters/parameters.test.js.map +1 -0
  84. package/dist/src/components/property/property.js +2 -1
  85. package/dist/src/components/property/property.js.map +1 -0
  86. package/dist/src/components/property/property.test.js +2 -1
  87. package/dist/src/components/property/property.test.js.map +1 -0
  88. package/dist/src/components/record/declaration.js +2 -1
  89. package/dist/src/components/record/declaration.js.map +1 -0
  90. package/dist/src/components/record/declaration.test.js +2 -1
  91. package/dist/src/components/record/declaration.test.js.map +1 -0
  92. package/dist/src/components/stc/index.js +2 -1
  93. package/dist/src/components/stc/index.js.map +1 -0
  94. package/dist/src/components/struct/declaration.js +2 -1
  95. package/dist/src/components/struct/declaration.js.map +1 -0
  96. package/dist/src/components/struct/declaration.test.js +2 -1
  97. package/dist/src/components/struct/declaration.test.js.map +1 -0
  98. package/dist/src/components/type-parameters/type-parameter-constraints.js +2 -1
  99. package/dist/src/components/type-parameters/type-parameter-constraints.js.map +1 -0
  100. package/dist/src/components/type-parameters/type-parameter-constraints.test.js +2 -1
  101. package/dist/src/components/type-parameters/type-parameter-constraints.test.js.map +1 -0
  102. package/dist/src/components/type-parameters/type-parameter.js +2 -1
  103. package/dist/src/components/type-parameters/type-parameter.js.map +1 -0
  104. package/dist/src/components/type-parameters/type-parameters.js +2 -1
  105. package/dist/src/components/type-parameters/type-parameters.js.map +1 -0
  106. package/dist/src/components/type-parameters/type-parameters.test.js +2 -1
  107. package/dist/src/components/type-parameters/type-parameters.test.js.map +1 -0
  108. package/dist/src/components/var/declaration.js +2 -1
  109. package/dist/src/components/var/declaration.js.map +1 -0
  110. package/dist/src/components/var/declaration.test.js +2 -1
  111. package/dist/src/components/var/declaration.test.js.map +1 -0
  112. package/dist/src/contexts/global-namespace.js +2 -1
  113. package/dist/src/contexts/global-namespace.js.map +1 -0
  114. package/dist/src/contexts/namespace.js +2 -1
  115. package/dist/src/contexts/namespace.js.map +1 -0
  116. package/dist/src/index.js +2 -1
  117. package/dist/src/index.js.map +1 -0
  118. package/dist/src/modifiers.js +2 -1
  119. package/dist/src/modifiers.js.map +1 -0
  120. package/dist/src/name-policy.js +2 -1
  121. package/dist/src/name-policy.js.map +1 -0
  122. package/dist/src/scopes/class.js +2 -1
  123. package/dist/src/scopes/class.js.map +1 -0
  124. package/dist/src/scopes/contexts.js +2 -1
  125. package/dist/src/scopes/contexts.js.map +1 -0
  126. package/dist/src/scopes/csharp.js +2 -1
  127. package/dist/src/scopes/csharp.js.map +1 -0
  128. package/dist/src/scopes/factories.js +2 -1
  129. package/dist/src/scopes/factories.js.map +1 -0
  130. package/dist/src/scopes/index.js +2 -1
  131. package/dist/src/scopes/index.js.map +1 -0
  132. package/dist/src/scopes/lexical.js +2 -1
  133. package/dist/src/scopes/lexical.js.map +1 -0
  134. package/dist/src/scopes/method.js +2 -1
  135. package/dist/src/scopes/method.js.map +1 -0
  136. package/dist/src/scopes/named-type.js +2 -1
  137. package/dist/src/scopes/named-type.js.map +1 -0
  138. package/dist/src/scopes/namespace.js +2 -1
  139. package/dist/src/scopes/namespace.js.map +1 -0
  140. package/dist/src/scopes/source-file.js +2 -1
  141. package/dist/src/scopes/source-file.js.map +1 -0
  142. package/dist/src/symbols/csharp.js +2 -1
  143. package/dist/src/symbols/csharp.js.map +1 -0
  144. package/dist/src/symbols/factories.d.ts.map +1 -1
  145. package/dist/src/symbols/factories.js +14 -7
  146. package/dist/src/symbols/factories.js.map +1 -0
  147. package/dist/src/symbols/index.js +2 -1
  148. package/dist/src/symbols/index.js.map +1 -0
  149. package/dist/src/symbols/method.js +2 -1
  150. package/dist/src/symbols/method.js.map +1 -0
  151. package/dist/src/symbols/named-type.js +2 -1
  152. package/dist/src/symbols/named-type.js.map +1 -0
  153. package/dist/src/symbols/namespace.js +2 -1
  154. package/dist/src/symbols/namespace.js.map +1 -0
  155. package/dist/src/symbols/reference.js +2 -1
  156. package/dist/src/symbols/reference.js.map +1 -0
  157. package/dist/test/project-directory.test.js +2 -1
  158. package/dist/test/project-directory.test.js.map +1 -0
  159. package/dist/test/sourcefile.test.js +2 -1
  160. package/dist/test/sourcefile.test.js.map +1 -0
  161. package/dist/test/using.test.js +2 -1
  162. package/dist/test/using.test.js.map +1 -0
  163. package/dist/test/utils.js +2 -1
  164. package/dist/test/utils.js.map +1 -0
  165. package/dist/test/vitest.setup.js +2 -1
  166. package/dist/test/vitest.setup.js.map +1 -0
  167. package/dist/tsconfig.tsbuildinfo +1 -1
  168. package/package.json +5 -3
  169. package/src/components/SourceFile.tsx +27 -30
  170. package/src/components/class/declaration.tsx +1 -0
  171. package/src/symbols/factories.ts +31 -15
  172. package/temp/api.json +3 -3
  173. package/tsconfig.json +4 -1
@@ -1,23 +1,27 @@
1
1
  import {
2
+ Block,
2
3
  Children,
3
4
  computed,
4
5
  SourceFile as CoreSourceFile,
5
6
  Scope,
6
- Show,
7
7
  useBinder,
8
8
  } from "@alloy-js/core";
9
9
  import { getGlobalNamespace } from "../contexts/global-namespace.js";
10
10
  import { useNamespaceContext } from "../contexts/namespace.js";
11
11
  import { CSharpSourceFileScope } from "../scopes/source-file.js";
12
12
  import { NamespaceSymbol } from "../symbols/namespace.js";
13
- import { NamespaceScope, NamespaceScopes } from "./namespace-scopes.jsx";
13
+ import { NamespaceScopes } from "./namespace-scopes.jsx";
14
14
  import { Reference } from "./Reference.jsx";
15
15
  import { UsingDirective } from "./UsingDirective.jsx";
16
16
 
17
+ /**
18
+ * Props for {@link SourceFile} component
19
+ */
17
20
  export interface SourceFileProps {
18
21
  /** Path of the source file */
19
22
  path: string;
20
23
 
24
+ /** Source file content */
21
25
  children?: Children;
22
26
 
23
27
  /**
@@ -27,8 +31,7 @@ export interface SourceFileProps {
27
31
  using?: string[];
28
32
  }
29
33
 
30
- // a C# source file. exists within the context of a namespace
31
- // contains using statements and declarations
34
+ /** A C# source file exists within the context of a namespace contains using statements and declarations */
32
35
  export function SourceFile(props: SourceFileProps) {
33
36
  const sourceFileScope = new CSharpSourceFileScope(props.path);
34
37
 
@@ -41,6 +44,10 @@ export function SourceFile(props: SourceFileProps) {
41
44
  Array.from(sourceFileScope.usings) as (NamespaceSymbol | string)[]
42
45
  ).concat(props.using ?? []);
43
46
  });
47
+
48
+ const content = computed(() => (
49
+ <NamespaceScopes symbol={nsSymbol}>{props.children}</NamespaceScopes>
50
+ ));
44
51
  return (
45
52
  <CoreSourceFile
46
53
  path={props.path}
@@ -58,33 +65,23 @@ export function SourceFile(props: SourceFileProps) {
58
65
  <hbr />
59
66
  </>
60
67
  )}
61
- <Show when={!!nsContext && nsSymbol !== globalNs}>
62
- <Show when={sourceFileScope.hasBlockNamespace}>
68
+ {nsSymbol === globalNs ?
69
+ content
70
+ : <>
63
71
  namespace {nsRef}
64
- {" {"}
65
- <hbr />
66
- {" "}
67
- </Show>
68
-
69
- <Show when={!sourceFileScope.hasBlockNamespace}>
70
- namespace {nsRef};<hbr />
71
- <hbr />
72
- </Show>
73
- <align width={sourceFileScope.hasBlockNamespace ? 4 : 0}>
74
- <NamespaceScopes symbol={nsContext!.symbol}>
75
- {props.children}
76
- </NamespaceScopes>
77
- </align>
78
- <Show when={sourceFileScope.hasBlockNamespace}>
79
- <hbr />
80
- {"}"}
81
- </Show>
82
- </Show>
83
- <Show when={!nsContext || nsSymbol === globalNs}>
84
- <NamespaceScope symbol={getGlobalNamespace(useBinder())}>
85
- {props.children}
86
- </NamespaceScope>
87
- </Show>
72
+ {sourceFileScope.hasBlockNamespace ?
73
+ <>
74
+ {" "}
75
+ <Block>{content}</Block>
76
+ </>
77
+ : <>
78
+ ;<hbr />
79
+ <hbr />
80
+ {content}
81
+ </>
82
+ }
83
+ </>
84
+ }
88
85
  </Scope>
89
86
  </CoreSourceFile>
90
87
  );
@@ -133,6 +133,7 @@ export function ClassDeclaration(props: ClassDeclarationProps) {
133
133
  const thisClassSymbol = createNamedTypeSymbol(props.name, "class", {
134
134
  refkeys: props.refkey,
135
135
  });
136
+
136
137
  const thisClassScope = createClassScope(thisClassSymbol);
137
138
 
138
139
  const bases = [
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Namekey,
3
3
  NamePolicyGetter,
4
+ onCleanup,
4
5
  OutputSymbolOptions,
5
6
  useBinder,
6
7
  } from "@alloy-js/core";
@@ -99,13 +100,22 @@ export function createFieldSymbol(
99
100
  );
100
101
  }
101
102
 
103
+ function withCleanup<T extends CSharpSymbol>(sym: T): T {
104
+ onCleanup(() => {
105
+ sym.delete();
106
+ });
107
+ return sym;
108
+ }
109
+
102
110
  export function createNamedTypeSymbol(
103
111
  name: string | Namekey,
104
112
  kind: NamedTypeTypeKind,
105
113
  options?: OutputSymbolOptions,
106
114
  ) {
107
115
  const scope = useNamedTypeScope();
108
- return new NamedTypeSymbol(name, scope.ownerSymbol.members, kind, options);
116
+ return withCleanup(
117
+ new NamedTypeSymbol(name, scope.ownerSymbol.members, kind, options),
118
+ );
109
119
  }
110
120
 
111
121
  export function createNamespaceSymbol(name: string) {
@@ -114,7 +124,7 @@ export function createNamespaceSymbol(name: string) {
114
124
  if (nsSymbol.members.symbolNames.has(name)) {
115
125
  return nsSymbol.members.symbolNames.get(name)! as NamespaceSymbol;
116
126
  }
117
- return new NamespaceSymbol(name, nsSymbol);
127
+ return withCleanup(new NamespaceSymbol(name, nsSymbol));
118
128
  }
119
129
 
120
130
  export interface CreateMethodSymbolOptions extends CSharpSymbolOptions {
@@ -137,11 +147,13 @@ export function createMethodSymbol(
137
147
  );
138
148
  }
139
149
 
140
- return new MethodSymbol(
141
- originalName,
142
- scope.members,
143
- options.methodKind ?? "ordinary",
144
- withNamePolicy(options, "class-method"),
150
+ return withCleanup(
151
+ new MethodSymbol(
152
+ originalName,
153
+ scope.members,
154
+ options.methodKind ?? "ordinary",
155
+ withNamePolicy(options, "class-method"),
156
+ ),
145
157
  );
146
158
  }
147
159
 
@@ -150,10 +162,12 @@ export function createPropertySymbol(
150
162
  options: CSharpSymbolOptions,
151
163
  ) {
152
164
  const scope = useNamedTypeScope();
153
- return new CSharpSymbol(
154
- name,
155
- scope.members,
156
- withNamePolicy(options, "class-property"),
165
+ return withCleanup(
166
+ new CSharpSymbol(
167
+ name,
168
+ scope.members,
169
+ withNamePolicy(options, "class-property"),
170
+ ),
157
171
  );
158
172
  }
159
173
 
@@ -181,10 +195,12 @@ export function createVariableSymbol(
181
195
  `Can't create variable symbol outside of a lexical scope, got a ${scope.constructor.name}.`,
182
196
  );
183
197
  }
184
- return new CSharpSymbol(
185
- originalName,
186
- scope.localVariables,
187
- withNamePolicy(options, "variable"),
198
+ return withCleanup(
199
+ new CSharpSymbol(
200
+ originalName,
201
+ scope.localVariables,
202
+ withNamePolicy(options, "variable"),
203
+ ),
188
204
  );
189
205
  }
190
206
 
package/temp/api.json CHANGED
@@ -12101,7 +12101,7 @@
12101
12101
  {
12102
12102
  "kind": "Function",
12103
12103
  "canonicalReference": "@alloy-js/csharp!SourceFile:function(1)",
12104
- "docComment": "",
12104
+ "docComment": "/**\n * A C# source file exists within the context of a namespace contains using statements and declarations\n */\n",
12105
12105
  "excerptTokens": [
12106
12106
  {
12107
12107
  "kind": "Content",
@@ -12148,7 +12148,7 @@
12148
12148
  {
12149
12149
  "kind": "Interface",
12150
12150
  "canonicalReference": "@alloy-js/csharp!SourceFileProps:interface",
12151
- "docComment": "",
12151
+ "docComment": "/**\n * Props for {@link SourceFile} component\n */\n",
12152
12152
  "excerptTokens": [
12153
12153
  {
12154
12154
  "kind": "Content",
@@ -12163,7 +12163,7 @@
12163
12163
  {
12164
12164
  "kind": "PropertySignature",
12165
12165
  "canonicalReference": "@alloy-js/csharp!SourceFileProps#children:member",
12166
- "docComment": "",
12166
+ "docComment": "/**\n * Source file content\n */\n",
12167
12167
  "excerptTokens": [
12168
12168
  {
12169
12169
  "kind": "Content",
package/tsconfig.json CHANGED
@@ -4,7 +4,10 @@
4
4
  "emitDeclarationOnly": true,
5
5
  "declaration": true,
6
6
  "outDir": "dist",
7
- "types": ["@alloy-js/core/testing/matchers"]
7
+ "types": ["@alloy-js/core/testing/matchers"],
8
+ "paths": {
9
+ "#components/*": ["./src/components/*"]
10
+ }
8
11
  },
9
12
  "references": [{ "path": "../core" }],
10
13
  "include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"],