Skip to content

Kotlin target (Metano.Compiler.Kotlin) #29

@danfma

Description

@danfma

Priority: Future

Background: Same as #TBD (Dart target). ADR-0001 establishes the per-target project pattern.

Goal

A new `Metano.Compiler.Kotlin` project that transpiles annotated C# types into idiomatic Kotlin, targeted at native Android consumers (or any JVM Kotlin project that wants to share domain types with a .NET backend).

Scope (high level)

  • New project `src/Metano.Compiler.Kotlin/` implementing `ITranspilerTarget`
  • Kotlin-specific AST + Printer
  • CLI tool: `metano-kotlin`
  • Lowering rules:
    • C# records → Kotlin `data class` (native `==` / `hashCode` / `copy`)
    • C# sealed hierarchies → Kotlin `sealed class` (tight fit)
    • C# enums → Kotlin `enum class`
    • Nullable types → Kotlin `T?`
    • Async / await → Kotlin coroutines (`suspend` / `Flow`)
  • BCL mappings: `DateTime` → `kotlinx.datetime.LocalDateTime`, `decimal` → `java.math.BigDecimal`, `Guid` → `java.util.UUID`
  • LINQ → Kotlin's `Sequence` operators (very close semantic match)
  • Gradle integration story — how does a Kotlin consumer pull in the generated sources?
  • `[EmitPackage]` support for Maven / Gradle coordinates
  • Sample project `samples/SampleTodo.Kotlin/`

Notes

Kotlin is an excellent target for Metano — the type systems line up tightly (nullable, data classes, sealed hierarchies, generics with variance). Lower porting friction than Dart.

Part of #14.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions