https://github.com/rogeralsing/projectexodus
Transpiler from C# to Kotlin.
https://github.com/rogeralsing/projectexodus
csharp kotlin roslyn roslyn-workspace transpiler
Last synced: about 20 hours ago
JSON representation
Transpiler from C# to Kotlin.
- Host: GitHub
- URL: https://github.com/rogeralsing/projectexodus
- Owner: rogeralsing
- License: apache-2.0
- Created: 2017-07-07T16:58:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-08-20T15:39:22.000Z (about 2 months ago)
- Last Synced: 2025-09-29T01:41:48.904Z (14 days ago)
- Topics: csharp, kotlin, roslyn, roslyn-workspace, transpiler
- Language: C#
- Size: 276 KB
- Stars: 76
- Watchers: 10
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ProjectExodus
Transpiler from C# to Kotlin.
> Requires the .NET 9 SDK.
Very early pre alpha
## Usage
The transpiler expects the path to a C# solution and an output directory for the generated Kotlin files.
```bash
dotnet run --project src/CsToKotlinTranspiler --
```You may also provide the paths via environment variables:
```bash
export CS2KOTLIN_SRC=/path/to/solution.sln
export CS2KOTLIN_OUT=./kotlinOutput
dotnet run --project src/CsToKotlinTranspiler
```If neither arguments nor environment variables are supplied, the tool uses default paths.
### Single-file mode
To transpile a single C# file and print the syntax-highlighted Kotlin directly to the console, use the companion CLI:
```bash
dotnet run --project src/CsToKotlinCli --
```Run the command with `-h` to show its built-in help text. The CLI uses [Spectre.Console](https://spectreconsole.net/) for colorful output.
Demo:
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApplication3
{
class Example
{
public void Main()
{
var i = 1.ToString();
var res = Console.ReadLine();
Console.WriteLine("You wrote " + res);
}public void Conditionals()
{
var x = 1 > 2 ? "a" : "b";
}
public string Arrays(string[] strings)
{
if (strings == null)
{
return "null";
}
var x = "";
foreach (var s in strings)
{
x += "," + s;
}
return x;
}public void Linq()
{
int[] ints = {1, 2, 3, 4, 5, 6, 7, 8};
var big = ints.Where(i => i > 4).Select(i => i*2).ToList();
}public void Delegates()
{
Action del = (a, b) =>
{
Console.WriteLine("{0} {1}", a, b);
};
Func del2 = a => "hello" + a;
InvokeIt(del);
}private void InvokeIt(Action del)
{
del(1, "hello");
}
}
}
```Gets transpiled into
```kotlin
package consoleapplication3class Example {
fun main () : Unit {
var i : String = 1.toString()
var res : String = readLine()
println("You wrote " + res)
}
fun conditionals () : Unit {
var x : String = if (1 > 2) "a" else "b"
}
fun arrays (strings : Array) : String {
if (strings == null) {
return "null"
}
var x : String = ""
for(s in strings) {
x += "," + s
}
return x
}
fun linq () : Unit {
var ints : Array = arrayOf(1, 2, 3, 4, 5, 6, 7, 8)
var big : List = ints.filter{it > 4}.map{it * 2}.toList()
}
fun delegates () : Unit {
var del : (Int, String) -> Unit = {a, b ->
println("{0} {1}", a, b)
}var del2 : (Int) -> String = {a -> "hello" + a}
invokeIt(del)
}
fun invokeIt (del : (Int, String) -> Unit) : Unit {
del(1, "hello")
}
}
```