public MemberComposer(ITypeComposer type, MemberMetaInfo targetMember, ITypeSymbol composerSymbol, IReadOnlyList <MethodSignature> methods)
 {
     ParentType     = type;
     TargetMember   = targetMember;
     ComposerSymbol = composerSymbol;
     Methods        = methods;
 }
Exemplo n.º 2
0
        public IMemberComposer CreateStruct(ITypeComposer typeComposer, IComponentProvider provider, Func <GeneratingTypeName, string, INamedTypeSymbol> symbolProvider)
        {
            var components = _componentCollection.Components.Select(x => provider.ProvideComponent(x)).ToList();

            var builder = new CodeSourceFileBuilder(_typeName.Namespace);

            builder.Using("System");

            builder.AttributeHideEditor().AttributeGenerated(typeof(MemberComposerSource).Assembly);
            builder.NestType(_typeName, $"internal readonly struct {_typeName.TypeName} {GetGenericArgs()}", node => {
                // Fields & Field Initialization
                AddComponents(builder, components).NewLine();
                AddComponentInitializers(builder, provider.DiscoveryType, components).NewLine();

                // Construtor
                AddConstructor(builder, provider.DiscoveryType, components).NewLine();
                AddTryConstructor(builder, provider.DiscoveryType, components).NewLine();

                // Entry Point
                builder.Comment("Dependency Member Entry Point");
                builder.AddParsingMethods(new ParsingMethodWithTypeBuilder(_member));

                // Data Condition Methods
                for (int i = 0; i < _conditions.Count; i++)
                {
                    builder.AddFormatterMethods(_conditions[i], _member, i, GetDefaultNames).NewLine();
                }

                // Data Format Method
                builder.AddFormatterFinalMethods(_format, _member, _conditions.Count, GetDefaultNames).NewLine();

                // Data Resolve Method
                builder.Comment("Data Resolver").NewLine();
                for (var i = 0; i < components.Count; i++)
                {
                    builder.AddParsingBody(components[i], _member, _componentCollection.GetMethodNames(i)).NewLine();
                }

                // Nested Throw Helpers
                builder.Comment("Throw Helpers (Avoid inlining throw action)");
                _throwCollection.AddThrowClass(builder);
            });

            return(new MemberComposer(typeComposer, _member, symbolProvider(_typeName, builder.ToString()), GetMethodSignatures(provider)));
        }
Exemplo n.º 3
0
 public IMemberComposer Build(ITypeComposer typeComposer, MemberMetaInfo meta, GeneratingTypeName typeName, IComponentProvider provider)
 => new MemberComposerSource(meta, typeName, _conditions, _formatters, _symbolProvider)
 .CreateStruct(typeComposer, provider, (name, source) => {
     _sourceAddition.AddSource($"{typeName}.generated.cs", source);
     return(_symbolProvider.GetSymbol(name.ToString()));
 });
Exemplo n.º 4
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="composer">Injected composer</param>
 /// <param name="linker">Injected linker</param>
 /// <param name="processLogger">Process logger instance</param>
 public PrinterMarkdown(ITypeComposer composer, ILinker linker, IIndefiniteProcess processLogger)
 {
     m_linker        = linker;
     m_processLogger = processLogger;
     m_composer      = composer;
 }
 public TypeParserInfo(INamedTypeSymbol parser, ITypeComposer composer)
 {
     Parser   = parser;
     Composer = composer;
 }