public void Execute(ISourceTextBuffer buffer, INamedTypeSymbol typeSymbol) { var ownFieldsToInject = GetOwnFieldsToInject(typeSymbol); var inheritedFieldsToInject = GetInheritedFieldsToInject(typeSymbol); if (!ownFieldsToInject.Any() && !inheritedFieldsToInject.Any()) { return; } var classNamespace = _symbolParser.GetNamespaceName(typeSymbol); var className = _symbolParser.GetTypeName(typeSymbol); buffer.WriteLine($"namespace {classNamespace}"); buffer.BeginBlock(); buffer.WriteLine($"public partial class {className}"); buffer.BeginBlock(); WriteConstructor(buffer, typeSymbol, ownFieldsToInject, inheritedFieldsToInject); buffer.EndBlock(); buffer.EndBlock(); }
private void WriteConstructor(ISourceTextBuffer buffer, INamedTypeSymbol typeSymbol, IEnumerable <IFieldSymbol> ownFields, IEnumerable <IFieldSymbol> inheritedFields) { var name = _symbolParser.GetConstructorName(typeSymbol); buffer.WriteLine($"public {name}("); buffer.Indent(); WriteParameterList(buffer, inheritedFields.Concat(ownFields)); buffer.WriteLine($")"); buffer.Dedent(); if (inheritedFields.Any()) { WriteBaseInitCall(buffer, inheritedFields); } buffer.BeginBlock(); WriteBindingList(buffer, ownFields); ResolvePostControllerMethodCall(buffer, typeSymbol); buffer.EndBlock(); }