@alloy-js/csharp 0.23.0-dev.1 → 0.23.0-dev.3

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 (65) hide show
  1. package/CHANGELOG.md +1 -14
  2. package/dist/src/components/access-expression/access-expression.d.ts +1 -1
  3. package/dist/src/components/access-expression/access-expression.d.ts.map +1 -1
  4. package/dist/src/components/enum/member.d.ts.map +1 -1
  5. package/dist/src/components/enum/member.js +2 -2
  6. package/dist/src/components/enum/member.js.map +1 -1
  7. package/dist/src/components/lexical-scope.d.ts.map +1 -1
  8. package/dist/src/components/lexical-scope.js +4 -3
  9. package/dist/src/components/lexical-scope.js.map +1 -1
  10. package/dist/src/components/method-scope.d.ts.map +1 -1
  11. package/dist/src/components/method-scope.js +4 -3
  12. package/dist/src/components/method-scope.js.map +1 -1
  13. package/dist/src/components/source-file/source-file.d.ts.map +1 -1
  14. package/dist/src/components/source-file/source-file.js +6 -3
  15. package/dist/src/components/source-file/source-file.js.map +1 -1
  16. package/dist/src/contexts/global-namespace.d.ts.map +1 -1
  17. package/dist/src/contexts/global-namespace.js +4 -4
  18. package/dist/src/contexts/global-namespace.js.map +1 -1
  19. package/dist/src/create-library.d.ts.map +1 -1
  20. package/dist/src/create-library.js +7 -7
  21. package/dist/src/create-library.js.map +1 -1
  22. package/dist/src/scopes/csharp.d.ts +1 -0
  23. package/dist/src/scopes/csharp.d.ts.map +1 -1
  24. package/dist/src/scopes/csharp.js +10 -0
  25. package/dist/src/scopes/csharp.js.map +1 -1
  26. package/dist/src/scopes/factories.d.ts.map +1 -1
  27. package/dist/src/scopes/factories.js +4 -3
  28. package/dist/src/scopes/factories.js.map +1 -1
  29. package/dist/src/scopes/namespace.js +2 -2
  30. package/dist/src/scopes/namespace.js.map +1 -1
  31. package/dist/src/symbols/csharp.d.ts +1 -0
  32. package/dist/src/symbols/csharp.d.ts.map +1 -1
  33. package/dist/src/symbols/csharp.js +19 -2
  34. package/dist/src/symbols/csharp.js.map +1 -1
  35. package/dist/src/symbols/factories.d.ts.map +1 -1
  36. package/dist/src/symbols/factories.js +42 -10
  37. package/dist/src/symbols/factories.js.map +1 -1
  38. package/dist/src/symbols/named-type.d.ts +1 -0
  39. package/dist/src/symbols/named-type.d.ts.map +1 -1
  40. package/dist/src/symbols/named-type.js +12 -1
  41. package/dist/src/symbols/named-type.js.map +1 -1
  42. package/dist/src/symbols/namespace.d.ts +1 -0
  43. package/dist/src/symbols/namespace.d.ts.map +1 -1
  44. package/dist/src/symbols/namespace.js +11 -1
  45. package/dist/src/symbols/namespace.js.map +1 -1
  46. package/dist/testing/create-wrapper.d.ts.map +1 -1
  47. package/dist/testing/create-wrapper.js +2 -1
  48. package/dist/testing/create-wrapper.js.map +1 -1
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +11 -7
  51. package/src/components/enum/member.tsx +16 -5
  52. package/src/components/lexical-scope.tsx +15 -4
  53. package/src/components/method-scope.tsx +15 -4
  54. package/src/components/source-file/source-file.tsx +11 -2
  55. package/src/contexts/global-namespace.ts +11 -6
  56. package/src/create-library.ts +18 -9
  57. package/src/scopes/csharp.ts +11 -0
  58. package/src/scopes/factories.ts +4 -4
  59. package/src/scopes/namespace.ts +2 -2
  60. package/src/symbols/csharp.ts +20 -1
  61. package/src/symbols/factories.ts +46 -34
  62. package/src/symbols/named-type.ts +15 -3
  63. package/src/symbols/namespace.ts +12 -2
  64. package/temp/api.json +141 -234
  65. package/testing/create-wrapper.tsx +2 -1
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@alloy-js/csharp",
3
- "version": "0.23.0-dev.1",
3
+ "version": "0.23.0-dev.3",
4
4
  "description": "Alloy components for CSharp language.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/alloy-framework/alloy.git"
8
+ },
5
9
  "exports": {
6
10
  ".": {
7
11
  "import": "./dist/src/index.js"
@@ -32,23 +36,23 @@
32
36
  "author": "jhendrix@microsoft.com",
33
37
  "license": "MIT",
34
38
  "dependencies": {
35
- "@alloy-js/core": "~0.22.0 || >= 0.23.0-dev.1",
36
- "@alloy-js/msbuild": "~0.22.0 || >= 0.23.0-dev.0",
39
+ "@alloy-js/core": "~0.22.0 || >= 0.23.0-dev.8",
40
+ "@alloy-js/msbuild": "~0.22.0 || >= 0.23.0-dev.1",
37
41
  "change-case": "^5.4.4",
38
42
  "marked": "^16.1.1",
39
43
  "pathe": "^2.0.3"
40
44
  },
41
45
  "devDependencies": {
42
- "@alloy-js/cli": "~0.22.0 || >= 0.23.0-dev.1",
43
- "@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.0",
44
- "@alloy-js/typescript": "~0.22.0 || >= 0.23.0-dev.2",
46
+ "@alloy-js/cli": "~0.22.0 || >= 0.23.0-dev.3",
47
+ "@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.1",
48
+ "@alloy-js/typescript": "~0.22.0 || >= 0.23.0-dev.4",
45
49
  "@microsoft/api-extractor": "~7.52.8",
46
50
  "@rollup/plugin-typescript": "^12.1.2",
47
51
  "@types/js-yaml": "^4.0.9",
48
52
  "concurrently": "^9.2.0",
49
53
  "js-yaml": "^4.1.0",
50
54
  "typescript": "^5.8.3",
51
- "vitest": "^3.2.4"
55
+ "vitest": "3.2.4"
52
56
  },
53
57
  "type": "module",
54
58
  "scripts": {
@@ -1,4 +1,10 @@
1
- import { MemberDeclaration, MemberName, Namekey, Refkey } from "@alloy-js/core";
1
+ import {
2
+ createSymbol,
3
+ MemberDeclaration,
4
+ MemberName,
5
+ Namekey,
6
+ Refkey,
7
+ } from "@alloy-js/core";
2
8
  import { useCSharpNamePolicy } from "../../name-policy.js";
3
9
  import { useNamedTypeScope } from "../../scopes/contexts.js";
4
10
  import { CSharpSymbol } from "../../symbols/csharp.js";
@@ -23,10 +29,15 @@ export function EnumMember(props: EnumMemberProps) {
23
29
  throw new Error("EnumMember must be used within an EnumDeclaration.");
24
30
  }
25
31
 
26
- const thisEnumValueSymbol = new CSharpSymbol(props.name, symbol.members, {
27
- refkeys: props.refkey,
28
- namePolicy: useCSharpNamePolicy().for("enum-member"),
29
- });
32
+ const thisEnumValueSymbol = createSymbol(
33
+ CSharpSymbol,
34
+ props.name,
35
+ symbol.members,
36
+ {
37
+ refkeys: props.refkey,
38
+ namePolicy: useCSharpNamePolicy().for("enum-member"),
39
+ },
40
+ );
30
41
 
31
42
  return (
32
43
  <MemberDeclaration symbol={thisEnumValueSymbol}>
@@ -1,4 +1,9 @@
1
- import { Scope, ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
1
+ import {
2
+ Scope,
3
+ ScopePropsWithInfo,
4
+ ScopePropsWithValue,
5
+ createScope,
6
+ } from "@alloy-js/core";
2
7
  import { useCSharpScope } from "../scopes/contexts.js";
3
8
  import { CSharpLexicalScope } from "../scopes/lexical.js";
4
9
 
@@ -20,9 +25,15 @@ export function LexicalScope(props: LexicalScopeProps) {
20
25
  scope = props.value;
21
26
  } else {
22
27
  const parentScope = useCSharpScope();
23
- scope = new CSharpLexicalScope(props.name ?? "lexical scope", parentScope, {
24
- ...props,
25
- });
28
+ scope = createScope(
29
+ CSharpLexicalScope,
30
+ props.name ?? "lexical scope",
31
+ parentScope,
32
+ {
33
+ ...props,
34
+ binder: parentScope?.binder,
35
+ },
36
+ );
26
37
  }
27
38
 
28
39
  return <Scope value={scope}>{props.children}</Scope>;
@@ -1,4 +1,9 @@
1
- import { Scope, ScopePropsWithInfo, ScopePropsWithValue } from "@alloy-js/core";
1
+ import {
2
+ Scope,
3
+ ScopePropsWithInfo,
4
+ ScopePropsWithValue,
5
+ createScope,
6
+ } from "@alloy-js/core";
2
7
  import { useCSharpScope } from "../scopes/contexts.js";
3
8
  import { CSharpMethodScope } from "../scopes/method.js";
4
9
 
@@ -18,9 +23,15 @@ export function MethodScope(props: MethodScopeProps) {
18
23
  scope = props.value;
19
24
  } else {
20
25
  const parentScope = useCSharpScope();
21
- scope = new CSharpMethodScope(props.name ?? "method scope", parentScope, {
22
- ...props,
23
- });
26
+ scope = createScope(
27
+ CSharpMethodScope,
28
+ props.name ?? "method scope",
29
+ parentScope,
30
+ {
31
+ ...props,
32
+ binder: parentScope?.binder,
33
+ },
34
+ );
24
35
  }
25
36
 
26
37
  return <Scope value={scope}>{props.children}</Scope>;
@@ -8,6 +8,7 @@ import {
8
8
  Children,
9
9
  computed,
10
10
  SourceFile as CoreSourceFile,
11
+ createScope,
11
12
  List,
12
13
  Scope,
13
14
  Show,
@@ -45,10 +46,18 @@ export interface SourceFileProps extends CSharpFormatOptions {
45
46
 
46
47
  /** A C# source file exists within the context of a namespace contains using statements and declarations */
47
48
  export function SourceFile(props: SourceFileProps) {
48
- const sourceFileScope = new CSharpSourceFileScope(props.path);
49
+ const binder = useBinder();
50
+ const sourceFileScope = createScope(
51
+ CSharpSourceFileScope,
52
+ props.path,
53
+ undefined,
54
+ {
55
+ binder,
56
+ },
57
+ );
49
58
 
50
59
  const nsContext = useNamespaceContext();
51
- const globalNs = getGlobalNamespace(useBinder());
60
+ const globalNs = getGlobalNamespace(binder);
52
61
  const nsSymbol = nsContext ? nsContext.symbol : globalNs;
53
62
  const usings = computed(() => {
54
63
  return (
@@ -1,4 +1,4 @@
1
- import { Binder, useBinder } from "@alloy-js/core";
1
+ import { Binder, createSymbol, useBinder } from "@alloy-js/core";
2
2
  import { NamespaceSymbol } from "../symbols/namespace.js";
3
3
 
4
4
  export function useGlobalNamespace() {
@@ -7,12 +7,17 @@ export function useGlobalNamespace() {
7
7
  }
8
8
 
9
9
  const globalNamespaces = new WeakMap<Binder, NamespaceSymbol>();
10
- let defaultGlobalNamespace = new NamespaceSymbol("global", undefined, {
11
- isGlobal: true,
12
- });
10
+ let defaultGlobalNamespace = createSymbol(
11
+ NamespaceSymbol,
12
+ "global",
13
+ undefined,
14
+ {
15
+ isGlobal: true,
16
+ },
17
+ );
13
18
 
14
19
  export function resetGlobalNamespace() {
15
- defaultGlobalNamespace = new NamespaceSymbol("global", undefined, {
20
+ defaultGlobalNamespace = createSymbol(NamespaceSymbol, "global", undefined, {
16
21
  isGlobal: true,
17
22
  });
18
23
  }
@@ -25,7 +30,7 @@ export function getGlobalNamespace(binder: Binder | undefined) {
25
30
  let namespace = globalNamespaces.get(binder);
26
31
 
27
32
  if (!namespace) {
28
- namespace = new NamespaceSymbol("global", undefined, {
33
+ namespace = createSymbol(NamespaceSymbol, "global", undefined, {
29
34
  binder,
30
35
  isGlobal: true,
31
36
  });
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Binder,
3
+ createSymbol,
3
4
  LibrarySymbolReference,
4
5
  namekey,
5
6
  refkey,
@@ -124,10 +125,15 @@ export function createLibrary<T extends Record<string, Descriptor>>(
124
125
  name,
125
126
  )! as NamespaceSymbol;
126
127
  } else {
127
- ownerSymbol = new NamespaceSymbol(namekey(name), ownerSymbol!, {
128
- binder,
129
- refkeys: refkey(),
130
- });
128
+ ownerSymbol = createSymbol(
129
+ NamespaceSymbol,
130
+ namekey(name),
131
+ ownerSymbol!,
132
+ {
133
+ binder,
134
+ refkeys: refkey(),
135
+ },
136
+ );
131
137
  }
132
138
  }
133
139
 
@@ -214,7 +220,8 @@ function createSymbolFromDescriptor(
214
220
  if (ownerSymbol.members.symbolNames.has(name)) {
215
221
  return ownerSymbol.members.symbolNames.get(name)! as NamespaceSymbol;
216
222
  }
217
- return new NamespaceSymbol(
223
+ return createSymbol(
224
+ NamespaceSymbol,
218
225
  namekey(name),
219
226
  ownerSymbol as NamespaceSymbol,
220
227
  {
@@ -228,7 +235,8 @@ function createSymbolFromDescriptor(
228
235
  case "interface":
229
236
  case "struct":
230
237
  case "record":
231
- return new NamedTypeSymbol(
238
+ return createSymbol(
239
+ NamedTypeSymbol,
232
240
  namekey(name),
233
241
  ownerSymbol.members,
234
242
  descriptor.kind,
@@ -239,7 +247,8 @@ function createSymbolFromDescriptor(
239
247
  },
240
248
  );
241
249
  case "method":
242
- return new MethodSymbol(
250
+ return createSymbol(
251
+ MethodSymbol,
243
252
  namekey(name),
244
253
  ownerSymbol.members,
245
254
  descriptor.methodKind,
@@ -250,7 +259,7 @@ function createSymbolFromDescriptor(
250
259
  );
251
260
  case "field":
252
261
  case "property":
253
- return new CSharpSymbol(namekey(name), ownerSymbol.members, {
262
+ return createSymbol(CSharpSymbol, namekey(name), ownerSymbol.members, {
254
263
  binder,
255
264
  refkeys: refkey(),
256
265
  type:
@@ -262,7 +271,7 @@ function createSymbolFromDescriptor(
262
271
  lazyMemberInitializer,
263
272
  });
264
273
  case "generic":
265
- return new CSharpSymbol(namekey(name), ownerSymbol.members, {
274
+ return createSymbol(CSharpSymbol, namekey(name), ownerSymbol.members, {
266
275
  binder,
267
276
  refkeys: refkey(),
268
277
  });
@@ -20,4 +20,15 @@ export class CSharpScope extends OutputScope {
20
20
  get ownerSymbol(): CSharpSymbol | undefined {
21
21
  return super.ownerSymbol as CSharpSymbol | undefined;
22
22
  }
23
+
24
+ override get debugInfo(): Record<string, unknown> {
25
+ const info = super.debugInfo;
26
+ if (this.enclosingNamespace) {
27
+ return {
28
+ ...info,
29
+ enclosingNamespace: this.enclosingNamespace.name,
30
+ };
31
+ }
32
+ return info;
33
+ }
23
34
  }
@@ -1,4 +1,4 @@
1
- import { OutputScopeOptions } from "@alloy-js/core";
1
+ import { OutputScopeOptions, createScope } from "@alloy-js/core";
2
2
  import { NamedTypeSymbol } from "../symbols/named-type.js";
3
3
  import { CSharpClassScope } from "./class.js";
4
4
  import { useCSharpScope, useNamedTypeScope } from "./contexts.js";
@@ -21,7 +21,7 @@ export function createNamedTypeScope(
21
21
  );
22
22
  }
23
23
 
24
- return new CSharpNamedTypeScope(ownerSymbol, currentScope, options);
24
+ return createScope(CSharpNamedTypeScope, ownerSymbol, currentScope, options);
25
25
  }
26
26
 
27
27
  export function createClassScope(
@@ -37,9 +37,9 @@ export function createClassScope(
37
37
  "Can't create C# class scope inside of " + currentScope.constructor.name,
38
38
  );
39
39
  }
40
- return new CSharpClassScope(ownerSymbol, currentScope, options);
40
+ return createScope(CSharpClassScope, ownerSymbol, currentScope, options);
41
41
  }
42
42
  export function createMethodScope(options: OutputScopeOptions = {}) {
43
43
  const parentScope = useNamedTypeScope();
44
- return new CSharpMethodScope("method scope", parentScope, options);
44
+ return createScope(CSharpMethodScope, "method scope", parentScope, options);
45
45
  }
@@ -1,4 +1,4 @@
1
- import { OutputScope, useScope } from "@alloy-js/core";
1
+ import { OutputScope, createScope, useScope } from "@alloy-js/core";
2
2
  import type { NamespaceSymbol } from "../symbols/namespace.js";
3
3
  import { CSharpNamedTypeScope } from "./named-type.js";
4
4
  import { CSharpSourceFileScope } from "./source-file.js";
@@ -32,7 +32,7 @@ export function createCSharpNamespaceScope(namespaceSymbol: NamespaceSymbol) {
32
32
  );
33
33
  }
34
34
 
35
- const scope = new CSharpNamespaceScope(namespaceSymbol, parentScope);
35
+ const scope = createScope(CSharpNamespaceScope, namespaceSymbol, parentScope);
36
36
 
37
37
  return scope;
38
38
  }
@@ -1,4 +1,5 @@
1
1
  import {
2
+ createSymbol,
2
3
  Namekey,
3
4
  OutputDeclarationSpace,
4
5
  OutputMemberSpace,
@@ -128,8 +129,10 @@ export class CSharpSymbol extends OutputSymbol {
128
129
 
129
130
  copy() {
130
131
  const options = this.getCopyOptions();
131
- const copy = new CSharpSymbol(this.name, undefined, {
132
+ const binder = this.binder;
133
+ const copy = createSymbol(CSharpSymbol, this.name, undefined, {
132
134
  ...options,
135
+ binder,
133
136
  accessibility: this.#accessibility,
134
137
  isStatic: this.#isStatic,
135
138
  isVirtual: this.#isVirtual,
@@ -151,6 +154,22 @@ export class CSharpSymbol extends OutputSymbol {
151
154
  return copy;
152
155
  }
153
156
 
157
+ override get debugInfo(): Record<string, unknown> {
158
+ return {
159
+ ...super.debugInfo,
160
+ kind: this.symbolKind,
161
+ accessibility: this.accessibility,
162
+ isAbstract: this.isAbstract,
163
+ isVirtual: this.isVirtual,
164
+ isOverride: this.isOverride,
165
+ isStatic: this.isStatic,
166
+ isSealed: this.isSealed,
167
+ isExtern: this.isExtern,
168
+ isReadOnly: this.isReadOnly,
169
+ isNullable: this.isNullable,
170
+ };
171
+ }
172
+
154
173
  /**
155
174
  * Whether this symbol is static.
156
175
  */
@@ -1,4 +1,5 @@
1
1
  import {
2
+ createSymbol,
2
3
  Namekey,
3
4
  NamePolicyGetter,
4
5
  onCleanup,
@@ -37,11 +38,11 @@ export function createParameterSymbol(
37
38
  `Can't create parameter symbol outside of a method or class scope.`,
38
39
  );
39
40
  }
40
- return new CSharpSymbol(
41
- originalName,
42
- scope.parameters,
43
- withNamePolicy(options, "parameter"),
44
- );
41
+ const binder = options.binder ?? scope.binder;
42
+ return createSymbol(CSharpSymbol, originalName, scope.parameters, {
43
+ ...withNamePolicy(options, "parameter"),
44
+ binder,
45
+ });
45
46
  }
46
47
 
47
48
  export interface CreateTypeParameterSymbolOptions extends CSharpSymbolOptions {
@@ -61,11 +62,11 @@ export function createTypeParameterSymbol(
61
62
  );
62
63
  }
63
64
 
64
- return new CSharpSymbol(
65
- originalName,
66
- scope.typeParameters,
67
- withNamePolicy(options, "type-parameter"),
68
- );
65
+ const binder = options.binder ?? scope.binder;
66
+ return createSymbol(CSharpSymbol, originalName, scope.typeParameters, {
67
+ ...withNamePolicy(options, "type-parameter"),
68
+ binder,
69
+ });
69
70
  }
70
71
 
71
72
  export function createFieldSymbol(
@@ -91,11 +92,11 @@ export function createFieldSymbol(
91
92
  throw new Error(`Can't define a field outside of a class or struct.`);
92
93
  }
93
94
 
94
- return new CSharpSymbol(
95
- originalName,
96
- scope.members,
97
- withNamePolicy(options, nameElement),
98
- );
95
+ const binder = options.binder ?? scope.binder;
96
+ return createSymbol(CSharpSymbol, originalName, scope.members, {
97
+ ...withNamePolicy(options, nameElement),
98
+ binder,
99
+ });
99
100
  }
100
101
 
101
102
  function withCleanup<T extends CSharpSymbol>(sym: T): T {
@@ -111,8 +112,12 @@ export function createNamedTypeSymbol(
111
112
  options?: OutputSymbolOptions,
112
113
  ) {
113
114
  const scope = useNamedTypeScope();
115
+ const binder = options?.binder ?? scope.ownerSymbol.binder;
114
116
  return withCleanup(
115
- new NamedTypeSymbol(name, scope.ownerSymbol.members, kind, options),
117
+ createSymbol(NamedTypeSymbol, name, scope.ownerSymbol.members, kind, {
118
+ ...options,
119
+ binder,
120
+ }),
116
121
  );
117
122
  }
118
123
 
@@ -121,7 +126,9 @@ export function createNamespaceSymbol(
121
126
  options: CSharpSymbolOptions = {},
122
127
  ): NamespaceSymbol {
123
128
  const scope = useNamespaceContext();
124
- const parentSymbol = scope?.symbol ?? getGlobalNamespace(useBinder());
129
+ const parentSymbol =
130
+ scope?.symbol ??
131
+ getGlobalNamespace(options.binder ?? scope?.symbol?.binder ?? useBinder());
125
132
  const names = normalizeNamespaceName(name);
126
133
  let current = parentSymbol;
127
134
  for (const name of names) {
@@ -155,12 +162,12 @@ function createNamespaceSymbolInternal(
155
162
  expectedName,
156
163
  )! as NamespaceSymbol;
157
164
  }
165
+ const binder = options.binder ?? parentSymbol.binder;
158
166
  return withCleanup(
159
- new NamespaceSymbol(
160
- name,
161
- parentSymbol,
162
- withNamePolicy(options, "namespace"),
163
- ),
167
+ createSymbol(NamespaceSymbol, name, parentSymbol, {
168
+ ...withNamePolicy(options, "namespace"),
169
+ binder,
170
+ }),
164
171
  );
165
172
  }
166
173
 
@@ -184,12 +191,17 @@ export function createMethodSymbol(
184
191
  );
185
192
  }
186
193
 
194
+ const binder = options.binder ?? scope.binder;
187
195
  return withCleanup(
188
- new MethodSymbol(
196
+ createSymbol(
197
+ MethodSymbol,
189
198
  originalName,
190
199
  scope.members,
191
200
  options.methodKind ?? "ordinary",
192
- withNamePolicy(options, "class-method"),
201
+ {
202
+ ...withNamePolicy(options, "class-method"),
203
+ binder,
204
+ },
193
205
  ),
194
206
  );
195
207
  }
@@ -199,12 +211,12 @@ export function createPropertySymbol(
199
211
  options: CSharpSymbolOptions,
200
212
  ) {
201
213
  const scope = useNamedTypeScope();
214
+ const binder = options.binder ?? scope.binder;
202
215
  return withCleanup(
203
- new CSharpSymbol(
204
- name,
205
- scope.members,
206
- withNamePolicy(options, "class-property"),
207
- ),
216
+ createSymbol(CSharpSymbol, name, scope.members, {
217
+ ...withNamePolicy(options, "class-property"),
218
+ binder,
219
+ }),
208
220
  );
209
221
  }
210
222
 
@@ -232,12 +244,12 @@ export function createVariableSymbol(
232
244
  `Can't create variable symbol outside of a lexical scope, got a ${scope.constructor.name}.`,
233
245
  );
234
246
  }
247
+ const binder = options.binder ?? scope.binder;
235
248
  return withCleanup(
236
- new CSharpSymbol(
237
- originalName,
238
- scope.localVariables,
239
- withNamePolicy(options, "variable"),
240
- ),
249
+ createSymbol(CSharpSymbol, originalName, scope.localVariables, {
250
+ ...withNamePolicy(options, "variable"),
251
+ binder,
252
+ }),
241
253
  );
242
254
  }
243
255
 
@@ -1,4 +1,4 @@
1
- import { Namekey, OutputSpace } from "@alloy-js/core";
1
+ import { Namekey, OutputSpace, createSymbol } from "@alloy-js/core";
2
2
  import { CSharpSymbol, CSharpSymbolOptions } from "./csharp.js";
3
3
 
4
4
  // represents a symbol from a .cs file. Class, enum, interface etc.
@@ -38,11 +38,16 @@ export class NamedTypeSymbol extends CSharpSymbol {
38
38
 
39
39
  copy() {
40
40
  const options = this.getCopyOptions();
41
- const copy = new NamedTypeSymbol(
41
+ const binder = this.binder;
42
+ const copy = createSymbol(
43
+ NamedTypeSymbol,
42
44
  this.name,
43
45
  undefined,
44
46
  this.#typeKind,
45
- options,
47
+ {
48
+ ...options,
49
+ binder,
50
+ },
46
51
  );
47
52
  this.initializeCopy(copy);
48
53
  return copy;
@@ -51,4 +56,11 @@ export class NamedTypeSymbol extends CSharpSymbol {
51
56
  get members() {
52
57
  return this.memberSpaceFor("members")!;
53
58
  }
59
+
60
+ override get debugInfo(): Record<string, unknown> {
61
+ return {
62
+ ...super.debugInfo,
63
+ typeKind: this.typeKind,
64
+ };
65
+ }
54
66
  }
@@ -1,4 +1,4 @@
1
- import { Namekey, OutputSymbolOptions } from "@alloy-js/core";
1
+ import { Namekey, OutputSymbolOptions, createSymbol } from "@alloy-js/core";
2
2
  import { NamedTypeSymbol } from "./named-type.js";
3
3
 
4
4
  export interface NamespaceSymbolOptions extends OutputSymbolOptions {
@@ -52,11 +52,21 @@ export class NamespaceSymbol extends NamedTypeSymbol {
52
52
 
53
53
  copy() {
54
54
  const options = this.getCopyOptions();
55
- const copy = new NamespaceSymbol(this.name, undefined, {
55
+ const binder = this.binder;
56
+ const copy = createSymbol(NamespaceSymbol, this.name, undefined, {
56
57
  ...options,
58
+ binder,
57
59
  isGlobal: this.#isGlobal,
58
60
  });
59
61
  this.initializeCopy(copy);
60
62
  return copy;
61
63
  }
64
+
65
+ override get debugInfo(): Record<string, unknown> {
66
+ return {
67
+ ...super.debugInfo,
68
+ isGlobal: this.isGlobal,
69
+ fullyQualifiedName: this.getFullyQualifiedName(),
70
+ };
71
+ }
62
72
  }