@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.
Files changed (125) hide show
  1. package/LICENSE.txt +7 -0
  2. package/api-extractor.json +4 -0
  3. package/babel.config.cjs +4 -0
  4. package/dist/src/components/Class.d.ts +33 -0
  5. package/dist/src/components/Class.d.ts.map +1 -0
  6. package/dist/src/components/Class.js +170 -0
  7. package/dist/src/components/Class.js.map +1 -0
  8. package/dist/src/components/Declaration.d.ts +8 -0
  9. package/dist/src/components/Declaration.d.ts.map +1 -0
  10. package/dist/src/components/Declaration.js +18 -0
  11. package/dist/src/components/Declaration.js.map +1 -0
  12. package/dist/src/components/Enum.d.ts +13 -0
  13. package/dist/src/components/Enum.d.ts.map +1 -0
  14. package/dist/src/components/Enum.js +65 -0
  15. package/dist/src/components/Enum.js.map +1 -0
  16. package/dist/src/components/Name.d.ts +2 -0
  17. package/dist/src/components/Name.d.ts.map +1 -0
  18. package/dist/src/components/Name.js +12 -0
  19. package/dist/src/components/Name.js.map +1 -0
  20. package/dist/src/components/Namespace.d.ts +11 -0
  21. package/dist/src/components/Namespace.d.ts.map +1 -0
  22. package/dist/src/components/Namespace.js +35 -0
  23. package/dist/src/components/Namespace.js.map +1 -0
  24. package/dist/src/components/Parameters.d.ts +13 -0
  25. package/dist/src/components/Parameters.d.ts.map +1 -0
  26. package/dist/src/components/Parameters.js +34 -0
  27. package/dist/src/components/Parameters.js.map +1 -0
  28. package/dist/src/components/ProjectDirectory.d.ts +12 -0
  29. package/dist/src/components/ProjectDirectory.d.ts.map +1 -0
  30. package/dist/src/components/ProjectDirectory.js +48 -0
  31. package/dist/src/components/ProjectDirectory.js.map +1 -0
  32. package/dist/src/components/Reference.d.ts +6 -0
  33. package/dist/src/components/Reference.d.ts.map +1 -0
  34. package/dist/src/components/Reference.js +9 -0
  35. package/dist/src/components/Reference.js.map +1 -0
  36. package/dist/src/components/SourceFile.d.ts +12 -0
  37. package/dist/src/components/SourceFile.d.ts.map +1 -0
  38. package/dist/src/components/SourceFile.js +72 -0
  39. package/dist/src/components/SourceFile.js.map +1 -0
  40. package/dist/src/components/UsingDirective.d.ts +5 -0
  41. package/dist/src/components/UsingDirective.d.ts.map +1 -0
  42. package/dist/src/components/UsingDirective.js +13 -0
  43. package/dist/src/components/UsingDirective.js.map +1 -0
  44. package/dist/src/components/index.d.ts +11 -0
  45. package/dist/src/components/index.d.ts.map +1 -0
  46. package/dist/src/components/index.js +11 -0
  47. package/dist/src/components/index.js.map +1 -0
  48. package/dist/src/components/stc/index.d.ts +43 -0
  49. package/dist/src/components/stc/index.d.ts.map +1 -0
  50. package/dist/src/components/stc/index.js +13 -0
  51. package/dist/src/components/stc/index.js.map +1 -0
  52. package/dist/src/index.d.ts +5 -0
  53. package/dist/src/index.d.ts.map +1 -0
  54. package/dist/src/index.js +5 -0
  55. package/dist/src/index.js.map +1 -0
  56. package/dist/src/modifiers.d.ts +5 -0
  57. package/dist/src/modifiers.d.ts.map +1 -0
  58. package/dist/src/modifiers.js +35 -0
  59. package/dist/src/modifiers.js.map +1 -0
  60. package/dist/src/name-policy.d.ts +5 -0
  61. package/dist/src/name-policy.d.ts.map +1 -0
  62. package/dist/src/name-policy.js +30 -0
  63. package/dist/src/name-policy.js.map +1 -0
  64. package/dist/src/symbols/csharp-output-symbol.d.ts +7 -0
  65. package/dist/src/symbols/csharp-output-symbol.d.ts.map +1 -0
  66. package/dist/src/symbols/csharp-output-symbol.js +20 -0
  67. package/dist/src/symbols/csharp-output-symbol.js.map +1 -0
  68. package/dist/src/symbols/index.d.ts +4 -0
  69. package/dist/src/symbols/index.d.ts.map +1 -0
  70. package/dist/src/symbols/index.js +4 -0
  71. package/dist/src/symbols/index.js.map +1 -0
  72. package/dist/src/symbols/reference.d.ts +3 -0
  73. package/dist/src/symbols/reference.d.ts.map +1 -0
  74. package/dist/src/symbols/reference.js +55 -0
  75. package/dist/src/symbols/reference.js.map +1 -0
  76. package/dist/src/symbols/scopes.d.ts +16 -0
  77. package/dist/src/symbols/scopes.d.ts.map +1 -0
  78. package/dist/src/symbols/scopes.js +37 -0
  79. package/dist/src/symbols/scopes.js.map +1 -0
  80. package/dist/test/class.test.d.ts +2 -0
  81. package/dist/test/class.test.d.ts.map +1 -0
  82. package/dist/test/enum.test.d.ts +2 -0
  83. package/dist/test/enum.test.d.ts.map +1 -0
  84. package/dist/test/namespace.test.d.ts +2 -0
  85. package/dist/test/namespace.test.d.ts.map +1 -0
  86. package/dist/test/projectdirectory.test.d.ts +2 -0
  87. package/dist/test/projectdirectory.test.d.ts.map +1 -0
  88. package/dist/test/sourcefile.test.d.ts +2 -0
  89. package/dist/test/sourcefile.test.d.ts.map +1 -0
  90. package/dist/test/using.test.d.ts +2 -0
  91. package/dist/test/using.test.d.ts.map +1 -0
  92. package/dist/test/utils.d.ts +6 -0
  93. package/dist/test/utils.d.ts.map +1 -0
  94. package/dist/tsconfig.tsbuildinfo +1 -0
  95. package/package.json +51 -0
  96. package/src/components/Class.tsx +210 -0
  97. package/src/components/Declaration.tsx +17 -0
  98. package/src/components/Enum.tsx +74 -0
  99. package/src/components/Name.tsx +11 -0
  100. package/src/components/Namespace.tsx +39 -0
  101. package/src/components/Parameters.tsx +52 -0
  102. package/src/components/ProjectDirectory.tsx +54 -0
  103. package/src/components/Reference.tsx +13 -0
  104. package/src/components/SourceFile.tsx +69 -0
  105. package/src/components/UsingDirective.tsx +19 -0
  106. package/src/components/index.ts +10 -0
  107. package/src/components/stc/index.ts +13 -0
  108. package/src/index.ts +4 -0
  109. package/src/modifiers.ts +45 -0
  110. package/src/name-policy.ts +41 -0
  111. package/src/symbols/csharp-output-symbol.ts +26 -0
  112. package/src/symbols/index.ts +3 -0
  113. package/src/symbols/reference.ts +65 -0
  114. package/src/symbols/scopes.ts +60 -0
  115. package/temp/api.json +3474 -0
  116. package/test/class.test.tsx +249 -0
  117. package/test/enum.test.tsx +147 -0
  118. package/test/namespace.test.tsx +59 -0
  119. package/test/projectdirectory.test.tsx +106 -0
  120. package/test/sourcefile.test.tsx +46 -0
  121. package/test/using.test.tsx +97 -0
  122. package/test/utils.tsx +69 -0
  123. package/tsconfig.json +11 -0
  124. package/tsdoc-metadata.json +11 -0
  125. 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
+ }
@@ -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
+ });