public void ListRecursiveTypeTest()
        {
            ThriftCatalog catalog = new ThriftCatalog();
            ThriftStructMetadataBuilder builder  = new ThriftStructMetadataBuilder(catalog, typeof(ListRecursiveStruct));
            ThriftStructMetadata        metadata = builder.Build();

            Assert.Equal(1, metadata.Fields.Count());
        }
        protected AbstractReflectionThriftCodec(ThriftCodecManager manager, ThriftStructMetadata metadata)
        {
            Guard.ArgumentNotNull(manager, nameof(manager));
            Guard.ArgumentNotNull(metadata, nameof(metadata));

            this._metadata = metadata;
            _fields        = new SortedDictionary <short, IThriftCodec>();

            foreach (ThriftFieldMetadata fieldMetadata in metadata.GetFields(FieldKind.ThriftField))
            {
                _fields.Add(fieldMetadata.Id, manager.GetCodec(fieldMetadata.ThriftType));
            }
        }
        public IThriftCodec GenerateThriftTypeCodec(ThriftCodecManager codecManager, ThriftStructMetadata metadata)
        {
            switch (metadata.MetadataType)
            {
            case MetadataType.Struct:
                var type      = metadata.StructType;
                var codecType = typeof(ReflectionThriftStructCodec <>).MakeGenericType(type);
                return((IThriftCodec)Activator.CreateInstance(codecType, codecManager, metadata));

            case MetadataType.Union:
            default:
                throw new ThriftyException($"encountered type {metadata.MetadataType}");
            }
        }
        public void ComplexTypeTest()
        {
            ThriftCatalog catalog = new ThriftCatalog();
            ThriftStructMetadataBuilder builder  = new ThriftStructMetadataBuilder(catalog, typeof(ComplexStruct));
            ThriftStructMetadata        metadata = builder.Build();

            var properties = typeof(ComplexStruct).GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly);

            Assert.Equal(properties.Length, metadata.Fields.Count());

            Assert.Equal(false, metadata.IsException);
            Assert.Equal(false, metadata.IsUnion);
            Assert.Equal(MetadataType.Struct, metadata.MetadataType);
            Assert.Equal(0, metadata.MethodInjections.Count());
            Assert.Equal(null, metadata.BuilderType);
        }
        private ThriftStructMetadata StructTest <T>()
        {
            ThriftCatalog catalog = new ThriftCatalog();
            ThriftStructMetadataBuilder builder  = new ThriftStructMetadataBuilder(catalog, typeof(T));
            ThriftStructMetadata        metadata = builder.Build();

            var properties = typeof(T).GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);

            Assert.Equal(properties.Length, metadata.Fields.Count());

            Assert.Equal(false, metadata.IsException);
            Assert.Equal(false, metadata.IsUnion);
            Assert.Equal(MetadataType.Struct, metadata.MetadataType);
            Assert.Equal(0, metadata.MethodInjections.Count());
            Assert.Equal(null, metadata.BuilderType);
            return(metadata);
        }
 public ReflectionThriftStructCodec(ThriftCodecManager manager, ThriftStructMetadata metadata) : base(manager, metadata)
 {
 }