public CodeGenerator(SchemaModel model, GeneratorOptions options) { _model = model; _names = new GenNames(options); _commonGen = new CommonSnippetGen(_names); _domClassGen = new DomainClassSnippetGen(_names); _readerGen = new ReaderSnippetGen(_names); _writerGen = new WriterSnippetGen(_names); _interfaceGen = new InterfaceSnippetGen(_names); }
public static FieldDeclarationSyntax MakeTypeIdConst(ulong id, GenNames names) => FieldDeclaration( VariableDeclaration( IdentifierName("UInt64")) .WithVariables( SingletonSeparatedList <VariableDeclaratorSyntax>( VariableDeclarator(names.TypeIdField.Identifier) .WithInitializer( EqualsValueClause(HexLiteral(id)))))) .WithModifiers( TokenList( new[] { Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ConstKeyword) }));
internal string Transform(GenFile file) { NameSyntax topNamespace = GenNames.NamespaceName(file.Namespace) ?? _names.TopNamespace; var ns = NamespaceDeclaration(topNamespace); foreach (var def in file.NestedTypes) { ns = ns.AddMembers(Transform(def).ToArray()); } var cu = CompilationUnit().AddUsings( UsingDirective(ParseName("Capnp")), UsingDirective(ParseName("Capnp.Rpc")), UsingDirective(ParseName("System")), UsingDirective(ParseName("System.Collections.Generic")), UsingDirective(ParseName("System.Threading")), UsingDirective(ParseName("System.Threading.Tasks"))); cu = cu.AddMembers(ns); return(cu.NormalizeWhitespace().ToFullString()); }
public CommonSnippetGen(GenNames names) { _names = names; }
public WriterSnippetGen(GenNames names) { _names = names; }
public InterfaceSnippetGen(GenNames names) { _names = names; }
public ReaderSnippetGen(GenNames names) { _names = names; }
public DomainClassSnippetGen(GenNames names) { _names = names; }