@alloy-js/csharp 0.20.0-dev.8 → 0.20.0
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/CHANGELOG.md +19 -0
- package/dist/src/components/class/declaration.test.js +5 -6
- package/dist/src/components/class/declaration.test.js.map +1 -1
- 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 -1
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/namespace.ref.test.js +1 -1
- package/dist/src/components/namespace.test.js +1 -1
- package/dist/src/components/{SourceFile.d.ts → source-file/source-file.d.ts} +3 -2
- package/dist/src/components/source-file/source-file.d.ts.map +1 -0
- package/dist/src/components/{SourceFile.js → source-file/source-file.js} +18 -13
- package/dist/src/components/source-file/source-file.js.map +1 -0
- package/dist/src/components/source-file/source-file.test.d.ts +2 -0
- package/dist/src/components/source-file/source-file.test.d.ts.map +1 -0
- package/dist/src/components/source-file/source-file.test.js +136 -0
- package/dist/src/components/source-file/source-file.test.js.map +1 -0
- package/dist/src/contexts/format-options.d.ts +5 -0
- package/dist/src/contexts/format-options.d.ts.map +1 -0
- package/dist/src/contexts/format-options.js +9 -0
- package/dist/src/contexts/format-options.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/test/project-directory.test.js +6 -2
- package/dist/test/project-directory.test.js.map +1 -1
- package/dist/test/using.test.js +3 -4
- package/dist/test/using.test.js.map +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +3 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/components/class/declaration.test.tsx +4 -7
- package/src/components/enum/declaration.ref.test.tsx +1 -1
- package/src/components/index.ts +1 -1
- package/src/components/namespace.ref.test.tsx +1 -1
- package/src/components/namespace.test.tsx +1 -1
- package/src/components/source-file/source-file.test.tsx +96 -0
- package/src/components/{SourceFile.tsx → source-file/source-file.tsx} +20 -10
- package/src/contexts/format-options.ts +14 -0
- package/src/index.ts +1 -0
- package/temp/api.json +155 -4
- package/test/project-directory.test.tsx +2 -0
- package/test/using.test.tsx +3 -5
- package/test/utils.tsx +1 -0
- package/dist/src/components/SourceFile.d.ts.map +0 -1
- package/dist/src/components/SourceFile.js.map +0 -1
- package/dist/test/sourcefile.test.d.ts +0 -2
- package/dist/test/sourcefile.test.d.ts.map +0 -1
- package/dist/test/sourcefile.test.js +0 -47
- package/dist/test/sourcefile.test.js.map +0 -1
- package/test/sourcefile.test.tsx +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alloy-js/csharp",
|
|
3
|
-
"version": "0.20.0
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Alloy components for CSharp language.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"author": "jhendrix@microsoft.com",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@alloy-js/core": "~0.19.0 || >= 0.20.0-dev.7",
|
|
24
23
|
"change-case": "^5.4.4",
|
|
25
24
|
"marked": "^16.1.1",
|
|
26
|
-
"pathe": "^2.0.3"
|
|
25
|
+
"pathe": "^2.0.3",
|
|
26
|
+
"@alloy-js/core": "~0.20.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@alloy-js/cli": "~0.19.0 || >= 0.20.0-dev.1",
|
|
30
|
-
"@alloy-js/rollup-plugin": "~0.1.0 || >= 0.1.1-dev.0",
|
|
31
29
|
"@microsoft/api-extractor": "~7.52.8",
|
|
32
30
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
33
31
|
"concurrently": "^9.2.0",
|
|
34
32
|
"typescript": "^5.8.3",
|
|
35
|
-
"vitest": "^3.2.4"
|
|
33
|
+
"vitest": "^3.2.4",
|
|
34
|
+
"@alloy-js/cli": "~0.20.0",
|
|
35
|
+
"@alloy-js/rollup-plugin": "~0.1.0"
|
|
36
36
|
},
|
|
37
37
|
"type": "module",
|
|
38
38
|
"scripts": {
|
|
@@ -9,17 +9,16 @@ import {
|
|
|
9
9
|
NamePolicyContext,
|
|
10
10
|
Output,
|
|
11
11
|
refkey,
|
|
12
|
-
render,
|
|
13
12
|
} from "@alloy-js/core";
|
|
14
13
|
import * as coretest from "@alloy-js/core/testing";
|
|
15
14
|
import { describe, expect, it } from "vitest";
|
|
16
|
-
import {
|
|
15
|
+
import { TestNamespace, toSourceText } from "../../../test/utils.jsx";
|
|
17
16
|
import { createCSharpNamePolicy } from "../../name-policy.js";
|
|
18
17
|
import { Attribute } from "../attributes/attributes.jsx";
|
|
19
18
|
import { Field } from "../field/field.jsx";
|
|
20
19
|
import { Method } from "../method/method.jsx";
|
|
21
20
|
import { Property } from "../property/property.jsx";
|
|
22
|
-
import { SourceFile } from "../
|
|
21
|
+
import { SourceFile } from "../source-file/source-file.jsx";
|
|
23
22
|
import { TypeParameterProps } from "../type-parameters/type-parameter.jsx";
|
|
24
23
|
import { ClassDeclaration } from "./declaration.jsx";
|
|
25
24
|
|
|
@@ -181,7 +180,7 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
181
180
|
},
|
|
182
181
|
];
|
|
183
182
|
|
|
184
|
-
|
|
183
|
+
expect(
|
|
185
184
|
<Output namePolicy={createCSharpNamePolicy()}>
|
|
186
185
|
<SourceFile path="Test.cs">
|
|
187
186
|
<EnumDeclaration public name="TestEnum" refkey={enumTypeRefkey}>
|
|
@@ -213,9 +212,7 @@ it("uses refkeys for members, params, and return type", () => {
|
|
|
213
212
|
</ClassDeclaration>
|
|
214
213
|
</SourceFile>
|
|
215
214
|
</Output>,
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
expect(findFile(res, "Test.cs").contents).toBe(coretest.d`
|
|
215
|
+
).toRenderTo(`
|
|
219
216
|
public enum TestEnum
|
|
220
217
|
{
|
|
221
218
|
One,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Namespace } from "#components/namespace.jsx";
|
|
2
|
-
import { SourceFile } from "#components/
|
|
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";
|
|
5
5
|
import { expect, it } from "vitest";
|
package/src/components/index.ts
CHANGED
|
@@ -21,7 +21,7 @@ export * from "./ProjectDirectory.js";
|
|
|
21
21
|
export * from "./property/property.jsx";
|
|
22
22
|
export * from "./record/declaration.js";
|
|
23
23
|
export * from "./Reference.js";
|
|
24
|
-
export * from "./
|
|
24
|
+
export * from "./source-file/source-file.jsx";
|
|
25
25
|
export * from "./struct/declaration.jsx";
|
|
26
26
|
export type { TypeParameterProps } from "./type-parameters/type-parameter.jsx";
|
|
27
27
|
export * from "./UsingDirective.js";
|
|
@@ -3,7 +3,7 @@ import { d } from "@alloy-js/core/testing";
|
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import { ClassDeclaration } from "./class/declaration.jsx";
|
|
5
5
|
import { Namespace } from "./namespace.jsx";
|
|
6
|
-
import { SourceFile } from "./
|
|
6
|
+
import { SourceFile } from "./source-file/source-file.jsx";
|
|
7
7
|
|
|
8
8
|
it("references types in the same namespace", () => {
|
|
9
9
|
const classRef = refkey();
|
|
@@ -3,7 +3,7 @@ import { d } from "@alloy-js/core/testing";
|
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import { ClassDeclaration } from "./class/declaration.jsx";
|
|
5
5
|
import { Namespace } from "./namespace.jsx";
|
|
6
|
-
import { SourceFile } from "./
|
|
6
|
+
import { SourceFile } from "./source-file/source-file.jsx";
|
|
7
7
|
|
|
8
8
|
it("defines multiple namespaces and source files with unique content", () => {
|
|
9
9
|
const tree = (
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ClassDeclaration } from "#components/class/declaration.jsx";
|
|
2
|
+
import { Namespace } from "#components/namespace.jsx";
|
|
3
|
+
import { Children, FormatOptions, Indent, Output, Prose } from "@alloy-js/core";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { CSharpFormatOptions } from "../../contexts/format-options.js";
|
|
6
|
+
import { SourceFile } from "./source-file.jsx";
|
|
7
|
+
|
|
8
|
+
it("defines multiple source files with unique content", () => {
|
|
9
|
+
expect(
|
|
10
|
+
<Output>
|
|
11
|
+
<Namespace name="TestCode">
|
|
12
|
+
<SourceFile path="Test1.cs">
|
|
13
|
+
<ClassDeclaration public name="TestClass1" />
|
|
14
|
+
</SourceFile>
|
|
15
|
+
<SourceFile path="Test2.cs">
|
|
16
|
+
<ClassDeclaration public name="TestClass2" />
|
|
17
|
+
</SourceFile>
|
|
18
|
+
</Namespace>
|
|
19
|
+
</Output>,
|
|
20
|
+
).toRenderTo({
|
|
21
|
+
"Test1.cs": `
|
|
22
|
+
namespace TestCode;
|
|
23
|
+
|
|
24
|
+
public class TestClass1;
|
|
25
|
+
`,
|
|
26
|
+
"Test2.cs": `
|
|
27
|
+
namespace TestCode;
|
|
28
|
+
|
|
29
|
+
public class TestClass2;
|
|
30
|
+
`,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe("format options", () => {
|
|
35
|
+
function FileWithFormatOptions(props: {
|
|
36
|
+
options: CSharpFormatOptions;
|
|
37
|
+
children: Children;
|
|
38
|
+
}) {
|
|
39
|
+
return (
|
|
40
|
+
<CSharpFormatOptions value={props.options}>
|
|
41
|
+
<SourceFile path="hi.cs">{props.children}</SourceFile>
|
|
42
|
+
</CSharpFormatOptions>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
it("respect tabWidth", () => {
|
|
47
|
+
expect(
|
|
48
|
+
<FileWithFormatOptions options={{ tabWidth: 5 }}>
|
|
49
|
+
hello
|
|
50
|
+
<Indent>indented 5 spaces</Indent>
|
|
51
|
+
</FileWithFormatOptions>,
|
|
52
|
+
).toRenderTo(`
|
|
53
|
+
hello
|
|
54
|
+
indented 5 spaces
|
|
55
|
+
`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("respect useTabs", () => {
|
|
59
|
+
expect(
|
|
60
|
+
<FileWithFormatOptions options={{ useTabs: true }}>
|
|
61
|
+
hello
|
|
62
|
+
<Indent>indented with tabs</Indent>
|
|
63
|
+
</FileWithFormatOptions>,
|
|
64
|
+
).toRenderTo(`
|
|
65
|
+
hello
|
|
66
|
+
\tindented with tabs
|
|
67
|
+
`);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("respect printWidth", () => {
|
|
71
|
+
expect(
|
|
72
|
+
<FileWithFormatOptions options={{ printWidth: 10 }}>
|
|
73
|
+
<Prose>this is too long</Prose>
|
|
74
|
+
</FileWithFormatOptions>,
|
|
75
|
+
).toRenderTo(`
|
|
76
|
+
this is
|
|
77
|
+
too long
|
|
78
|
+
`);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("CSharpFormatOptions takes precedence over FormatOptions", () => {
|
|
82
|
+
expect(
|
|
83
|
+
<FormatOptions value={{ tabWidth: 5 }}>
|
|
84
|
+
<CSharpFormatOptions value={{ tabWidth: 3 }}>
|
|
85
|
+
<SourceFile path="hi.cs">
|
|
86
|
+
hello
|
|
87
|
+
<Indent>indented 3 spaces</Indent>
|
|
88
|
+
</SourceFile>
|
|
89
|
+
</CSharpFormatOptions>
|
|
90
|
+
</FormatOptions>,
|
|
91
|
+
).toRenderTo(`
|
|
92
|
+
hello
|
|
93
|
+
indented 3 spaces
|
|
94
|
+
`);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { NamespaceScopes } from "#components/namespace-scopes.jsx";
|
|
2
|
+
import { Reference } from "#components/Reference.jsx";
|
|
3
|
+
import { UsingDirective } from "#components/UsingDirective.jsx";
|
|
1
4
|
import {
|
|
2
5
|
Block,
|
|
3
6
|
Children,
|
|
@@ -6,18 +9,19 @@ import {
|
|
|
6
9
|
Scope,
|
|
7
10
|
useBinder,
|
|
8
11
|
} from "@alloy-js/core";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
CSharpFormatOptions,
|
|
14
|
+
useCsharpFormatOptions,
|
|
15
|
+
} from "../../contexts/format-options.js";
|
|
16
|
+
import { getGlobalNamespace } from "../../contexts/global-namespace.js";
|
|
17
|
+
import { useNamespaceContext } from "../../contexts/namespace.js";
|
|
18
|
+
import { CSharpSourceFileScope } from "../../scopes/source-file.js";
|
|
19
|
+
import { NamespaceSymbol } from "../../symbols/namespace.js";
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* Props for {@link SourceFile} component
|
|
19
23
|
*/
|
|
20
|
-
export interface SourceFileProps {
|
|
24
|
+
export interface SourceFileProps extends CSharpFormatOptions {
|
|
21
25
|
/** Path of the source file */
|
|
22
26
|
path: string;
|
|
23
27
|
|
|
@@ -48,13 +52,19 @@ export function SourceFile(props: SourceFileProps) {
|
|
|
48
52
|
const content = computed(() => (
|
|
49
53
|
<NamespaceScopes symbol={nsSymbol}>{props.children}</NamespaceScopes>
|
|
50
54
|
));
|
|
55
|
+
|
|
56
|
+
const opts = useCsharpFormatOptions({
|
|
57
|
+
printWidth: props.printWidth,
|
|
58
|
+
tabWidth: props.tabWidth,
|
|
59
|
+
useTabs: props.useTabs,
|
|
60
|
+
});
|
|
61
|
+
|
|
51
62
|
return (
|
|
52
63
|
<CoreSourceFile
|
|
53
64
|
path={props.path}
|
|
54
65
|
filetype="cs"
|
|
55
66
|
reference={Reference}
|
|
56
|
-
|
|
57
|
-
printWidth={120}
|
|
67
|
+
{...opts}
|
|
58
68
|
>
|
|
59
69
|
<Scope value={sourceFileScope}>
|
|
60
70
|
{(sourceFileScope.usings.size > 0 ||
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CommonFormatOptions,
|
|
3
|
+
createFormatOptionsContextFor,
|
|
4
|
+
} from "@alloy-js/core";
|
|
5
|
+
|
|
6
|
+
export interface CSharpFormatOptions extends CommonFormatOptions {}
|
|
7
|
+
|
|
8
|
+
export const {
|
|
9
|
+
Provider: CSharpFormatOptions,
|
|
10
|
+
useFormatOptions: useCsharpFormatOptions,
|
|
11
|
+
} = createFormatOptionsContextFor<CSharpFormatOptions>("csharp", {
|
|
12
|
+
tabWidth: 4,
|
|
13
|
+
printWidth: 120,
|
|
14
|
+
});
|
package/src/index.ts
CHANGED
package/temp/api.json
CHANGED
|
@@ -2525,6 +2525,87 @@
|
|
|
2525
2525
|
"endIndex": 2
|
|
2526
2526
|
}
|
|
2527
2527
|
},
|
|
2528
|
+
{
|
|
2529
|
+
"kind": "Interface",
|
|
2530
|
+
"canonicalReference": "@alloy-js/csharp!CSharpFormatOptions:interface",
|
|
2531
|
+
"docComment": "",
|
|
2532
|
+
"excerptTokens": [
|
|
2533
|
+
{
|
|
2534
|
+
"kind": "Content",
|
|
2535
|
+
"text": "export interface CSharpFormatOptions extends "
|
|
2536
|
+
},
|
|
2537
|
+
{
|
|
2538
|
+
"kind": "Reference",
|
|
2539
|
+
"text": "CommonFormatOptions",
|
|
2540
|
+
"canonicalReference": "@alloy-js/core!CommonFormatOptions:interface"
|
|
2541
|
+
},
|
|
2542
|
+
{
|
|
2543
|
+
"kind": "Content",
|
|
2544
|
+
"text": " "
|
|
2545
|
+
}
|
|
2546
|
+
],
|
|
2547
|
+
"fileUrlPath": "src/contexts/format-options.ts",
|
|
2548
|
+
"releaseTag": "Public",
|
|
2549
|
+
"name": "CSharpFormatOptions",
|
|
2550
|
+
"preserveMemberOrder": false,
|
|
2551
|
+
"members": [],
|
|
2552
|
+
"extendsTokenRanges": [
|
|
2553
|
+
{
|
|
2554
|
+
"startIndex": 1,
|
|
2555
|
+
"endIndex": 2
|
|
2556
|
+
}
|
|
2557
|
+
]
|
|
2558
|
+
},
|
|
2559
|
+
{
|
|
2560
|
+
"kind": "Variable",
|
|
2561
|
+
"canonicalReference": "@alloy-js/csharp!CSharpFormatOptions:var",
|
|
2562
|
+
"docComment": "",
|
|
2563
|
+
"excerptTokens": [
|
|
2564
|
+
{
|
|
2565
|
+
"kind": "Content",
|
|
2566
|
+
"text": "CSharpFormatOptions: "
|
|
2567
|
+
},
|
|
2568
|
+
{
|
|
2569
|
+
"kind": "Content",
|
|
2570
|
+
"text": "import(\"@alloy-js/core\")."
|
|
2571
|
+
},
|
|
2572
|
+
{
|
|
2573
|
+
"kind": "Reference",
|
|
2574
|
+
"text": "ComponentDefinition",
|
|
2575
|
+
"canonicalReference": "@alloy-js/core!ComponentDefinition:interface"
|
|
2576
|
+
},
|
|
2577
|
+
{
|
|
2578
|
+
"kind": "Content",
|
|
2579
|
+
"text": "<import(\"@alloy-js/core\")."
|
|
2580
|
+
},
|
|
2581
|
+
{
|
|
2582
|
+
"kind": "Reference",
|
|
2583
|
+
"text": "ContextProviderProps",
|
|
2584
|
+
"canonicalReference": "@alloy-js/core!ContextProviderProps:interface"
|
|
2585
|
+
},
|
|
2586
|
+
{
|
|
2587
|
+
"kind": "Content",
|
|
2588
|
+
"text": "<"
|
|
2589
|
+
},
|
|
2590
|
+
{
|
|
2591
|
+
"kind": "Reference",
|
|
2592
|
+
"text": "CSharpFormatOptions",
|
|
2593
|
+
"canonicalReference": "@alloy-js/csharp!CSharpFormatOptions:interface"
|
|
2594
|
+
},
|
|
2595
|
+
{
|
|
2596
|
+
"kind": "Content",
|
|
2597
|
+
"text": ">>"
|
|
2598
|
+
}
|
|
2599
|
+
],
|
|
2600
|
+
"fileUrlPath": "src/contexts/format-options.ts",
|
|
2601
|
+
"isReadonly": true,
|
|
2602
|
+
"releaseTag": "Public",
|
|
2603
|
+
"name": "CSharpFormatOptions",
|
|
2604
|
+
"variableTypeTokenRange": {
|
|
2605
|
+
"startIndex": 1,
|
|
2606
|
+
"endIndex": 8
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2528
2609
|
{
|
|
2529
2610
|
"kind": "Class",
|
|
2530
2611
|
"canonicalReference": "@alloy-js/csharp!CSharpLexicalScope:class",
|
|
@@ -12361,7 +12442,7 @@
|
|
|
12361
12442
|
"text": ";"
|
|
12362
12443
|
}
|
|
12363
12444
|
],
|
|
12364
|
-
"fileUrlPath": "src/components/
|
|
12445
|
+
"fileUrlPath": "src/components/source-file/source-file.tsx",
|
|
12365
12446
|
"returnTypeTokenRange": {
|
|
12366
12447
|
"startIndex": 3,
|
|
12367
12448
|
"endIndex": 4
|
|
@@ -12387,10 +12468,19 @@
|
|
|
12387
12468
|
"excerptTokens": [
|
|
12388
12469
|
{
|
|
12389
12470
|
"kind": "Content",
|
|
12390
|
-
"text": "export interface SourceFileProps "
|
|
12471
|
+
"text": "export interface SourceFileProps extends "
|
|
12472
|
+
},
|
|
12473
|
+
{
|
|
12474
|
+
"kind": "Reference",
|
|
12475
|
+
"text": "CSharpFormatOptions",
|
|
12476
|
+
"canonicalReference": "@alloy-js/csharp!CSharpFormatOptions:interface"
|
|
12477
|
+
},
|
|
12478
|
+
{
|
|
12479
|
+
"kind": "Content",
|
|
12480
|
+
"text": " "
|
|
12391
12481
|
}
|
|
12392
12482
|
],
|
|
12393
|
-
"fileUrlPath": "src/components/
|
|
12483
|
+
"fileUrlPath": "src/components/source-file/source-file.tsx",
|
|
12394
12484
|
"releaseTag": "Public",
|
|
12395
12485
|
"name": "SourceFileProps",
|
|
12396
12486
|
"preserveMemberOrder": false,
|
|
@@ -12478,7 +12568,12 @@
|
|
|
12478
12568
|
}
|
|
12479
12569
|
}
|
|
12480
12570
|
],
|
|
12481
|
-
"extendsTokenRanges": [
|
|
12571
|
+
"extendsTokenRanges": [
|
|
12572
|
+
{
|
|
12573
|
+
"startIndex": 1,
|
|
12574
|
+
"endIndex": 2
|
|
12575
|
+
}
|
|
12576
|
+
]
|
|
12482
12577
|
},
|
|
12483
12578
|
{
|
|
12484
12579
|
"kind": "Function",
|
|
@@ -13030,6 +13125,62 @@
|
|
|
13030
13125
|
],
|
|
13031
13126
|
"extendsTokenRanges": []
|
|
13032
13127
|
},
|
|
13128
|
+
{
|
|
13129
|
+
"kind": "Function",
|
|
13130
|
+
"canonicalReference": "@alloy-js/csharp!useCsharpFormatOptions:function(1)",
|
|
13131
|
+
"docComment": "",
|
|
13132
|
+
"excerptTokens": [
|
|
13133
|
+
{
|
|
13134
|
+
"kind": "Content",
|
|
13135
|
+
"text": "useCsharpFormatOptions: (overrides?: "
|
|
13136
|
+
},
|
|
13137
|
+
{
|
|
13138
|
+
"kind": "Reference",
|
|
13139
|
+
"text": "Partial",
|
|
13140
|
+
"canonicalReference": "!Partial:type"
|
|
13141
|
+
},
|
|
13142
|
+
{
|
|
13143
|
+
"kind": "Content",
|
|
13144
|
+
"text": "<"
|
|
13145
|
+
},
|
|
13146
|
+
{
|
|
13147
|
+
"kind": "Reference",
|
|
13148
|
+
"text": "CSharpFormatOptions",
|
|
13149
|
+
"canonicalReference": "@alloy-js/csharp!CSharpFormatOptions:interface"
|
|
13150
|
+
},
|
|
13151
|
+
{
|
|
13152
|
+
"kind": "Content",
|
|
13153
|
+
"text": "> | undefined"
|
|
13154
|
+
},
|
|
13155
|
+
{
|
|
13156
|
+
"kind": "Content",
|
|
13157
|
+
"text": ") => "
|
|
13158
|
+
},
|
|
13159
|
+
{
|
|
13160
|
+
"kind": "Reference",
|
|
13161
|
+
"text": "CSharpFormatOptions",
|
|
13162
|
+
"canonicalReference": "@alloy-js/csharp!CSharpFormatOptions:interface"
|
|
13163
|
+
}
|
|
13164
|
+
],
|
|
13165
|
+
"fileUrlPath": "src/contexts/format-options.ts",
|
|
13166
|
+
"returnTypeTokenRange": {
|
|
13167
|
+
"startIndex": 6,
|
|
13168
|
+
"endIndex": 7
|
|
13169
|
+
},
|
|
13170
|
+
"releaseTag": "Public",
|
|
13171
|
+
"overloadIndex": 1,
|
|
13172
|
+
"parameters": [
|
|
13173
|
+
{
|
|
13174
|
+
"parameterName": "overrides",
|
|
13175
|
+
"parameterTypeTokenRange": {
|
|
13176
|
+
"startIndex": 1,
|
|
13177
|
+
"endIndex": 5
|
|
13178
|
+
},
|
|
13179
|
+
"isOptional": true
|
|
13180
|
+
}
|
|
13181
|
+
],
|
|
13182
|
+
"name": "useCsharpFormatOptions"
|
|
13183
|
+
},
|
|
13033
13184
|
{
|
|
13034
13185
|
"kind": "Function",
|
|
13035
13186
|
"canonicalReference": "@alloy-js/csharp!useCSharpNamePolicy:function(1)",
|
|
@@ -22,6 +22,7 @@ it("defines a project directory file with multiple source files", () => {
|
|
|
22
22
|
</csharp.Namespace>
|
|
23
23
|
</csharp.ProjectDirectory>
|
|
24
24
|
</core.Output>,
|
|
25
|
+
{ insertFinalNewLine: false },
|
|
25
26
|
);
|
|
26
27
|
|
|
27
28
|
const projDir = res.contents[0] as core.OutputDirectory;
|
|
@@ -80,6 +81,7 @@ it("defines a project directory file with multiple source files and a custom TFM
|
|
|
80
81
|
</csharp.Namespace>
|
|
81
82
|
</csharp.ProjectDirectory>
|
|
82
83
|
</core.Output>,
|
|
84
|
+
{ insertFinalNewLine: false },
|
|
83
85
|
);
|
|
84
86
|
|
|
85
87
|
const projDir = res.contents[0] as core.OutputDirectory;
|
package/test/using.test.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import * as core from "@alloy-js/core";
|
|
|
2
2
|
import * as coretest from "@alloy-js/core/testing";
|
|
3
3
|
import { expect, it } from "vitest";
|
|
4
4
|
import * as csharp from "../src/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { findFile } from "./utils.jsx";
|
|
6
6
|
|
|
7
7
|
it("uses a single namespace", () => {
|
|
8
8
|
const res = core.render(
|
|
@@ -53,7 +53,7 @@ it("adds using statement across namespaces", () => {
|
|
|
53
53
|
},
|
|
54
54
|
];
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
expect(
|
|
57
57
|
<core.Output namePolicy={csharp.createCSharpNamePolicy()}>
|
|
58
58
|
<csharp.Namespace name="Models">
|
|
59
59
|
<csharp.SourceFile path="Models.cs">
|
|
@@ -90,9 +90,7 @@ it("adds using statement across namespaces", () => {
|
|
|
90
90
|
</csharp.SourceFile>
|
|
91
91
|
</csharp.Namespace>
|
|
92
92
|
</core.Output>,
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
assertFileContents(res, {
|
|
93
|
+
).toRenderTo({
|
|
96
94
|
"Models.cs": coretest.d`
|
|
97
95
|
namespace Models;
|
|
98
96
|
|
package/test/utils.tsx
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAKT,MAAM,gBAAgB,CAAC;AASxB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IAEb,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,2GAA2G;AAC3G,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAqDhD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Block","computed","SourceFile","CoreSourceFile","Scope","useBinder","getGlobalNamespace","useNamespaceContext","CSharpSourceFileScope","NamespaceScopes","Reference","UsingDirective","props","sourceFileScope","path","nsContext","globalNs","nsSymbol","symbol","nsRef","name","undefined","usings","Array","from","concat","using","content","_$createComponent","children","filetype","reference","tabWidth","printWidth","value","_$memo","size","length","namespaces","_$createIntrinsic","hasBlockNamespace"],"sources":["../../../src/components/SourceFile.tsx"],"sourcesContent":[null],"mappings":";AAAA,SACEA,KAAK,EAELC,QAAQ,EACRC,UAAU,IAAIC,cAAc,EAC5BC,KAAK,EACLC,SAAS,QACJ,gBAAgB;AACvB,SAASC,kBAAkB,QAAQ,iCAAiC;AACpE,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,0BAA0B;AAEhE,SAASC,eAAe;AACxB,SAASC,SAAS;AAClB,SAASC,cAAc;;AAEvB;AACA;AACA;;AAeA;AACA,OAAO,SAAST,UAAUA,CAACU,KAAsB,EAAE;EACjD,MAAMC,eAAe,GAAG,IAAIL,qBAAqB,CAACI,KAAK,CAACE,IAAI,CAAC;EAE7D,MAAMC,SAAS,GAAGR,mBAAmB,CAAC,CAAC;EACvC,MAAMS,QAAQ,GAAGV,kBAAkB,CAACD,SAAS,CAAC,CAAC,CAAC;EAChD,MAAMY,QAAQ,GAAGF,SAAS,GAAGA,SAAS,CAACG,MAAM,GAAGF,QAAQ;EACxD,MAAMG,KAAK,GAAGJ,SAAS,GAAGA,SAAS,CAACG,MAAM,CAACE,IAAI,GAAGC,SAAS;EAC3D,MAAMC,MAAM,GAAGrB,QAAQ,CAAC,MAAM;IAC5B,OACEsB,KAAK,CAACC,IAAI,CAACX,eAAe,CAACS,MAAM,CAAC,CAClCG,MAAM,CAACb,KAAK,CAACc,KAAK,IAAI,EAAE,CAAC;EAC7B,CAAC,CAAC;EAEF,MAAMC,OAAO,GAAG1B,QAAQ,CAAC,MAAA2B,iBAAA,CACtBnB,eAAe;IAACS,MAAM,EAAED,QAAQ;IAAA,IAAAY,SAAA;MAAA,OAAGjB,KAAK,CAACiB,QAAQ;IAAA;EAAA,EACnD,CAAC;EACF,OAAAD,iBAAA,CACGzB,cAAc;IAAA,IACbW,IAAIA,CAAA;MAAA,OAAEF,KAAK,CAACE,IAAI;IAAA;IAChBgB,QAAQ;IACRC,SAAS,EAAErB,SAAS;IACpBsB,QAAQ,EAAE,CAAC;IACXC,UAAU,EAAE,GAAG;IAAA,IAAAJ,SAAA;MAAA,OAAAD,iBAAA,CAEdxB,KAAK;QAAC8B,KAAK,EAAErB,eAAe;QAAA,IAAAgB,SAAA;UAAA,QAAAM,MAAA,OAC1BA,MAAA,UAACtB,eAAe,CAACS,MAAM,CAACc,IAAI,GAAG,CAAC,IAC9BxB,KAAK,CAACc,KAAK,IAAId,KAAK,CAACc,KAAK,CAACW,MAAM,GAAG,CAAE,SAAAT,iBAAA,CAEpCjB,cAAc;YAAA,IAAC2B,UAAUA,CAAA;cAAA,OAAEhB,MAAM,CAACY,KAAK;YAAA;UAAA,IAAAK,iBAAA,aAAAA,iBAAA,YAI3C,GAAAJ,MAAA,OACAlB,QAAQ,KAAKD,QAAQ,GACpBW,OAAO,kBAEMR,KAAK,EAAAgB,MAAA,OACfA,MAAA,SAAAtB,eAAe,CAAC2B,iBAAiB,OAE7B,GAAG,EAAAZ,iBAAA,CACH5B,KAAK;YAAA6B,QAAA,EAAEF;UAAO,YAAAY,iBAAA,aAAAA,iBAAA,aAKdZ,OAAO,CACP,EAEJ;QAAA;MAAA;IAAA;EAAA;AAKb","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sourcefile.test.d.ts","sourceRoot":"","sources":["../../test/sourcefile.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import * as core from "@alloy-js/core";
|
|
3
|
-
import * as coretest from "@alloy-js/core/testing";
|
|
4
|
-
import { it } from "vitest";
|
|
5
|
-
import * as csharp from "../src/index.js";
|
|
6
|
-
import { assertFileContents } from "./utils.js";
|
|
7
|
-
it("defines multiple source files with unique content", () => {
|
|
8
|
-
const res = core.render(_$createComponent(core.Output, {
|
|
9
|
-
get children() {
|
|
10
|
-
return _$createComponent(csharp.Namespace, {
|
|
11
|
-
name: "TestCode",
|
|
12
|
-
get children() {
|
|
13
|
-
return [_$createComponent(csharp.SourceFile, {
|
|
14
|
-
path: "Test1.cs",
|
|
15
|
-
get children() {
|
|
16
|
-
return _$createComponent(csharp.ClassDeclaration, {
|
|
17
|
-
"public": true,
|
|
18
|
-
name: "TestClass1"
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}), _$createComponent(csharp.SourceFile, {
|
|
22
|
-
path: "Test2.cs",
|
|
23
|
-
get children() {
|
|
24
|
-
return _$createComponent(csharp.ClassDeclaration, {
|
|
25
|
-
"public": true,
|
|
26
|
-
name: "TestClass2"
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
})];
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
34
|
-
assertFileContents(res, {
|
|
35
|
-
"Test1.cs": coretest.d`
|
|
36
|
-
namespace TestCode;
|
|
37
|
-
|
|
38
|
-
public class TestClass1;
|
|
39
|
-
`,
|
|
40
|
-
"Test2.cs": coretest.d`
|
|
41
|
-
namespace TestCode;
|
|
42
|
-
|
|
43
|
-
public class TestClass2;
|
|
44
|
-
`
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=sourcefile.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["core","coretest","it","csharp","assertFileContents","res","render","_$createComponent","Output","children","Namespace","name","SourceFile","path","ClassDeclaration","d"],"sources":["../../test/sourcefile.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,IAAI,MAAM,gBAAgB;AACtC,OAAO,KAAKC,QAAQ,MAAM,wBAAwB;AAClD,SAASC,EAAE,QAAQ,QAAQ;AAC3B,OAAO,KAAKC,MAAM,MAAM,iBAAiB;AACzC,SAASC,kBAAkB;AAE3BF,EAAE,CAAC,mDAAmD,EAAE,MAAM;EAC5D,MAAMG,GAAG,GAAGL,IAAI,CAACM,MAAM,CAAAC,iBAAA,CACpBP,IAAI,CAACQ,MAAM;IAAA,IAAAC,SAAA;MAAA,OAAAF,iBAAA,CACTJ,MAAM,CAACO,SAAS;QAACC,IAAI;QAAA,IAAAF,SAAA;UAAA,QAAAF,iBAAA,CACnBJ,MAAM,CAACS,UAAU;YAACC,IAAI;YAAA,IAAAJ,SAAA;cAAA,OAAAF,iBAAA,CACpBJ,MAAM,CAACW,gBAAgB;gBAAA;gBAAQH,IAAI;cAAA;YAAA;UAAA,IAAAJ,iBAAA,CAErCJ,MAAM,CAACS,UAAU;YAACC,IAAI;YAAA,IAAAJ,SAAA;cAAA,OAAAF,iBAAA,CACpBJ,MAAM,CAACW,gBAAgB;gBAAA;gBAAQH,IAAI;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA,EAI5C,CAAC;EAEDP,kBAAkB,CAACC,GAAG,EAAE;IACtB,UAAU,EAAEJ,QAAQ,CAACc,CAAC;AAC1B;AACA;AACA;AACA,KAAK;IACD,UAAU,EAAEd,QAAQ,CAACc,CAAC;AAC1B;AACA;AACA;AACA;EACE,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/test/sourcefile.test.tsx
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as core from "@alloy-js/core";
|
|
2
|
-
import * as coretest from "@alloy-js/core/testing";
|
|
3
|
-
import { it } from "vitest";
|
|
4
|
-
import * as csharp from "../src/index.js";
|
|
5
|
-
import { assertFileContents } from "./utils.jsx";
|
|
6
|
-
|
|
7
|
-
it("defines multiple source files with unique content", () => {
|
|
8
|
-
const res = core.render(
|
|
9
|
-
<core.Output>
|
|
10
|
-
<csharp.Namespace name="TestCode">
|
|
11
|
-
<csharp.SourceFile path="Test1.cs">
|
|
12
|
-
<csharp.ClassDeclaration public name="TestClass1" />
|
|
13
|
-
</csharp.SourceFile>
|
|
14
|
-
<csharp.SourceFile path="Test2.cs">
|
|
15
|
-
<csharp.ClassDeclaration public name="TestClass2" />
|
|
16
|
-
</csharp.SourceFile>
|
|
17
|
-
</csharp.Namespace>
|
|
18
|
-
</core.Output>,
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
assertFileContents(res, {
|
|
22
|
-
"Test1.cs": coretest.d`
|
|
23
|
-
namespace TestCode;
|
|
24
|
-
|
|
25
|
-
public class TestClass1;
|
|
26
|
-
`,
|
|
27
|
-
"Test2.cs": coretest.d`
|
|
28
|
-
namespace TestCode;
|
|
29
|
-
|
|
30
|
-
public class TestClass2;
|
|
31
|
-
`,
|
|
32
|
-
});
|
|
33
|
-
});
|