@alloy-js/csharp 0.1.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/LICENSE.txt +7 -0
- package/api-extractor.json +4 -0
- package/babel.config.cjs +4 -0
- package/dist/src/components/Class.d.ts +33 -0
- package/dist/src/components/Class.d.ts.map +1 -0
- package/dist/src/components/Class.js +170 -0
- package/dist/src/components/Class.js.map +1 -0
- package/dist/src/components/Declaration.d.ts +8 -0
- package/dist/src/components/Declaration.d.ts.map +1 -0
- package/dist/src/components/Declaration.js +18 -0
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/Enum.d.ts +13 -0
- package/dist/src/components/Enum.d.ts.map +1 -0
- package/dist/src/components/Enum.js +65 -0
- package/dist/src/components/Enum.js.map +1 -0
- package/dist/src/components/Name.d.ts +2 -0
- package/dist/src/components/Name.d.ts.map +1 -0
- package/dist/src/components/Name.js +12 -0
- package/dist/src/components/Name.js.map +1 -0
- package/dist/src/components/Namespace.d.ts +11 -0
- package/dist/src/components/Namespace.d.ts.map +1 -0
- package/dist/src/components/Namespace.js +35 -0
- package/dist/src/components/Namespace.js.map +1 -0
- package/dist/src/components/Parameters.d.ts +13 -0
- package/dist/src/components/Parameters.d.ts.map +1 -0
- package/dist/src/components/Parameters.js +34 -0
- package/dist/src/components/Parameters.js.map +1 -0
- package/dist/src/components/ProjectDirectory.d.ts +12 -0
- package/dist/src/components/ProjectDirectory.d.ts.map +1 -0
- package/dist/src/components/ProjectDirectory.js +48 -0
- package/dist/src/components/ProjectDirectory.js.map +1 -0
- package/dist/src/components/Reference.d.ts +6 -0
- package/dist/src/components/Reference.d.ts.map +1 -0
- package/dist/src/components/Reference.js +9 -0
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +12 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -0
- package/dist/src/components/SourceFile.js +72 -0
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/UsingDirective.d.ts +5 -0
- package/dist/src/components/UsingDirective.d.ts.map +1 -0
- package/dist/src/components/UsingDirective.js +13 -0
- package/dist/src/components/UsingDirective.js.map +1 -0
- package/dist/src/components/index.d.ts +11 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +11 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/stc/index.d.ts +43 -0
- package/dist/src/components/stc/index.d.ts.map +1 -0
- package/dist/src/components/stc/index.js +13 -0
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/modifiers.d.ts +5 -0
- package/dist/src/modifiers.d.ts.map +1 -0
- package/dist/src/modifiers.js +35 -0
- package/dist/src/modifiers.js.map +1 -0
- package/dist/src/name-policy.d.ts +5 -0
- package/dist/src/name-policy.d.ts.map +1 -0
- package/dist/src/name-policy.js +30 -0
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/symbols/csharp-output-symbol.d.ts +7 -0
- package/dist/src/symbols/csharp-output-symbol.d.ts.map +1 -0
- package/dist/src/symbols/csharp-output-symbol.js +20 -0
- package/dist/src/symbols/csharp-output-symbol.js.map +1 -0
- package/dist/src/symbols/index.d.ts +4 -0
- package/dist/src/symbols/index.d.ts.map +1 -0
- package/dist/src/symbols/index.js +4 -0
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/reference.d.ts +3 -0
- package/dist/src/symbols/reference.d.ts.map +1 -0
- package/dist/src/symbols/reference.js +55 -0
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/src/symbols/scopes.d.ts +16 -0
- package/dist/src/symbols/scopes.d.ts.map +1 -0
- package/dist/src/symbols/scopes.js +37 -0
- package/dist/src/symbols/scopes.js.map +1 -0
- package/dist/test/class.test.d.ts +2 -0
- package/dist/test/class.test.d.ts.map +1 -0
- package/dist/test/enum.test.d.ts +2 -0
- package/dist/test/enum.test.d.ts.map +1 -0
- package/dist/test/namespace.test.d.ts +2 -0
- package/dist/test/namespace.test.d.ts.map +1 -0
- package/dist/test/projectdirectory.test.d.ts +2 -0
- package/dist/test/projectdirectory.test.d.ts.map +1 -0
- package/dist/test/sourcefile.test.d.ts +2 -0
- package/dist/test/sourcefile.test.d.ts.map +1 -0
- package/dist/test/using.test.d.ts +2 -0
- package/dist/test/using.test.d.ts.map +1 -0
- package/dist/test/utils.d.ts +6 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +51 -0
- package/src/components/Class.tsx +210 -0
- package/src/components/Declaration.tsx +17 -0
- package/src/components/Enum.tsx +74 -0
- package/src/components/Name.tsx +11 -0
- package/src/components/Namespace.tsx +39 -0
- package/src/components/Parameters.tsx +52 -0
- package/src/components/ProjectDirectory.tsx +54 -0
- package/src/components/Reference.tsx +13 -0
- package/src/components/SourceFile.tsx +69 -0
- package/src/components/UsingDirective.tsx +19 -0
- package/src/components/index.ts +10 -0
- package/src/components/stc/index.ts +13 -0
- package/src/index.ts +4 -0
- package/src/modifiers.ts +45 -0
- package/src/name-policy.ts +41 -0
- package/src/symbols/csharp-output-symbol.ts +26 -0
- package/src/symbols/index.ts +3 -0
- package/src/symbols/reference.ts +65 -0
- package/src/symbols/scopes.ts +60 -0
- package/temp/api.json +3474 -0
- package/test/class.test.tsx +249 -0
- package/test/enum.test.tsx +147 -0
- package/test/namespace.test.tsx +59 -0
- package/test/projectdirectory.test.tsx +106 -0
- package/test/sourcefile.test.tsx +46 -0
- package/test/using.test.tsx +97 -0
- package/test/utils.tsx +69 -0
- package/tsconfig.json +11 -0
- package/tsdoc-metadata.json +11 -0
- package/vitest.config.ts +18 -0
package/test/utils.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as core from "@alloy-js/core";
|
|
2
|
+
import * as coretest from "@alloy-js/core/testing";
|
|
3
|
+
import { expect } from "vitest";
|
|
4
|
+
import * as csharp from "../src/index.js";
|
|
5
|
+
|
|
6
|
+
export function toSourceText(c: core.Children): string {
|
|
7
|
+
const res = core.render(
|
|
8
|
+
<core.Output namePolicy={csharp.createCSharpNamePolicy()}>
|
|
9
|
+
<csharp.Namespace name='TestCode'>
|
|
10
|
+
<csharp.SourceFile path="Test.cs">{c}</csharp.SourceFile>
|
|
11
|
+
</csharp.Namespace>
|
|
12
|
+
</core.Output>,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const file = findFile(res, "Test.cs");
|
|
16
|
+
return file.contents;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function testRender(c: core.Children): core.OutputDirectory {
|
|
20
|
+
return core.render(
|
|
21
|
+
<core.Output>
|
|
22
|
+
<csharp.Namespace name='TestCode'>
|
|
23
|
+
{c}
|
|
24
|
+
</csharp.Namespace>
|
|
25
|
+
</core.Output>,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function findFile(
|
|
30
|
+
res: core.OutputDirectory,
|
|
31
|
+
path: string,
|
|
32
|
+
): core.OutputFile {
|
|
33
|
+
const result = findFileWorker(res, path);
|
|
34
|
+
|
|
35
|
+
if (!result) {
|
|
36
|
+
throw new Error("Expected to find file " + path);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
|
|
40
|
+
function findFileWorker(
|
|
41
|
+
res: core.OutputDirectory,
|
|
42
|
+
path: string,
|
|
43
|
+
): core.OutputFile | null {
|
|
44
|
+
for (const item of res.contents) {
|
|
45
|
+
if (item.kind === "file") {
|
|
46
|
+
if (item.path.includes(path)) {
|
|
47
|
+
return item;
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
} else {
|
|
51
|
+
const found = findFileWorker(item, path);
|
|
52
|
+
if (found) {
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function assertFileContents(
|
|
62
|
+
res: core.OutputDirectory,
|
|
63
|
+
expectedFiles: Record<string, string>,
|
|
64
|
+
): void {
|
|
65
|
+
for (const [path, contents] of Object.entries(expectedFiles)) {
|
|
66
|
+
const file = findFile(res, path);
|
|
67
|
+
expect(file.contents).toBe(coretest.dedent(contents));
|
|
68
|
+
}
|
|
69
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"emitDeclarationOnly": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "dist"
|
|
7
|
+
},
|
|
8
|
+
"references": [{ "path": "../core" }],
|
|
9
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "test/**/*.ts", "test/**/*.tsx"],
|
|
10
|
+
"exclude": ["node_modules", "dist"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.47.7"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { babel } from "@rollup/plugin-babel";
|
|
2
|
+
import { defineConfig } from "vitest/config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
esbuild: {
|
|
6
|
+
jsx: "preserve",
|
|
7
|
+
sourcemap: "both",
|
|
8
|
+
},
|
|
9
|
+
plugins: [
|
|
10
|
+
babel({
|
|
11
|
+
inputSourceMap: true as any,
|
|
12
|
+
sourceMaps: "both",
|
|
13
|
+
babelHelpers: "bundled",
|
|
14
|
+
extensions: [".ts", ".tsx"],
|
|
15
|
+
presets: ["@babel/preset-typescript", "@alloy-js/babel-preset"],
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
});
|