convert
Convert a single file between C# and Calor.
calor convert <input> [options]Overview
The convert command performs bidirectional conversion between C# and Calor:
- C# → Calor: Convert
.csfiles to Calor syntax - Calor → C#: Convert
.calrfiles to generated C#
The conversion direction is automatically detected from the input file extension.
Quick Start
# Convert C# to Calor
calor convert MyService.cs
# Convert Calor to C#
calor convert MyService.calr
# Specify output path
calor convert MyService.cs --output src/MyService.calr
# Include benchmark comparison
calor convert MyService.cs --benchmarkOptions
| Option | Short | Default | Description |
|---|---|---|---|
--output | -o | Auto-detected | Output file path |
--benchmark | -b | false | Include benchmark metrics comparison |
--verbose | -v | false | Enable verbose output |
--explain | -e | false | Explain unsupported features in detail |
--no-fallback | — | false | Fail on unsupported constructs instead of emitting fallback TODOs |
--validate | — | false | Parse generated Calor before writing and report errors |
--passthrough | — | false | Preserve unconvertible C# members as §CSHARP interop blocks |
--timeout | -t | 0 | Conversion timeout in seconds; 0 disables it |
--explicit-call-closers | — | false | Emit explicit §/C for every §C call (v0.6.0-compatible output). |
--format | — | text | text or schema 2.0 json; there is no -f alias |
Auto-Detected Output Paths
If --output is not specified:
| Input | Output |
|---|---|
MyFile.cs | MyFile.calr |
MyFile.calr | MyFile.g.cs |
Supported Constructs
The converter validates generated C# before claiming a fully successful
conversion. It reports semantic losses with file:line locations and exposes
the same list as data.lossCount and data.losses[] in JSON. Unknown
operators, patterns, compound assignments, namespace handling, and local
functions no longer silently substitute a different construct.
When native conversion is impossible, the containing member is preserved as a
§CSHARP interop block and counted. --passthrough broadens that preservation
path. "Conversion successful" is printed only when there are no recorded
losses and requested validation passed.
| C# Construct | Calor Equivalent |
|---|---|
namespace | §M{id:Name} module |
class | §CL{id:Name:vis} class |
class method | §MT{id:Name:vis} method |
property | §PROP{id:Name:vis:type} property |
field | §FLD{id:type:name} field |
if/else if/else | §IF{id} / §EI / §EL branches (end at dedent) |
for loop | §L{id:var:from:to:step} |
while loop | §WH{id} |
Benchmark Comparison
Use --benchmark to see how the Calor version compares to C#:
calor convert PaymentService.cs --benchmarkThis is a local source-pair comparison, not the published 217-program v0.12 dashboard. Keep its metric output with the conversion report rather than assuming it reproduces the website headline.
Exit Codes
| Code | Meaning |
|---|---|
0 | Conversion completed; inspect the loss report to distinguish fully native from preserved interop |
1 | Missing input, unsupported route without fallback, timeout, or conversion failure |
See Also
- calor migrate - Convert entire projects
- calor assess - Find best conversion candidates
- calor benchmark - Detailed metrics comparison