v0.13.2Control flow and dataflow are rebuilt on explicit semantics, Z3 translation matches executable C# numeric rules, and the build chain is hermetic and supply-chain verified with hash- and size-pinned Z3 binaries.See what's new

convert

Convert a single file between C# and Calor.

Bash
calor convert <input> [options]

Overview

The convert command performs bidirectional conversion between C# and Calor:

  • C# → Calor: Convert .cs files to Calor syntax
  • Calor → C#: Convert .calr files to generated C#

The conversion direction is automatically detected from the input file extension.


Quick Start

Bash
# 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 --benchmark

Options

OptionShortDefaultDescription
--output-oAuto-detectedOutput file path
--benchmark-bfalseInclude benchmark metrics comparison
--verbose-vfalseEnable verbose output
--explain-efalseExplain unsupported features in detail
--no-fallbackfalseFail on unsupported constructs instead of emitting fallback TODOs
--validatefalseParse generated Calor before writing and report errors
--passthroughfalsePreserve unconvertible C# members as §CSHARP interop blocks
--timeout-t0Conversion timeout in seconds; 0 disables it
--explicit-call-closersfalseEmit explicit §/C for every §C call (v0.6.0-compatible output).
--formattexttext or schema 2.0 json; there is no -f alias

Auto-Detected Output Paths

If --output is not specified:

InputOutput
MyFile.csMyFile.calr
MyFile.calrMyFile.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# ConstructCalor 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#:

Bash
calor convert PaymentService.cs --benchmark

This 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

CodeMeaning
0Conversion completed; inspect the loss report to distinguish fully native from preserved interop
1Missing input, unsupported route without fallback, timeout, or conversion failure

See Also