Conversion Strategies — Technical Reference

📖 This is the exhaustive technical reference. For a shorter, example-driven overview of how each Go construct maps to C#, start with ConversionStrategies.md — every section there links back here for the full detail. Read this document when you need the why: the exact emitted form, the edge cases, the converter fixes, the behavioral-test guards, and the C#-vs-Go semantic reasoning behind a decision. It is the authoritative record; the summary is the front door.

A living document, refined as more code is converted. The converter is written in Go (using the official go/ast + go/types toolchain, under src/go2cs/) and emits C# that leans on two things the visible code does not show in full: a hand-written runtime library, golib (src/core/golib/), and a set of Roslyn source generators (src/gen/go2cs-gen/) that synthesize the Go semantics which cannot be written directly in C#. See also: Architecture.md, Glossary.md and Roadmap.md.

The guiding goal: the generated C# should be both behaviorally and visually similar to the original Go, so that a Go developer can read the output and follow it. The runtime library and the generators exist to keep the visible converted code close to the Go original.

How this reference is organized. Each ## topic opens with the high-level rule (the same ground the summary covers) and is then followed by ### subsections documenting specific conversion decisions, edge cases, and fixes — most keyed to the behavioral test that guards them. When updating the converter, add the deep detail here and the reader-facing example to the summary.

Contents

Each topic is its own page. The summary, Conversion Strategies, gives the short, example-driven version of each one.