@contractkit/plugin-csharp 0.0.0 → 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.
@@ -1,13 +1,13 @@
1
1
  $ eslint --max-warnings=0 && pnpm run build
2
2
  $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
3
- CLI Building entry: src/index.ts
4
- CLI Using tsconfig: tsconfig.json
5
- CLI tsup v8.5.1
6
- CLI Target: esnext
7
- ESM Build start
8
- ESM dist/index.js 93.08 KB
9
- ESM dist/index.js.map 198.91 KB
10
- ESM ⚡️ Build success in 28ms
11
- DTS Build start
12
- DTS ⚡️ Build success in 419ms
13
- DTS dist/index.d.ts 1.50 KB
3
+ CLI Building entry: src/index.ts
4
+ CLI Using tsconfig: tsconfig.json
5
+ CLI tsup v8.5.1
6
+ CLI Target: esnext
7
+ ESM Build start
8
+ ESM dist/index.js 93.08 KB
9
+ ESM dist/index.js.map 198.91 KB
10
+ ESM ⚡️ Build success in 293ms
11
+ DTS Build start
12
+ DTS ⚡️ Build success in 6492ms
13
+ DTS dist/index.d.ts 1.50 KB
@@ -0,0 +1,36 @@
1
+ $ vitest run --coverage
2
+
3
+  RUN  v4.1.5 /home/runner/work/ContractKit/ContractKit/packages/plugin-csharp
4
+ Coverage enabled with v8
5
+
6
+ ✓ tests/codegen-client.test.ts (26 tests) 213ms
7
+ ✓ tests/index.test.ts (10 tests) 175ms
8
+ ✓ tests/codegen-models.test.ts (63 tests) 246ms
9
+ ✓ tests/runtime.test.ts (14 tests) 47ms
10
+ ✓ tests/naming.test.ts (19 tests) 45ms
11
+ ✓ tests/scaffold.test.ts (5 tests) 37ms
12
+ ✓ tests/hoist.test.ts (10 tests) 38ms
13
+
14
+  Test Files  7 passed (7)
15
+  Tests  147 passed (147)
16
+  Start at  17:49:55
17
+  Duration  12.67s (transform 6.76s, setup 0ms, import 21.88s, tests 802ms, environment 1ms)
18
+
19
+  % Coverage report from v8
20
+ -------------------|---------|----------|---------|---------|-------------------
21
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
22
+ -------------------|---------|----------|---------|---------|-------------------
23
+ All files | 87.99 | 76.98 | 89.44 | 90.79 |
24
+ src | 88.03 | 77.05 | 89.63 | 90.83 |
25
+ ...gen-client.ts | 94.61 | 87.12 | 94.91 | 97.59 | ...94-496,513-514
26
+ ...gen-models.ts | 91.19 | 75 | 96.42 | 92.97 | ...79,881,903-906
27
+ codegen-sdk.ts | 100 | 100 | 100 | 100 |
28
+ hoist.ts | 78.66 | 61.9 | 93.1 | 79.06 | ...13-322,350-362
29
+ index.ts | 70.74 | 71.21 | 58.06 | 75.59 | ...25-329,350-369
30
+ naming.ts | 86.2 | 72.72 | 100 | 100 | ...40,164-191,204
31
+ ...converters.ts | 100 | 100 | 100 | 100 |
32
+ runtime.ts | 100 | 100 | 100 | 100 |
33
+ scaffold.ts | 100 | 100 | 100 | 100 |
34
+ tests | 86.95 | 75.67 | 88 | 89.74 |
35
+ helpers.ts | 86.95 | 75.67 | 88 | 89.74 | 99,138,146,175
36
+ -------------------|---------|----------|---------|---------|-------------------
package/CHANGELOG.md CHANGED
@@ -1 +1,11 @@
1
1
  # @contractkit/plugin-csharp
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 024df73: Add `@contractkit/plugin-csharp`, a C#/.NET SDK generator built on `System.Text.Json` and `HttpClient` with no NuGet dependencies, so a generated SDK restores and builds with no feed reachable.
8
+
9
+ It emits one file of `sealed record` models per contract file and one client of `Task`-returning `...Async` methods per operation file, alongside a small runtime (`SdkHttp`, `SdkException`, `SdkOptions`, the wire converters) and an aggregator sharing one `HttpClient` across every client. `scaffold: true` writes `<SdkName>.csproj` once, as a user-owned file.
10
+
11
+ Where it differs from the Kotlin generator it mirrors: an optional field and a required-nullable field are told apart per property (`T?` with `[JsonIgnore(WhenWritingNull)]` versus `required T?`), so a null the contract requires is written and an absent field is omitted; every tuple is hoisted with a type-level converter, so one nested in a collection still travels as a JSON array; a discriminated union is a marker interface its member records implement, so one contract can belong to several unions; and the generated output is compiled by `dotnet build` in the cross-plugin test suite wherever a .NET SDK is installed.
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
1
  {
2
- "name": "@contractkit/plugin-csharp",
3
- "version": "0.0.0",
4
- "description": "ContractKit built-in plugin: C#/.NET SDK client generation (System.Text.Json + HttpClient, no NuGet dependencies)",
5
- "license": "MIT",
6
- "author": {
7
- "name": "Marooned Software",
8
- "url": "https://github.com/MaroonedSoftware/contractkit"
9
- },
10
- "bugs": {
11
- "url": "https://github.com/MaroonedSoftware/contractkit/issues"
12
- },
13
- "homepage": "https://github.com/MaroonedSoftware/contractkit/packages/plugin-csharp#readme",
14
- "keywords": [
15
- "contractkit",
16
- "csharp",
17
- "dotnet",
18
- "system.text.json"
19
- ],
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/MaroonedSoftware/contractkit.git"
23
- },
24
- "type": "module",
25
- "main": "./dist/index.js",
26
- "module": "./dist/index.js",
27
- "types": "./dist/index.d.ts",
28
- "exports": {
29
- ".": "./dist/index.js"
30
- },
31
- "scripts": {
32
- "build": "tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
33
- "build:ci": "eslint --max-warnings=0 && pnpm run build",
34
- "lint": "eslint --fix",
35
- "format": "prettier --write .",
36
- "test": "vitest run",
37
- "test:ci": "vitest run --coverage"
38
- },
39
- "dependencies": {
40
- "@contractkit/core": "workspace:*"
41
- },
42
- "devDependencies": {
43
- "@repo/config-eslint": "workspace:*",
44
- "@repo/config-typescript": "workspace:*",
45
- "unplugin-swc": "^1.5.9",
46
- "vitest": "^4.1.5"
47
- }
48
- }
2
+ "name": "@contractkit/plugin-csharp",
3
+ "version": "0.1.0",
4
+ "description": "ContractKit built-in plugin: C#/.NET SDK client generation (System.Text.Json + HttpClient, no NuGet dependencies)",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Marooned Software",
8
+ "url": "https://github.com/MaroonedSoftware/contractkit"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/MaroonedSoftware/contractkit/issues"
12
+ },
13
+ "homepage": "https://github.com/MaroonedSoftware/contractkit/packages/plugin-csharp#readme",
14
+ "keywords": [
15
+ "contractkit",
16
+ "csharp",
17
+ "dotnet",
18
+ "system.text.json"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/MaroonedSoftware/contractkit.git"
23
+ },
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": "./dist/index.js"
30
+ },
31
+ "dependencies": {
32
+ "@contractkit/core": "0.29.0"
33
+ },
34
+ "devDependencies": {
35
+ "unplugin-swc": "^1.5.9",
36
+ "vitest": "^4.1.5",
37
+ "@repo/config-eslint": "0.3.1",
38
+ "@repo/config-typescript": "0.1.0"
39
+ },
40
+ "scripts": {
41
+ "build": "tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
42
+ "build:ci": "eslint --max-warnings=0 && pnpm run build",
43
+ "lint": "eslint --fix",
44
+ "format": "prettier --write .",
45
+ "test": "vitest run",
46
+ "test:ci": "vitest run --coverage"
47
+ }
48
+ }
@@ -1,12 +0,0 @@
1
- $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
2
- CLI Building entry: src/index.ts
3
- CLI Using tsconfig: tsconfig.json
4
- CLI tsup v8.5.1
5
- CLI Target: esnext
6
- ESM Build start
7
- ESM dist/index.js 93.08 KB
8
- ESM dist/index.js.map 198.91 KB
9
- ESM ⚡️ Build success in 19ms
10
- DTS Build start
11
- DTS ⚡️ Build success in 299ms
12
- DTS dist/index.d.ts 1.50 KB
@@ -1,34 +0,0 @@
1
- $ prettier --write .
2
- CHANGELOG.md 9ms (unchanged)
3
- dist/codegen-client.d.ts 22ms
4
- dist/codegen-models.d.ts 7ms
5
- dist/codegen-sdk.d.ts 1ms
6
- dist/hoist.d.ts 5ms
7
- dist/index.d.ts 3ms
8
- dist/index.js 97ms
9
- dist/naming.d.ts 6ms
10
- dist/runtime-converters.d.ts 1ms
11
- dist/runtime.d.ts 1ms
12
- dist/scaffold.d.ts 2ms
13
- eslint.config.js 1ms (unchanged)
14
- package.json 2ms (unchanged)
15
- README.md 20ms
16
- src/codegen-client.ts 37ms
17
- src/codegen-models.ts 40ms
18
- src/codegen-sdk.ts 3ms (unchanged)
19
- src/hoist.ts 17ms (unchanged)
20
- src/index.ts 13ms (unchanged)
21
- src/naming.ts 5ms (unchanged)
22
- src/runtime-converters.ts 1ms (unchanged)
23
- src/runtime.ts 1ms (unchanged)
24
- src/scaffold.ts 1ms (unchanged)
25
- tests/codegen-client.test.ts 13ms
26
- tests/codegen-models.test.ts 32ms
27
- tests/helpers.ts 8ms (unchanged)
28
- tests/hoist.test.ts 6ms (unchanged)
29
- tests/index.test.ts 6ms
30
- tests/naming.test.ts 4ms (unchanged)
31
- tests/runtime.test.ts 2ms (unchanged)
32
- tests/scaffold.test.ts 1ms (unchanged)
33
- tsconfig.json 1ms (unchanged)
34
- vitest.config.ts 1ms (unchanged)
@@ -1,17 +0,0 @@
1
- $ vitest run
2
-
3
-  RUN  v4.1.5 /Users/robert/projects/ContractKit/packages/plugin-csharp
4
-
5
- ✓ tests/scaffold.test.ts (5 tests) 1ms
6
- ✓ tests/naming.test.ts (19 tests) 2ms
7
- ✓ tests/runtime.test.ts (14 tests) 2ms
8
- ✓ tests/hoist.test.ts (10 tests) 2ms
9
- ✓ tests/codegen-client.test.ts (26 tests) 5ms
10
- ✓ tests/codegen-models.test.ts (63 tests) 6ms
11
- ✓ tests/index.test.ts (10 tests) 7ms
12
-
13
-  Test Files  7 passed (7)
14
-  Tests  147 passed (147)
15
-  Start at  09:19:55
16
-  Duration  213ms (transform 426ms, setup 0ms, import 716ms, tests 25ms, environment 0ms)
17
-