public void NamedArgumentTypeEncoder_SZArray()
        {
            var b = new BlobBuilder();
            var e = new NamedArgumentTypeEncoder(b);

            Assert.Same(b, e.Builder);

            e.SZArray();
            AssertEx.Equal(new byte[0], b.ToArray());
            b.Clear();
        }
Esempio n. 2
0
 static void EncodeType(NamedArgumentTypeEncoder typeEnc, Type type)
 {
     if (type == typeof(Type))
     {
         typeEnc.ScalarType().SystemType();
     }
     else if (type.IsArray)
     {
         EncodeType(typeEnc.SZArray().ElementType(), type.GetElementType());
     }
     else
     {
         // Work out the primitive type code
         var primTypeCode = PrimitiveTypeCodeFromSystemTypeCode(type);
         typeEnc.ScalarType().PrimitiveType(primTypeCode);
     }
 }
Esempio n. 3
0
        public static void NamedArgumentType(this NamedArgumentTypeEncoder encoder, INamedTypeSymbol attributeType, string field)
        {
            var fieldMembers = attributeType.GetMembers(field);
            var fieldSymbol  = fieldMembers.First() as IFieldSymbol;

            if (fieldSymbol.Type.SpecialType == SpecialType.System_Object)
            {
                encoder.Object();
            }
            else if (fieldSymbol.Type.SpecialType == SpecialType.System_Array)
            {
                // TODO array type encoder
                encoder.SZArray();
            }
            else if (fieldSymbol.Type.TypeKind == TypeKind.Enum)
            {
                encoder.ScalarType().Enum(fieldSymbol.Type.ToString());
            }
            else
            {
                encoder.ScalarType().CustomElementType(fieldSymbol);
            }
        }
Esempio n. 4
0
        public void NamedArgumentTypeEncoder_SZArray()
        {
            var b = new BlobBuilder();
            var e = new NamedArgumentTypeEncoder(b);
            Assert.Same(b, e.Builder);

            e.SZArray();
            AssertEx.Equal(new byte[0], b.ToArray());
            b.Clear();
        }