@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.
- package/dist/src/components/Declaration.js +2 -1
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/Name.js +2 -1
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/ProjectDirectory.js +2 -1
- package/dist/src/components/ProjectDirectory.js.map +1 -0
- package/dist/src/components/Reference.js +2 -1
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +5 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +20 -59
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/UsingDirective.js +2 -1
- package/dist/src/components/UsingDirective.js.map +1 -0
- package/dist/src/components/attributes/attributes.js +2 -1
- package/dist/src/components/attributes/attributes.js.map +1 -0
- package/dist/src/components/attributes/attributes.test.js +2 -1
- package/dist/src/components/attributes/attributes.test.js.map +1 -0
- package/dist/src/components/class/declaration.d.ts.map +1 -1
- package/dist/src/components/class/declaration.js +2 -1
- package/dist/src/components/class/declaration.js.map +1 -0
- package/dist/src/components/class/declaration.test.js +2 -1
- package/dist/src/components/class/declaration.test.js.map +1 -0
- package/dist/src/components/constructor/constructor.js +2 -1
- package/dist/src/components/constructor/constructor.js.map +1 -0
- package/dist/src/components/constructor/constructor.test.js +2 -1
- package/dist/src/components/constructor/constructor.test.js.map +1 -0
- package/dist/src/components/doc/comment.js +2 -1
- package/dist/src/components/doc/comment.js.map +1 -0
- package/dist/src/components/doc/comment.test.js +2 -1
- package/dist/src/components/doc/comment.test.js.map +1 -0
- package/dist/src/components/doc/from-markdown.js +2 -1
- package/dist/src/components/doc/from-markdown.js.map +1 -0
- package/dist/src/components/doc/from-markdown.test.js +2 -1
- package/dist/src/components/doc/from-markdown.test.js.map +1 -0
- package/dist/src/components/enum/declaration.js +2 -1
- package/dist/src/components/enum/declaration.js.map +1 -0
- package/dist/src/components/enum/declaration.ref.test.js +2 -1
- package/dist/src/components/enum/declaration.ref.test.js.map +1 -0
- package/dist/src/components/enum/declaration.test.js +2 -1
- package/dist/src/components/enum/declaration.test.js.map +1 -0
- package/dist/src/components/enum/member.js +2 -1
- package/dist/src/components/enum/member.js.map +1 -0
- package/dist/src/components/enum/member.test.js +2 -1
- package/dist/src/components/enum/member.test.js.map +1 -0
- package/dist/src/components/field/field.js +2 -1
- package/dist/src/components/field/field.js.map +1 -0
- package/dist/src/components/field/field.test.js +2 -1
- package/dist/src/components/field/field.test.js.map +1 -0
- package/dist/src/components/index.js +2 -1
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/declaration.js +2 -1
- package/dist/src/components/interface/declaration.js.map +1 -0
- package/dist/src/components/interface/declaration.test.js +2 -1
- package/dist/src/components/interface/declaration.test.js.map +1 -0
- package/dist/src/components/interface/method.js +2 -1
- package/dist/src/components/interface/method.js.map +1 -0
- package/dist/src/components/interface/method.test.js +2 -1
- package/dist/src/components/interface/method.test.js.map +1 -0
- package/dist/src/components/interface/property.js +2 -1
- package/dist/src/components/interface/property.js.map +1 -0
- package/dist/src/components/interface/property.test.js +2 -1
- package/dist/src/components/interface/property.test.js.map +1 -0
- package/dist/src/components/lexical-scope.js +2 -1
- package/dist/src/components/lexical-scope.js.map +1 -0
- package/dist/src/components/method/method.js +2 -1
- package/dist/src/components/method/method.js.map +1 -0
- package/dist/src/components/method/method.test.js +2 -1
- package/dist/src/components/method/method.test.js.map +1 -0
- package/dist/src/components/method-scope.js +2 -1
- package/dist/src/components/method-scope.js.map +1 -0
- package/dist/src/components/namespace-scopes.js +2 -1
- package/dist/src/components/namespace-scopes.js.map +1 -0
- package/dist/src/components/namespace.js +2 -1
- package/dist/src/components/namespace.js.map +1 -0
- package/dist/src/components/namespace.ref.test.js +2 -1
- package/dist/src/components/namespace.ref.test.js.map +1 -0
- package/dist/src/components/namespace.test.js +2 -1
- package/dist/src/components/namespace.test.js.map +1 -0
- package/dist/src/components/parameters/parameters.js +2 -1
- package/dist/src/components/parameters/parameters.js.map +1 -0
- package/dist/src/components/parameters/parameters.test.js +2 -1
- package/dist/src/components/parameters/parameters.test.js.map +1 -0
- package/dist/src/components/property/property.js +2 -1
- package/dist/src/components/property/property.js.map +1 -0
- package/dist/src/components/property/property.test.js +2 -1
- package/dist/src/components/property/property.test.js.map +1 -0
- package/dist/src/components/record/declaration.js +2 -1
- package/dist/src/components/record/declaration.js.map +1 -0
- package/dist/src/components/record/declaration.test.js +2 -1
- package/dist/src/components/record/declaration.test.js.map +1 -0
- package/dist/src/components/stc/index.js +2 -1
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/components/struct/declaration.js +2 -1
- package/dist/src/components/struct/declaration.js.map +1 -0
- package/dist/src/components/struct/declaration.test.js +2 -1
- package/dist/src/components/struct/declaration.test.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.js +2 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js +2 -1
- package/dist/src/components/type-parameters/type-parameter-constraints.test.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameter.js +2 -1
- package/dist/src/components/type-parameters/type-parameter.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.js +2 -1
- package/dist/src/components/type-parameters/type-parameters.js.map +1 -0
- package/dist/src/components/type-parameters/type-parameters.test.js +2 -1
- package/dist/src/components/type-parameters/type-parameters.test.js.map +1 -0
- package/dist/src/components/var/declaration.js +2 -1
- package/dist/src/components/var/declaration.js.map +1 -0
- package/dist/src/components/var/declaration.test.js +2 -1
- package/dist/src/components/var/declaration.test.js.map +1 -0
- package/dist/src/contexts/global-namespace.js +2 -1
- package/dist/src/contexts/global-namespace.js.map +1 -0
- package/dist/src/contexts/namespace.js +2 -1
- package/dist/src/contexts/namespace.js.map +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/modifiers.js +2 -1
- package/dist/src/modifiers.js.map +1 -0
- package/dist/src/name-policy.js +2 -1
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/scopes/class.js +2 -1
- package/dist/src/scopes/class.js.map +1 -0
- package/dist/src/scopes/contexts.js +2 -1
- package/dist/src/scopes/contexts.js.map +1 -0
- package/dist/src/scopes/csharp.js +2 -1
- package/dist/src/scopes/csharp.js.map +1 -0
- package/dist/src/scopes/factories.js +2 -1
- package/dist/src/scopes/factories.js.map +1 -0
- package/dist/src/scopes/index.js +2 -1
- package/dist/src/scopes/index.js.map +1 -0
- package/dist/src/scopes/lexical.js +2 -1
- package/dist/src/scopes/lexical.js.map +1 -0
- package/dist/src/scopes/method.js +2 -1
- package/dist/src/scopes/method.js.map +1 -0
- package/dist/src/scopes/named-type.js +2 -1
- package/dist/src/scopes/named-type.js.map +1 -0
- package/dist/src/scopes/namespace.js +2 -1
- package/dist/src/scopes/namespace.js.map +1 -0
- package/dist/src/scopes/source-file.js +2 -1
- package/dist/src/scopes/source-file.js.map +1 -0
- package/dist/src/symbols/csharp.js +2 -1
- package/dist/src/symbols/csharp.js.map +1 -0
- package/dist/src/symbols/factories.d.ts.map +1 -1
- package/dist/src/symbols/factories.js +14 -7
- package/dist/src/symbols/factories.js.map +1 -0
- package/dist/src/symbols/index.js +2 -1
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/method.js +2 -1
- package/dist/src/symbols/method.js.map +1 -0
- package/dist/src/symbols/named-type.js +2 -1
- package/dist/src/symbols/named-type.js.map +1 -0
- package/dist/src/symbols/namespace.js +2 -1
- package/dist/src/symbols/namespace.js.map +1 -0
- package/dist/src/symbols/reference.js +2 -1
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/test/project-directory.test.js +2 -1
- package/dist/test/project-directory.test.js.map +1 -0
- package/dist/test/sourcefile.test.js +2 -1
- package/dist/test/sourcefile.test.js.map +1 -0
- package/dist/test/using.test.js +2 -1
- package/dist/test/using.test.js.map +1 -0
- package/dist/test/utils.js +2 -1
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/src/components/SourceFile.tsx +27 -30
- package/src/components/class/declaration.tsx +1 -0
- package/src/symbols/factories.ts +31 -15
- package/temp/api.json +3 -3
- 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 {
|
|
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
|
-
|
|
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
|
-
|
|
62
|
-
|
|
68
|
+
{nsSymbol === globalNs ?
|
|
69
|
+
content
|
|
70
|
+
: <>
|
|
63
71
|
namespace {nsRef}
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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 = [
|
package/src/symbols/factories.ts
CHANGED
|
@@ -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
|
|
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
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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"],
|