@alloy-js/csharp 0.21.0-dev.2 → 0.21.0-dev.4
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/enum/declaration.ref.test.js +1 -1
- package/dist/src/components/index.d.ts +1 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -2
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/namespace/namespace-name.d.ts +10 -0
- package/dist/src/components/namespace/namespace-name.d.ts.map +1 -0
- package/dist/src/components/namespace/namespace-name.js +20 -0
- package/dist/src/components/namespace/namespace-name.js.map +1 -0
- package/dist/src/components/{namespace.d.ts → namespace/namespace.d.ts} +1 -1
- package/dist/src/components/namespace/namespace.d.ts.map +1 -0
- package/dist/src/components/{namespace.js → namespace/namespace.js} +9 -12
- package/dist/src/components/namespace/namespace.js.map +1 -0
- package/dist/src/components/namespace/namespace.test.d.ts.map +1 -0
- package/dist/src/components/namespace/namespace.test.js +207 -0
- package/dist/src/components/namespace/namespace.test.js.map +1 -0
- package/dist/src/components/namespace.ref.test.js +1 -1
- package/dist/src/components/source-file/source-file.d.ts.map +1 -1
- package/dist/src/components/source-file/source-file.js +4 -2
- package/dist/src/components/source-file/source-file.js.map +1 -1
- package/dist/src/components/source-file/source-file.test.js +1 -1
- package/dist/src/components/source-file/using.test.js +1 -1
- package/dist/src/symbols/factories.d.ts +1 -1
- package/dist/src/symbols/factories.d.ts.map +1 -1
- package/dist/src/symbols/factories.js +24 -6
- package/dist/src/symbols/factories.js.map +1 -1
- package/dist/src/symbols/reference.js +2 -2
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/enum/declaration.ref.test.tsx +1 -1
- package/src/components/index.ts +1 -1
- package/src/components/namespace/namespace-name.tsx +31 -0
- package/src/components/namespace/namespace.test.tsx +145 -0
- package/src/components/{namespace.tsx → namespace/namespace.tsx} +7 -13
- package/src/components/namespace.ref.test.tsx +1 -1
- package/src/components/source-file/source-file.test.tsx +1 -1
- package/src/components/source-file/source-file.tsx +2 -2
- package/src/components/source-file/using.test.tsx +1 -1
- package/src/symbols/factories.ts +39 -10
- package/src/symbols/reference.tsx +2 -2
- package/temp/api.json +34 -8
- package/dist/src/components/namespace.d.ts.map +0 -1
- package/dist/src/components/namespace.js.map +0 -1
- package/dist/src/components/namespace.test.d.ts.map +0 -1
- package/dist/src/components/namespace.test.js +0 -93
- package/dist/src/components/namespace.test.js.map +0 -1
- package/src/components/namespace.test.tsx +0 -65
- /package/dist/src/components/{namespace.test.d.ts → namespace/namespace.test.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/csharp",
|
|
3
|
-
"version": "0.21.0-dev.
|
|
3
|
+
"version": "0.21.0-dev.4",
|
|
4
4
|
"description": "Alloy components for CSharp language.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"author": "jhendrix@microsoft.com",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@alloy-js/core": "~0.20.0 || >= 0.21.0-dev.
|
|
23
|
+
"@alloy-js/core": "~0.20.0 || >= 0.21.0-dev.2",
|
|
24
24
|
"change-case": "^5.4.4",
|
|
25
25
|
"marked": "^16.1.1",
|
|
26
26
|
"pathe": "^2.0.3"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Namespace } from "#components/namespace.jsx";
|
|
1
|
+
import { Namespace } from "#components/namespace/namespace.jsx";
|
|
2
2
|
import { SourceFile } from "#components/source-file/source-file.jsx";
|
|
3
3
|
import { Output, refkey } from "@alloy-js/core";
|
|
4
4
|
import { d } from "@alloy-js/core/testing";
|
package/src/components/index.ts
CHANGED
|
@@ -15,7 +15,7 @@ export * from "./lexical-scope.jsx";
|
|
|
15
15
|
export * from "./method-scope.jsx";
|
|
16
16
|
export * from "./method/method.jsx";
|
|
17
17
|
export * from "./Name.js";
|
|
18
|
-
export
|
|
18
|
+
export { Namespace, type NamespaceProps } from "./namespace/namespace.jsx";
|
|
19
19
|
export * from "./parameters/parameters.jsx";
|
|
20
20
|
export * from "./ProjectDirectory.js";
|
|
21
21
|
export * from "./property/property.jsx";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useNamespaceContext } from "../../contexts/namespace.js";
|
|
2
|
+
import { NamespaceSymbol } from "../../symbols/namespace.js";
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export interface NamespaceNameProps {
|
|
6
|
+
symbol: NamespaceSymbol;
|
|
7
|
+
|
|
8
|
+
/** If it should print relative to the parent context */
|
|
9
|
+
relative?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** @internal */
|
|
13
|
+
export function NamespaceName(props: NamespaceNameProps) {
|
|
14
|
+
const names = [props.symbol.name];
|
|
15
|
+
const parent = props.relative ? useNamespaceContext()?.symbol : undefined;
|
|
16
|
+
|
|
17
|
+
let current = props.symbol.ownerSymbol;
|
|
18
|
+
while (current) {
|
|
19
|
+
if (
|
|
20
|
+
current === parent ||
|
|
21
|
+
!(current instanceof NamespaceSymbol) ||
|
|
22
|
+
current.isGlobal
|
|
23
|
+
) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
names.unshift(current.name);
|
|
27
|
+
current = current.ownerSymbol;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return names.join(".");
|
|
31
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { TestNamespace } from "#test/utils.jsx";
|
|
2
|
+
import { Output } from "@alloy-js/core";
|
|
3
|
+
import { d } from "@alloy-js/core/testing";
|
|
4
|
+
import { expect, it } from "vitest";
|
|
5
|
+
import { ClassDeclaration } from "../class/declaration.jsx";
|
|
6
|
+
import { SourceFile } from "../source-file/source-file.jsx";
|
|
7
|
+
import { Namespace } from "./namespace.jsx";
|
|
8
|
+
|
|
9
|
+
it("defines multiple namespaces and source files with unique content", () => {
|
|
10
|
+
const tree = (
|
|
11
|
+
<Output>
|
|
12
|
+
<Namespace name="Namespace1">
|
|
13
|
+
<SourceFile path="Model1.cs">
|
|
14
|
+
<ClassDeclaration public name="Model1" />
|
|
15
|
+
</SourceFile>
|
|
16
|
+
<SourceFile path="Model2.cs">
|
|
17
|
+
<ClassDeclaration public name="Model2" />
|
|
18
|
+
</SourceFile>
|
|
19
|
+
</Namespace>
|
|
20
|
+
<Namespace name="Namespace2">
|
|
21
|
+
<SourceFile path="Model3.cs">
|
|
22
|
+
<ClassDeclaration public name="Model3" />
|
|
23
|
+
</SourceFile>
|
|
24
|
+
<SourceFile path="Model4.cs">
|
|
25
|
+
<ClassDeclaration public name="Model4" />
|
|
26
|
+
</SourceFile>
|
|
27
|
+
</Namespace>
|
|
28
|
+
</Output>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect(tree).toRenderTo({
|
|
32
|
+
"Model1.cs": d`
|
|
33
|
+
namespace Namespace1;
|
|
34
|
+
|
|
35
|
+
public class Model1;
|
|
36
|
+
`,
|
|
37
|
+
"Model2.cs": d`
|
|
38
|
+
namespace Namespace1;
|
|
39
|
+
|
|
40
|
+
public class Model2;
|
|
41
|
+
`,
|
|
42
|
+
"Model3.cs": d`
|
|
43
|
+
namespace Namespace2;
|
|
44
|
+
|
|
45
|
+
public class Model3;
|
|
46
|
+
`,
|
|
47
|
+
"Model4.cs": d`
|
|
48
|
+
namespace Namespace2;
|
|
49
|
+
|
|
50
|
+
public class Model4;
|
|
51
|
+
`,
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("nest namespaces", () => {
|
|
56
|
+
const tree = (
|
|
57
|
+
<Output>
|
|
58
|
+
<Namespace name={["Namespace1"]}>
|
|
59
|
+
<Namespace name={["Namespace2"]}>
|
|
60
|
+
<SourceFile path="Model1.cs">
|
|
61
|
+
<ClassDeclaration public name="Model1" />
|
|
62
|
+
</SourceFile>
|
|
63
|
+
</Namespace>
|
|
64
|
+
</Namespace>
|
|
65
|
+
</Output>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
expect(tree).toRenderTo(`
|
|
69
|
+
namespace Namespace1.Namespace2;
|
|
70
|
+
|
|
71
|
+
public class Model1;
|
|
72
|
+
`);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("define nested namespace directly with array", () => {
|
|
76
|
+
const tree = (
|
|
77
|
+
<Output>
|
|
78
|
+
<Namespace name={["Namespace1", "Namespace2"]}>
|
|
79
|
+
<SourceFile path="Model1.cs">
|
|
80
|
+
<ClassDeclaration public name="Model1" />
|
|
81
|
+
</SourceFile>
|
|
82
|
+
</Namespace>
|
|
83
|
+
</Output>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(tree).toRenderTo(`
|
|
87
|
+
namespace Namespace1.Namespace2;
|
|
88
|
+
|
|
89
|
+
public class Model1;
|
|
90
|
+
`);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("define nested namespace directly as dotted notation", () => {
|
|
94
|
+
const tree = (
|
|
95
|
+
<Output>
|
|
96
|
+
<Namespace name="Namespace1.Namespace2">
|
|
97
|
+
<SourceFile path="Model1.cs">
|
|
98
|
+
<ClassDeclaration public name="Model1" />
|
|
99
|
+
</SourceFile>
|
|
100
|
+
</Namespace>
|
|
101
|
+
</Output>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
expect(tree).toRenderTo({
|
|
105
|
+
"Model1.cs": d`
|
|
106
|
+
namespace Namespace1.Namespace2;
|
|
107
|
+
|
|
108
|
+
public class Model1;
|
|
109
|
+
`,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("uses a name policy", () => {
|
|
114
|
+
expect(
|
|
115
|
+
<TestNamespace>
|
|
116
|
+
<Namespace name="my-namespace" />
|
|
117
|
+
</TestNamespace>,
|
|
118
|
+
).toRenderTo(`
|
|
119
|
+
namespace MyNamespace {
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
`);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("define nested namespace in sourcefile", () => {
|
|
126
|
+
const tree = (
|
|
127
|
+
<Output>
|
|
128
|
+
<Namespace name="Base">
|
|
129
|
+
<SourceFile path="Model1.cs">
|
|
130
|
+
<Namespace name="Namespace1.Namespace2">
|
|
131
|
+
<ClassDeclaration public name="Model1" />
|
|
132
|
+
</Namespace>
|
|
133
|
+
</SourceFile>
|
|
134
|
+
</Namespace>
|
|
135
|
+
</Output>
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
expect(tree).toRenderTo(`
|
|
139
|
+
namespace Base {
|
|
140
|
+
namespace Namespace1.Namespace2 {
|
|
141
|
+
public class Model1;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`);
|
|
145
|
+
});
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Block, Namekey, Refkey } from "@alloy-js/core";
|
|
2
2
|
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
-
import { NamespaceContext } from "
|
|
4
|
-
import { useSourceFileScope } from "
|
|
5
|
-
import { createNamespaceSymbol } from "
|
|
6
|
-
import { NamespaceScope } from "
|
|
3
|
+
import { NamespaceContext } from "../../contexts/namespace.js";
|
|
4
|
+
import { useSourceFileScope } from "../../scopes/source-file.js";
|
|
5
|
+
import { createNamespaceSymbol } from "../../symbols/factories.js";
|
|
6
|
+
import { NamespaceScope } from "../namespace-scopes.jsx";
|
|
7
|
+
import { NamespaceName } from "./namespace-name.jsx";
|
|
7
8
|
|
|
8
9
|
export interface NamespaceProps {
|
|
9
|
-
name: string | Namekey;
|
|
10
|
+
name: string | Namekey | (string | Namekey)[];
|
|
10
11
|
refkey?: Refkey | Refkey[];
|
|
11
12
|
children?: Children;
|
|
12
13
|
}
|
|
@@ -27,7 +28,7 @@ export function Namespace(props: NamespaceProps) {
|
|
|
27
28
|
sfScope.hasBlockNamespace = true;
|
|
28
29
|
return (
|
|
29
30
|
<>
|
|
30
|
-
namespace {namespaceSymbol
|
|
31
|
+
namespace <NamespaceName symbol={namespaceSymbol} relative />{" "}
|
|
31
32
|
<Block>
|
|
32
33
|
<NamespaceContext.Provider value={{ symbol: namespaceSymbol }}>
|
|
33
34
|
<NamespaceScope symbol={namespaceSymbol}>
|
|
@@ -39,10 +40,3 @@ export function Namespace(props: NamespaceProps) {
|
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
-
/*
|
|
44
|
-
const scope = createCSharpNamespaceScope(namespaceSymbol);
|
|
45
|
-
|
|
46
|
-
return <Scope value={scope}>{props.children}</Scope>;
|
|
47
|
-
}
|
|
48
|
-
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { List, memberRefkey, namekey, Output, refkey } from "@alloy-js/core";
|
|
2
2
|
import { expect, it } from "vitest";
|
|
3
3
|
import { ClassDeclaration } from "./class/declaration.jsx";
|
|
4
|
-
import { Namespace } from "./namespace.jsx";
|
|
4
|
+
import { Namespace } from "./namespace/namespace.jsx";
|
|
5
5
|
import { SourceFile } from "./source-file/source-file.jsx";
|
|
6
6
|
|
|
7
7
|
it("references types in the same namespace", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassDeclaration } from "#components/class/declaration.jsx";
|
|
2
|
-
import { Namespace } from "#components/namespace.jsx";
|
|
2
|
+
import { Namespace } from "#components/namespace/namespace.jsx";
|
|
3
3
|
import { Children, FormatOptions, Indent, Output, Prose } from "@alloy-js/core";
|
|
4
4
|
import { describe, expect, it } from "vitest";
|
|
5
5
|
import { CSharpFormatOptions } from "../../contexts/format-options.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NamespaceScopes } from "#components/namespace-scopes.jsx";
|
|
2
|
+
import { NamespaceName } from "#components/namespace/namespace-name.jsx";
|
|
2
3
|
import { Reference } from "#components/Reference.jsx";
|
|
3
4
|
import { Usings } from "#components/using/using.jsx";
|
|
4
5
|
import {
|
|
@@ -42,7 +43,6 @@ export function SourceFile(props: SourceFileProps) {
|
|
|
42
43
|
const nsContext = useNamespaceContext();
|
|
43
44
|
const globalNs = getGlobalNamespace(useBinder());
|
|
44
45
|
const nsSymbol = nsContext ? nsContext.symbol : globalNs;
|
|
45
|
-
const nsRef = nsContext ? nsContext.symbol.name : undefined;
|
|
46
46
|
const usings = computed(() => {
|
|
47
47
|
return (
|
|
48
48
|
Array.from(sourceFileScope.usings) as (NamespaceSymbol | string)[]
|
|
@@ -78,7 +78,7 @@ export function SourceFile(props: SourceFileProps) {
|
|
|
78
78
|
{nsSymbol === globalNs ?
|
|
79
79
|
content
|
|
80
80
|
: <>
|
|
81
|
-
namespace {
|
|
81
|
+
namespace <NamespaceName symbol={nsSymbol} />
|
|
82
82
|
{sourceFileScope.hasBlockNamespace ?
|
|
83
83
|
<>
|
|
84
84
|
{" "}
|
|
@@ -2,7 +2,7 @@ import { ClassDeclaration } from "#components/class/declaration.jsx";
|
|
|
2
2
|
import { EnumDeclaration } from "#components/enum/declaration.jsx";
|
|
3
3
|
import { EnumMember } from "#components/enum/member.jsx";
|
|
4
4
|
import { Method } from "#components/method/method.jsx";
|
|
5
|
-
import { Namespace } from "#components/namespace.jsx";
|
|
5
|
+
import { Namespace } from "#components/namespace/namespace.jsx";
|
|
6
6
|
import { SourceFile } from "#components/source-file/source-file.jsx";
|
|
7
7
|
import { Output, refkey } from "@alloy-js/core";
|
|
8
8
|
import * as coretest from "@alloy-js/core/testing";
|
package/src/symbols/factories.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useBinder,
|
|
7
7
|
} from "@alloy-js/core";
|
|
8
8
|
import { getGlobalNamespace } from "../contexts/global-namespace.js";
|
|
9
|
+
import { useNamespaceContext } from "../contexts/namespace.js";
|
|
9
10
|
import { CSharpElements, useCSharpNamePolicy } from "../name-policy.js";
|
|
10
11
|
import { CSharpClassScope } from "../scopes/class.js";
|
|
11
12
|
import { useCSharpScope, useNamedTypeScope } from "../scopes/contexts.js";
|
|
@@ -13,10 +14,7 @@ import { CSharpScope } from "../scopes/csharp.js";
|
|
|
13
14
|
import { CSharpLexicalScope } from "../scopes/lexical.js";
|
|
14
15
|
import { CSharpMethodScope } from "../scopes/method.js";
|
|
15
16
|
import { CSharpNamedTypeScope } from "../scopes/named-type.js";
|
|
16
|
-
import {
|
|
17
|
-
CSharpNamespaceScope,
|
|
18
|
-
useEnclosingNamespaceScope,
|
|
19
|
-
} from "../scopes/namespace.js";
|
|
17
|
+
import { CSharpNamespaceScope } from "../scopes/namespace.js";
|
|
20
18
|
import { CSharpSourceFileScope } from "../scopes/source-file.js";
|
|
21
19
|
import { CSharpSymbol, CSharpSymbolOptions } from "./csharp.js";
|
|
22
20
|
import { MethodKinds, MethodSymbol } from "./method.js";
|
|
@@ -119,19 +117,50 @@ export function createNamedTypeSymbol(
|
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
export function createNamespaceSymbol(
|
|
120
|
+
name: string | Namekey | (string | Namekey)[],
|
|
121
|
+
options: CSharpSymbolOptions = {},
|
|
122
|
+
): NamespaceSymbol {
|
|
123
|
+
const scope = useNamespaceContext();
|
|
124
|
+
const parentSymbol = scope?.symbol ?? getGlobalNamespace(useBinder());
|
|
125
|
+
const names = normalizeNamespaceName(name);
|
|
126
|
+
let current = parentSymbol;
|
|
127
|
+
for (const name of names) {
|
|
128
|
+
current = createNamespaceSymbolInternal(name, current, options);
|
|
129
|
+
}
|
|
130
|
+
return current;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function normalizeNamespaceName(
|
|
134
|
+
name: string | Namekey | (string | Namekey)[],
|
|
135
|
+
): (string | Namekey)[] {
|
|
136
|
+
if (Array.isArray(name)) {
|
|
137
|
+
return name;
|
|
138
|
+
}
|
|
139
|
+
if (typeof name === "string" && name.includes(".")) {
|
|
140
|
+
return name.split(".");
|
|
141
|
+
}
|
|
142
|
+
return [name];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function createNamespaceSymbolInternal(
|
|
122
146
|
name: string | Namekey,
|
|
147
|
+
parentSymbol: NamespaceSymbol,
|
|
123
148
|
options: CSharpSymbolOptions = {},
|
|
124
|
-
) {
|
|
125
|
-
const scope = useEnclosingNamespaceScope();
|
|
126
|
-
const nsSymbol = scope?.ownerSymbol ?? getGlobalNamespace(useBinder());
|
|
149
|
+
): NamespaceSymbol {
|
|
127
150
|
const namePolicy =
|
|
128
151
|
options.namePolicy ?? useCSharpNamePolicy().for("namespace");
|
|
129
152
|
const expectedName = namePolicy(typeof name === "string" ? name : name.name);
|
|
130
|
-
if (
|
|
131
|
-
return
|
|
153
|
+
if (parentSymbol.members.symbolNames.has(expectedName)) {
|
|
154
|
+
return parentSymbol.members.symbolNames.get(
|
|
155
|
+
expectedName,
|
|
156
|
+
)! as NamespaceSymbol;
|
|
132
157
|
}
|
|
133
158
|
return withCleanup(
|
|
134
|
-
new NamespaceSymbol(
|
|
159
|
+
new NamespaceSymbol(
|
|
160
|
+
name,
|
|
161
|
+
parentSymbol,
|
|
162
|
+
withNamePolicy(options, "namespace"),
|
|
163
|
+
),
|
|
135
164
|
);
|
|
136
165
|
}
|
|
137
166
|
|
|
@@ -17,7 +17,7 @@ export function ref(
|
|
|
17
17
|
const resolveResult = resolve<CSharpScope, CSharpSymbol>(refkey as Refkey);
|
|
18
18
|
return memo(() => {
|
|
19
19
|
if (resolveResult.value === undefined) {
|
|
20
|
-
return [
|
|
20
|
+
return [`unresolvedRefkey(refkey)`, undefined];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const result = resolveResult.value;
|
|
@@ -26,7 +26,7 @@ export function ref(
|
|
|
26
26
|
|
|
27
27
|
if (!commonScope) {
|
|
28
28
|
// this shouldn't be possible in csharp.
|
|
29
|
-
return [
|
|
29
|
+
return [`unresolvedRefkey(refkey)`, undefined];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
if (
|
package/temp/api.json
CHANGED
|
@@ -2067,6 +2067,19 @@
|
|
|
2067
2067
|
"text": "Namekey",
|
|
2068
2068
|
"canonicalReference": "@alloy-js/core!Namekey:interface"
|
|
2069
2069
|
},
|
|
2070
|
+
{
|
|
2071
|
+
"kind": "Content",
|
|
2072
|
+
"text": " | (string | "
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
"kind": "Reference",
|
|
2076
|
+
"text": "Namekey",
|
|
2077
|
+
"canonicalReference": "@alloy-js/core!Namekey:interface"
|
|
2078
|
+
},
|
|
2079
|
+
{
|
|
2080
|
+
"kind": "Content",
|
|
2081
|
+
"text": ")[]"
|
|
2082
|
+
},
|
|
2070
2083
|
{
|
|
2071
2084
|
"kind": "Content",
|
|
2072
2085
|
"text": ", options?: "
|
|
@@ -2092,8 +2105,8 @@
|
|
|
2092
2105
|
],
|
|
2093
2106
|
"fileUrlPath": "src/symbols/factories.ts",
|
|
2094
2107
|
"returnTypeTokenRange": {
|
|
2095
|
-
"startIndex":
|
|
2096
|
-
"endIndex":
|
|
2108
|
+
"startIndex": 9,
|
|
2109
|
+
"endIndex": 10
|
|
2097
2110
|
},
|
|
2098
2111
|
"releaseTag": "Public",
|
|
2099
2112
|
"overloadIndex": 1,
|
|
@@ -2102,15 +2115,15 @@
|
|
|
2102
2115
|
"parameterName": "name",
|
|
2103
2116
|
"parameterTypeTokenRange": {
|
|
2104
2117
|
"startIndex": 1,
|
|
2105
|
-
"endIndex":
|
|
2118
|
+
"endIndex": 6
|
|
2106
2119
|
},
|
|
2107
2120
|
"isOptional": false
|
|
2108
2121
|
},
|
|
2109
2122
|
{
|
|
2110
2123
|
"parameterName": "options",
|
|
2111
2124
|
"parameterTypeTokenRange": {
|
|
2112
|
-
"startIndex":
|
|
2113
|
-
"endIndex":
|
|
2125
|
+
"startIndex": 7,
|
|
2126
|
+
"endIndex": 8
|
|
2114
2127
|
},
|
|
2115
2128
|
"isOptional": true
|
|
2116
2129
|
}
|
|
@@ -10150,7 +10163,7 @@
|
|
|
10150
10163
|
"text": ";"
|
|
10151
10164
|
}
|
|
10152
10165
|
],
|
|
10153
|
-
"fileUrlPath": "src/components/namespace.tsx",
|
|
10166
|
+
"fileUrlPath": "src/components/namespace/namespace.tsx",
|
|
10154
10167
|
"returnTypeTokenRange": {
|
|
10155
10168
|
"startIndex": 3,
|
|
10156
10169
|
"endIndex": 4
|
|
@@ -10179,7 +10192,7 @@
|
|
|
10179
10192
|
"text": "export interface NamespaceProps "
|
|
10180
10193
|
}
|
|
10181
10194
|
],
|
|
10182
|
-
"fileUrlPath": "src/components/namespace.tsx",
|
|
10195
|
+
"fileUrlPath": "src/components/namespace/namespace.tsx",
|
|
10183
10196
|
"releaseTag": "Public",
|
|
10184
10197
|
"name": "NamespaceProps",
|
|
10185
10198
|
"preserveMemberOrder": false,
|
|
@@ -10230,6 +10243,19 @@
|
|
|
10230
10243
|
"text": "Namekey",
|
|
10231
10244
|
"canonicalReference": "@alloy-js/core!Namekey:interface"
|
|
10232
10245
|
},
|
|
10246
|
+
{
|
|
10247
|
+
"kind": "Content",
|
|
10248
|
+
"text": " | (string | "
|
|
10249
|
+
},
|
|
10250
|
+
{
|
|
10251
|
+
"kind": "Reference",
|
|
10252
|
+
"text": "Namekey",
|
|
10253
|
+
"canonicalReference": "@alloy-js/core!Namekey:interface"
|
|
10254
|
+
},
|
|
10255
|
+
{
|
|
10256
|
+
"kind": "Content",
|
|
10257
|
+
"text": ")[]"
|
|
10258
|
+
},
|
|
10233
10259
|
{
|
|
10234
10260
|
"kind": "Content",
|
|
10235
10261
|
"text": ";"
|
|
@@ -10241,7 +10267,7 @@
|
|
|
10241
10267
|
"name": "name",
|
|
10242
10268
|
"propertyTypeTokenRange": {
|
|
10243
10269
|
"startIndex": 1,
|
|
10244
|
-
"endIndex":
|
|
10270
|
+
"endIndex": 6
|
|
10245
10271
|
}
|
|
10246
10272
|
},
|
|
10247
10273
|
{
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/components/namespace.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAMtD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YA2B9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Block","NamespaceContext","useSourceFileScope","createNamespaceSymbol","NamespaceScope","Namespace","props","namespaceSymbol","name","refkeys","refkey","sfScope","_$createComponent","Provider","value","symbol","children","hasBlockNamespace","_$memo"],"sources":["../../../src/components/namespace.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,KAAK,QAAyB,gBAAgB;AAEvD,SAASC,gBAAgB,QAAQ,0BAA0B;AAC3D,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,cAAc;AAQvB,OAAO,SAASC,SAASA,CAACC,KAAqB,EAAE;EAC/C,MAAMC,eAAe,GAAGJ,qBAAqB,CAACG,KAAK,CAACE,IAAI,EAAE;IACxDC,OAAO,EAAEH,KAAK,CAACI;EACjB,CAAC,CAAC;EACF,MAAMC,OAAO,GAAGT,kBAAkB,CAAC,CAAC;EAEpC,IAAI,CAACS,OAAO,EAAE;IACZ,OAAAC,iBAAA,CACGX,gBAAgB,CAACY,QAAQ;MAACC,KAAK,EAAE;QAAEC,MAAM,EAAER;MAAgB,CAAC;MAAA,IAAAS,SAAA;QAAA,OAC1DV,KAAK,CAACU,QAAQ;MAAA;IAAA;EAGrB,CAAC,MAAM;IACLL,OAAO,CAACM,iBAAiB,GAAG,IAAI;IAChC,sBAAAC,MAAA,OAEeX,eAAe,CAACC,IAAI,GAAE,GAAG,EAAAI,iBAAA,CACnCZ,KAAK;MAAA,IAAAgB,SAAA;QAAA,OAAAJ,iBAAA,CACHX,gBAAgB,CAACY,QAAQ;UAACC,KAAK,EAAE;YAAEC,MAAM,EAAER;UAAgB,CAAC;UAAA,IAAAS,SAAA;YAAA,OAAAJ,iBAAA,CAC1DR,cAAc;cAACW,MAAM,EAAER,eAAe;cAAA,IAAAS,SAAA;gBAAA,OACpCV,KAAK,CAACU,QAAQ;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAM3B;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.test.d.ts","sourceRoot":"","sources":["../../../src/components/namespace.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { TestNamespace } from "#test/utils.js";
|
|
3
|
-
import { Output } from "@alloy-js/core";
|
|
4
|
-
import { d } from "@alloy-js/core/testing";
|
|
5
|
-
import { expect, it } from "vitest";
|
|
6
|
-
import { ClassDeclaration } from "./class/declaration.js";
|
|
7
|
-
import { Namespace } from "./namespace.js";
|
|
8
|
-
import { SourceFile } from "./source-file/source-file.js";
|
|
9
|
-
it("defines multiple namespaces and source files with unique content", () => {
|
|
10
|
-
const tree = _$createComponent(Output, {
|
|
11
|
-
get children() {
|
|
12
|
-
return [_$createComponent(Namespace, {
|
|
13
|
-
name: "Namespace1",
|
|
14
|
-
get children() {
|
|
15
|
-
return [_$createComponent(SourceFile, {
|
|
16
|
-
path: "Model1.cs",
|
|
17
|
-
get children() {
|
|
18
|
-
return _$createComponent(ClassDeclaration, {
|
|
19
|
-
"public": true,
|
|
20
|
-
name: "Model1"
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}), _$createComponent(SourceFile, {
|
|
24
|
-
path: "Model2.cs",
|
|
25
|
-
get children() {
|
|
26
|
-
return _$createComponent(ClassDeclaration, {
|
|
27
|
-
"public": true,
|
|
28
|
-
name: "Model2"
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
})];
|
|
32
|
-
}
|
|
33
|
-
}), _$createComponent(Namespace, {
|
|
34
|
-
name: "Namespace2",
|
|
35
|
-
get children() {
|
|
36
|
-
return [_$createComponent(SourceFile, {
|
|
37
|
-
path: "Model3.cs",
|
|
38
|
-
get children() {
|
|
39
|
-
return _$createComponent(ClassDeclaration, {
|
|
40
|
-
"public": true,
|
|
41
|
-
name: "Model3"
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}), _$createComponent(SourceFile, {
|
|
45
|
-
path: "Model4.cs",
|
|
46
|
-
get children() {
|
|
47
|
-
return _$createComponent(ClassDeclaration, {
|
|
48
|
-
"public": true,
|
|
49
|
-
name: "Model4"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
})];
|
|
53
|
-
}
|
|
54
|
-
})];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
expect(tree).toRenderTo({
|
|
58
|
-
"Model1.cs": d`
|
|
59
|
-
namespace Namespace1;
|
|
60
|
-
|
|
61
|
-
public class Model1;
|
|
62
|
-
`,
|
|
63
|
-
"Model2.cs": d`
|
|
64
|
-
namespace Namespace1;
|
|
65
|
-
|
|
66
|
-
public class Model2;
|
|
67
|
-
`,
|
|
68
|
-
"Model3.cs": d`
|
|
69
|
-
namespace Namespace2;
|
|
70
|
-
|
|
71
|
-
public class Model3;
|
|
72
|
-
`,
|
|
73
|
-
"Model4.cs": d`
|
|
74
|
-
namespace Namespace2;
|
|
75
|
-
|
|
76
|
-
public class Model4;
|
|
77
|
-
`
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
it("uses a name policy", () => {
|
|
81
|
-
expect(_$createComponent(TestNamespace, {
|
|
82
|
-
get children() {
|
|
83
|
-
return _$createComponent(Namespace, {
|
|
84
|
-
name: "my-namespace"
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
})).toRenderTo(`
|
|
88
|
-
namespace MyNamespace {
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
`);
|
|
92
|
-
});
|
|
93
|
-
//# sourceMappingURL=namespace.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TestNamespace","Output","d","expect","it","ClassDeclaration","Namespace","SourceFile","tree","_$createComponent","children","name","path","toRenderTo"],"sources":["../../../src/components/namespace.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,aAAa;AACtB,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACnC,SAASC,gBAAgB;AACzB,SAASC,SAAS;AAClB,SAASC,UAAU;AAEnBH,EAAE,CAAC,kEAAkE,EAAE,MAAM;EAC3E,MAAMI,IAAI,GAAAC,iBAAA,CACPR,MAAM;IAAA,IAAAS,SAAA;MAAA,QAAAD,iBAAA,CACJH,SAAS;QAACK,IAAI;QAAA,IAAAD,SAAA;UAAA,QAAAD,iBAAA,CACZF,UAAU;YAACK,IAAI;YAAA,IAAAF,SAAA;cAAA,OAAAD,iBAAA,CACbJ,gBAAgB;gBAAA;gBAAQM,IAAI;cAAA;YAAA;UAAA,IAAAF,iBAAA,CAE9BF,UAAU;YAACK,IAAI;YAAA,IAAAF,SAAA;cAAA,OAAAD,iBAAA,CACbJ,gBAAgB;gBAAA;gBAAQM,IAAI;cAAA;YAAA;UAAA;QAAA;MAAA,IAAAF,iBAAA,CAGhCH,SAAS;QAACK,IAAI;QAAA,IAAAD,SAAA;UAAA,QAAAD,iBAAA,CACZF,UAAU;YAACK,IAAI;YAAA,IAAAF,SAAA;cAAA,OAAAD,iBAAA,CACbJ,gBAAgB;gBAAA;gBAAQM,IAAI;cAAA;YAAA;UAAA,IAAAF,iBAAA,CAE9BF,UAAU;YAACK,IAAI;YAAA,IAAAF,SAAA;cAAA,OAAAD,iBAAA,CACbJ,gBAAgB;gBAAA;gBAAQM,IAAI;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA,EAIpC;EAEDR,MAAM,CAACK,IAAI,CAAC,CAACK,UAAU,CAAC;IACtB,WAAW,EAAEX,CAAC;AAClB;AACA;AACA;AACA,KAAK;IACD,WAAW,EAAEA,CAAC;AAClB;AACA;AACA;AACA,KAAK;IACD,WAAW,EAAEA,CAAC;AAClB;AACA;AACA;AACA,KAAK;IACD,WAAW,EAAEA,CAAC;AAClB;AACA;AACA;AACA;EACE,CAAC,CAAC;AACJ,CAAC,CAAC;AAEFE,EAAE,CAAC,oBAAoB,EAAE,MAAM;EAC7BD,MAAM,CAAAM,iBAAA,CACHT,aAAa;IAAA,IAAAU,SAAA;MAAA,OAAAD,iBAAA,CACXH,SAAS;QAACK,IAAI;MAAA;IAAA;EAAA,EAEnB,CAAC,CAACE,UAAU,CAAC;AACf;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { TestNamespace } from "#test/utils.jsx";
|
|
2
|
-
import { Output } from "@alloy-js/core";
|
|
3
|
-
import { d } from "@alloy-js/core/testing";
|
|
4
|
-
import { expect, it } from "vitest";
|
|
5
|
-
import { ClassDeclaration } from "./class/declaration.jsx";
|
|
6
|
-
import { Namespace } from "./namespace.jsx";
|
|
7
|
-
import { SourceFile } from "./source-file/source-file.jsx";
|
|
8
|
-
|
|
9
|
-
it("defines multiple namespaces and source files with unique content", () => {
|
|
10
|
-
const tree = (
|
|
11
|
-
<Output>
|
|
12
|
-
<Namespace name="Namespace1">
|
|
13
|
-
<SourceFile path="Model1.cs">
|
|
14
|
-
<ClassDeclaration public name="Model1" />
|
|
15
|
-
</SourceFile>
|
|
16
|
-
<SourceFile path="Model2.cs">
|
|
17
|
-
<ClassDeclaration public name="Model2" />
|
|
18
|
-
</SourceFile>
|
|
19
|
-
</Namespace>
|
|
20
|
-
<Namespace name="Namespace2">
|
|
21
|
-
<SourceFile path="Model3.cs">
|
|
22
|
-
<ClassDeclaration public name="Model3" />
|
|
23
|
-
</SourceFile>
|
|
24
|
-
<SourceFile path="Model4.cs">
|
|
25
|
-
<ClassDeclaration public name="Model4" />
|
|
26
|
-
</SourceFile>
|
|
27
|
-
</Namespace>
|
|
28
|
-
</Output>
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
expect(tree).toRenderTo({
|
|
32
|
-
"Model1.cs": d`
|
|
33
|
-
namespace Namespace1;
|
|
34
|
-
|
|
35
|
-
public class Model1;
|
|
36
|
-
`,
|
|
37
|
-
"Model2.cs": d`
|
|
38
|
-
namespace Namespace1;
|
|
39
|
-
|
|
40
|
-
public class Model2;
|
|
41
|
-
`,
|
|
42
|
-
"Model3.cs": d`
|
|
43
|
-
namespace Namespace2;
|
|
44
|
-
|
|
45
|
-
public class Model3;
|
|
46
|
-
`,
|
|
47
|
-
"Model4.cs": d`
|
|
48
|
-
namespace Namespace2;
|
|
49
|
-
|
|
50
|
-
public class Model4;
|
|
51
|
-
`,
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("uses a name policy", () => {
|
|
56
|
-
expect(
|
|
57
|
-
<TestNamespace>
|
|
58
|
-
<Namespace name="my-namespace" />
|
|
59
|
-
</TestNamespace>,
|
|
60
|
-
).toRenderTo(`
|
|
61
|
-
namespace MyNamespace {
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
`);
|
|
65
|
-
});
|
|
File without changes
|