protected override async Task GenerateCtor(StructuredStringBuilder sb) { if (BasicCtorPermission == CtorPermissionLevel.noGeneration) { return; } using (sb.Region("Ctor")) { sb.AppendLine($"{BasicCtorPermission.ToStringFast_Enum_Only()} {Name}()"); using (sb.CurlyBrace()) { List <Task> toDo = new List <Task>(); toDo.AddRange(gen.GenerationModules.Select(mod => mod.GenerateInCtor(this, sb))); var fieldsTask = Task.WhenAll(IterateFields().Select(field => field.GenerateForCtor(sb))); toDo.Add(fieldsTask); await fieldsTask; fieldCtorsGenerated.SetResult(); await Task.WhenAll(toDo); await GenerateInitializer(sb); sb.AppendLine("CustomCtor();"); } sb.AppendLine("partial void CustomCtor();"); } }
public void GenerateInterfaceMembers(StructuredStringBuilder sb, string member) { using (sb.Region("Interface Members")) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{ListTypeName(getter: true, internalInterface: true)}{NullChar} {ObjectGen.Interface(getter: true, internalInterface: InternalGetInterface)}.{Name} => {member};"); } }
public override async Task GenerateForClass(StructuredStringBuilder sb) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"private readonly {DictInterface(getter: false)} _{Name} = new {GetActualItemClass(getter: false)};"); Comments?.Apply(sb, LoquiInterfaceType.Direct); sb.AppendLine($"public {DictInterface(getter: false)} {Name} => _{Name};"); var member = $"_{Name}"; using (sb.Region("Interface Members")) { if (!ReadOnly) { sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{DictInterface(getter: false)} {ObjectGen.Interface(internalInterface: false)}.{Name} => {member};"); } sb.AppendLine($"[DebuggerBrowsable(DebuggerBrowsableState.Never)]"); sb.AppendLine($"{DictInterface(getter: true)} {ObjectGen.Interface(getter: true, internalInterface: false)}.{Name} => {member};"); } }