Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:

- name: Verify samples are regenerated cleanly
run: |
if ! git diff --quiet -- js/ 2>&1; then
if ! git diff --quiet -- targets/ 2>&1; then
echo "Generated TS files are out of sync with the C# source."
echo "Run 'dotnet build' locally and commit the regenerated files."
git status -- js/
git diff -- js/ | head -100
git status -- targets/
git diff -- targets/ | head -100
exit 1
fi

Expand All @@ -54,16 +54,16 @@ jobs:
run: bun install

- name: metano-runtime
run: cd js/metano-runtime && bun run build && bun test
run: cd targets/js/metano-runtime && bun run build && bun test

- name: sample-todo
run: cd js/sample-todo && bun run build && bun test
run: cd targets/js/sample-todo && bun run build && bun test

- name: sample-todo-service
run: cd js/sample-todo-service && bun run build && bun test
run: cd targets/js/sample-todo-service && bun run build && bun test

- name: sample-issue-tracker
run: cd js/sample-issue-tracker && bun run build && bun test
run: cd targets/js/sample-issue-tracker && bun run build && bun test

- name: Biome check
run: bunx biome check .
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Build metano-runtime
run: |
bun install
cd js/metano-runtime && bun run build
cd targets/js/metano-runtime && bun run build

# Sync version from the tag and publish to npm via Trusted Publishing.
# No NPM_TOKEN — the npm CLI uses the OIDC token from id-token: write.
Expand Down
54 changes: 35 additions & 19 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ dotnet run --project tests/Metano.Tests/ -- \
--results-directory TestResults # run tests with code coverage
dotnet run --project src/Metano.Compiler.TypeScript/ -- \
-p samples/SampleTodo/SampleTodo.csproj \
-o js/sample-todo/src --clean # transpile SampleTodo to TypeScript
-o targets/js/sample-todo/src --clean # transpile SampleTodo to TypeScript
dotnet run --project src/Metano.Compiler.Dart/ -- \
-p samples/SampleCounter/SampleCounter.csproj \
-o targets/flutter/sample_counter/lib/sample_counter --clean # transpile SampleCounter to Dart
dotnet csharpier . # format C# code
```

Expand All @@ -28,12 +31,13 @@ TUnit on .NET 10 requires `dotnet run` instead of `dotnet test`.
### JavaScript/TypeScript (Bun)

```sh
cd js/metano-runtime && bun run build # TypeScript build (tsgo)
cd js/metano-runtime && bun test # run runtime tests
cd js/sample-todo && bun run build # TS build of generated code
cd js/sample-todo && bun test # end-to-end tests (18 tests)
cd js/sample-issue-tracker && bun run build && bun test # 65 tests
cd js/sample-todo-service && bun run build && bun test # 19 tests (cross-package + Hono CRUD + JSON serialization)
cd targets/js/metano-runtime && bun run build # TypeScript build (tsgo)
cd targets/js/metano-runtime && bun test # run runtime tests
cd targets/js/sample-todo && bun run build # TS build of generated code
cd targets/js/sample-todo && bun test # end-to-end tests (18 tests)
cd targets/js/sample-issue-tracker && bun run build && bun test # 65 tests
cd targets/js/sample-todo-service && bun run build && bun test # 19 tests (cross-package + Hono CRUD + JSON serialization)
cd targets/js/sample-counter && bun run dev # Vite + SolidJS counter MVP sample
```

Always use **Bun** — never npm, yarn, or pnpm.
Expand All @@ -51,24 +55,36 @@ Metano.slnx
│ │ ├── TranspilerHost.cs # Orchestrates load → compile → target.Transform → write
│ │ ├── SymbolHelper.cs # Target-agnostic Roslyn helpers (attribute readers, type checks)
│ │ └── Diagnostics/ # MetanoDiagnostic + DiagnosticCodes (MS0001–MS0008)
│ └── Metano.Compiler.TypeScript/ # TypeScript target (depends on the core)
│ ├── TypeScriptTarget.cs # ITranspilerTarget adapter
│ ├── Commands.cs # CLI (ConsoleAppFramework) — `metano-typescript`
│ ├── PackageJsonWriter.cs # Auto-generates package.json (imports/exports/dependencies)
│ ├── Transformation/ # 39 focused handlers (TypeTransformer, ExpressionTransformer, etc.)
│ └── TypeScript/AST + Printer.cs # ~65 TS AST record types and the printer
│ ├── Metano.Compiler.TypeScript/ # TypeScript target (depends on the core)
│ │ ├── TypeScriptTarget.cs # ITranspilerTarget adapter
│ │ ├── Commands.cs # CLI (ConsoleAppFramework) — `metano-typescript`
│ │ ├── Bridge/ # IR → TS AST bridges (enums, interfaces, plain objects)
│ │ ├── PackageJsonWriter.cs # Auto-generates package.json (imports/exports/dependencies)
│ │ ├── Transformation/ # 39 focused handlers (TypeTransformer, ExpressionTransformer, etc.)
│ │ └── TypeScript/AST + Printer.cs # ~65 TS AST record types and the printer
│ └── Metano.Compiler.Dart/ # Dart/Flutter target (prototype — shape-only, no bodies yet)
│ ├── DartTarget.cs # ITranspilerTarget adapter
│ ├── Commands.cs # CLI — `metano-dart`
│ ├── Bridge/ # IR → Dart AST (enum, interface, class)
│ ├── Transformation/ # Dart transformer orchestrator
│ └── Dart/AST + Printer.cs # Minimal Dart AST + printer
├── tests/
│ └── Metano.Tests/ # 337 TUnit tests with inline C# compilation
│ └── Expected/ # Expected .ts output files for golden tests
├── samples/
│ ├── SampleTodo/ # Sample C# project for end-to-end validation
│ ├── SampleTodo.Service/ # Hono-based service sample (cross-package + [PlainObject] CRUD)
│ └── SampleIssueTracker/ # Larger sample exercising LINQ, records, modules, overloads
├── js/ # Bun workspace
│ ├── metano-runtime/ # metano-runtime (HashCode, HashSet, LINQ, type checks)
│ ├── sample-todo/ # Generated TS from SampleTodo + bun tests (18)
│ ├── sample-todo-service/ # Generated TS from SampleTodo.Service + bun tests (9)
│ └── sample-issue-tracker/ # Generated TS from SampleIssueTracker + bun tests (51)
│ ├── SampleIssueTracker/ # Larger sample exercising LINQ, records, modules, overloads
│ └── SampleCounter/ # Counter MVP sample (used by Vite + SolidJS consumer)
└── targets/ # One subfolder per language target + its samples
├── js/ # Bun workspace (TypeScript target)
│ ├── metano-runtime/ # metano-runtime (HashCode, HashSet, LINQ, type checks)
│ ├── sample-todo/ # Generated TS from SampleTodo + bun tests (18)
│ ├── sample-todo-service/ # Generated TS from SampleTodo.Service + bun tests (9)
│ ├── sample-issue-tracker/ # Generated TS from SampleIssueTracker + bun tests (51)
│ └── sample-counter/ # Vite + SolidJS MVP consumer of generated SampleCounter TS
└── flutter/ # Dart/Flutter target consumers
└── sample_counter/ # Flutter app consuming generated Dart from SampleCounter
```

### Pipeline
Expand Down
1 change: 1 addition & 0 deletions Metano.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Project Path="src/Metano/Metano.csproj" />
<Project Path="src/Metano.Compiler/Metano.Compiler.csproj" />
<Project Path="src/Metano.Compiler.TypeScript/Metano.Compiler.TypeScript.csproj" />
<Project Path="src/Metano.Compiler.Dart/Metano.Compiler.Dart.csproj" />
<Project Path="src/Metano.Build/Metano.Build.csproj" />
</Folder>
<Folder Name="/tests/">
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public record TodoItem(string Title, bool Completed = false, Priority Priority =
}
```

**Output** — `js/sample-todo/src/todo-item.ts`:
**Output** — `targets/js/sample-todo/src/todo-item.ts`:

```typescript
import { HashCode } from "metano-runtime";
Expand Down Expand Up @@ -263,7 +263,7 @@ export class TodoItem {
}
```

And `js/sample-todo/src/priority.ts`:
And `targets/js/sample-todo/src/priority.ts`:

```typescript
export const Priority = {
Expand Down Expand Up @@ -326,15 +326,19 @@ Real C# projects transpiled into TypeScript and exercised with Bun tests —
each one validates a different slice of the compiler:

- [`samples/SampleTodo`](samples/SampleTodo/) — minimal records + string
enums. Good starting point. Generates [`js/sample-todo`](js/sample-todo/).
enums. Good starting point. Generates
[`targets/js/sample-todo`](targets/js/sample-todo/).
- [`samples/SampleTodo.Service`](samples/SampleTodo.Service/) — Hono CRUD
service showing cross-package imports, `[PlainObject]` DTOs, and
`[ModuleEntryPoint]`. Generates
[`js/sample-todo-service`](js/sample-todo-service/).
[`targets/js/sample-todo-service`](targets/js/sample-todo-service/).
- [`samples/SampleIssueTracker`](samples/SampleIssueTracker/) — larger
domain model with branded IDs, rich aggregates, LINQ queries,
inheritance, and a repository. Generates
[`js/sample-issue-tracker`](js/sample-issue-tracker/).
[`targets/js/sample-issue-tracker`](targets/js/sample-issue-tracker/).
- [`samples/SampleCounter`](samples/SampleCounter/) — Counter MVP
(model + view interface + presenter) consumed by a Vite + SolidJS
frontend in [`targets/js/sample-counter`](targets/js/sample-counter/).

---

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
}
},
"files": {
"includes": ["js/metano-runtime/src/**", "js/metano-runtime/test/**"]
"includes": ["targets/js/metano-runtime/src/**", "targets/js/metano-runtime/test/**"]
}
}
2 changes: 1 addition & 1 deletion docs/adr/0005-inline-wrapper-branded-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ also protects BCL identifiers that cross the TS boundary.
- `src/Metano.Compiler.TypeScript/Transformation/InlineWrapperTransformer.cs`
- `src/Metano.Compiler.TypeScript/Transformation/TypeMapper.cs` — `Guid`
→ `UUID` mapping
- `js/metano-runtime/src/system/uuid.ts` — runtime-provided branded type
- `targets/js/metano-runtime/src/system/uuid.ts` — runtime-provided branded type
- `samples/SampleIssueTracker` — `UserId`, `IssueId` as inline wrappers
- `tests/Metano.Tests/InlineWrapperTranspileTests.cs`
- Related: [ADR-0003](0003-declarative-bcl-mappings.md) — how the
Expand Down
4 changes: 2 additions & 2 deletions docs/adr/0009-type-guards.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ namespace barrel. The `TsTypePredicateType` AST node carries the
- `src/Metano.Compiler.TypeScript/Transformation/TypeGuardBuilder.cs`
- `src/Metano.Compiler.TypeScript/TypeScript/AST/TsTypePredicateType.cs`
- `src/Metano/Annotations/GenerateGuardAttribute.cs`
- `js/metano-runtime/src/system/primitives/` — `isInt32`, `isString`,
etc.
- `targets/js/metano-runtime/src/type-checking/primitive-type-checks.ts` —
`isInt32`, `isString`, etc.
- `tests/Metano.Tests/TypeGuardTranspileTests.cs`
- [Issue #24](https://github.com/danfma/metano/issues/24) — `assertX`
throwing variant + discriminated unions (tracked follow-ups).
2 changes: 1 addition & 1 deletion docs/adr/0012-linq-eager-wrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ single C# file.

## References

- `js/metano-runtime/src/system/linq/` — `EnumerableBase` +
- `targets/js/metano-runtime/src/system/linq/` — `EnumerableBase` +
operator subclasses + terminals
- `src/Metano/Runtime/Linq.cs` — declarative LINQ mappings via
`[MapMethod]`
Expand Down
Loading