Convert C# template files to Fluent CSharpFile builder API.
Installation
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Inherit from CSharpTemplateBase<TModel>, implement ICSharpFileBuilderTemplate, and expose CSharpFile.
Initialize CSharpFile structure in constructor.
Implement config/transform methods: DefineFileConfig() => CSharpFile.GetConfig(); and TransformText() => CSharpFile.ToString();.
Use flow builders (AddIfStatement, AddForEachStatement) and CSharpInvocationStatement.
Register OnBuild/AfterBuild callbacks in constructor (Core=0, Enrichment=100, Extension=500, Final=1000).
Lookup callbacks must use higher priority than target template.
Resolve types inside callbacks/lambdas, never directly in constructor.
Resolve emitted type positions through the Type System APIs: GetTypeName(...) for model/type references, GetTypeName(templateId, model) for TemplateId-based references, and UseType("Namespace.Type") for framework/external types — including method return/parameter types (e.g. method.AddParameter(UseType("System.Threading.CancellationToken"), "cancellationToken")). Do not use UseType(...) for types represented in the Intent model.
For generated type declarations, put the final class/interface name on the template model/provider (for example IHasName.Name) and use the same model when resolving references via GetTypeName(templateId, model); handle name collisions before AddClass(...).
Inject DI parameters using param.IntroduceReadonlyField().
Never emit structural C# as raw strings outside the fluent API.
Never use obsolete CSharpMethodChainStatement or AddMethodChainStatement.
Never add else/catch/finally as children of a block (must be siblings).
Never use raw string interpolation for lambda arrows => or object initializer braces {}.
Never call obsolete field.WithAssignment(string) directly (use WithAssignment(new CSharpStatement(...))).
AddTypeSource(templateId) is not sufficient for single-file templates.AddTypeSource enables GetTypeName(model) resolution for file-per-model templates — it looks up the template instance by model. For single-file templates (one output, no model) like IIntegrationEventHandler, there is no model to pass, so GetTypeName cannot resolve the type and the using is never injected. Use the pattern in builder-patterns.md § "Resolving Single-File Template Namespaces" instead.