public void TypeKind_ReturnTypeIsSystemUInt64_ReturnsLongType()
        {
            helper.CreateReturnType("System.UInt64");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefLong, kind);
        }
        public void TypeKind_ReturnTypeIsSystemObject_ReturnsObjectType()
        {
            helper.CreateReturnType("System.Object");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefObject, kind);
        }
        public void TypeKind_ReturnTypeIsSystemInt32_ReturnsIntType()
        {
            helper.CreateReturnType("System.Int32");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefInt, kind);
        }
        public void TypeKind_ReturnTypeIsSystemUInt16_ReturnsShortType()
        {
            helper.CreateReturnType("System.UInt16");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefShort, kind);
        }
        public void TypeKind_ReturnTypeIsSystemDouble_ReturnsDoubleType()
        {
            helper.CreateReturnType("System.Double");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefDouble, kind);
        }
        public void TypeKind_ReturnTypeIsSystemSingle_ReturnsFloatType()
        {
            helper.CreateReturnType("System.Single");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefFloat, kind);
        }
        public void TypeKind_ReturnTypeIsSystemChar_ReturnsCharType()
        {
            helper.CreateReturnType("System.Char");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefChar, kind);
        }
        public void TypeKind_ReturnTypeIsSystemDecimal_ReturnsDecimalType()
        {
            helper.CreateReturnType("System.Decimal");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefDecimal, kind);
        }
        public void TypeKind_ReturnTypeIsSystemByte_ReturnsByteType()
        {
            helper.CreateReturnType("System.Byte");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefByte, kind);
        }
示例#10
0
        public void TypeKind_ReturnTypeIsSystemVoid_ReturnsVoidType()
        {
            helper.CreateReturnType("System.Void");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefVoid, kind);
        }
示例#11
0
        public void TypeKind_ReturnTypeIsNotReferenceType_ReturnsNonClassType()
        {
            helper.CreateReturnType("Test.MyClass");
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefOther, kind);
        }
示例#12
0
        public void TypeKind_ReturnTypeIsSystemString_ReturnsStringType()
        {
            helper.CreateReturnType("System.String");
            helper.MakeReferenceType();
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefString, kind);
        }
示例#13
0
        public void TypeKind_ReturnTypeIsReferenceType_ReturnsClassType()
        {
            helper.CreateReturnType("Test.MyClass");
            AddUnderlyingClassToReturnType("Test.MyClass");
            helper.MakeReferenceType();
            CreateCodeTypeRef2();

            vsCMTypeRef kind = typeRef.TypeKind;

            Assert.AreEqual(vsCMTypeRef.vsCMTypeRefCodeType, kind);
        }
        public static vsCMTypeRef GetTypeKind(this IReturnType returnType)
        {
            vsCMTypeRef typeRef = GetSystemTypeKind(returnType.FullyQualifiedName);

            if (typeRef != vsCMTypeRef.vsCMTypeRefOther)
            {
                return(typeRef);
            }

            if (returnType.IsReferenceType.GetValueOrDefault())
            {
                return(vsCMTypeRef.vsCMTypeRefCodeType);
            }
            return(vsCMTypeRef.vsCMTypeRefOther);
        }
        protected CodeTypeRef ObjectToTypeRef(object type)
        {
            if (null == type)
            {
                throw new ArgumentNullException("type");
            }
            CodeTypeRef ctr = type as CodeTypeRef;

            if (ctr != null)
            {
                return(ctr);
            }

            if (type is int)
            {
                type = (vsCMTypeRef)(int)type;
            }

            if (type is vsCMTypeRef)
            {
                vsCMTypeRef typeRef = (vsCMTypeRef)type;
                switch (typeRef)
                {
                case vsCMTypeRef.vsCMTypeRefVoid: return(GetSystemType("System.Void"));

                case vsCMTypeRef.vsCMTypeRefString: return(GetSystemType("System.String"));

                case vsCMTypeRef.vsCMTypeRefShort: return(GetSystemType("System.Int16"));

                case vsCMTypeRef.vsCMTypeRefObject: return(GetSystemType("System.Object"));

                case vsCMTypeRef.vsCMTypeRefLong: return(GetSystemType("System.Int64"));

                case vsCMTypeRef.vsCMTypeRefInt: return(GetSystemType("System.Int32"));

                case vsCMTypeRef.vsCMTypeRefFloat: return(GetSystemType("System.Single"));

                case vsCMTypeRef.vsCMTypeRefDouble: return(GetSystemType("System.Double"));

                case vsCMTypeRef.vsCMTypeRefDecimal: return(GetSystemType("System.Decimal"));

                case vsCMTypeRef.vsCMTypeRefCodeType: return(GetSystemType("System.Type"));

                case vsCMTypeRef.vsCMTypeRefChar: return(GetSystemType("System.Char"));

                case vsCMTypeRef.vsCMTypeRefByte: return(GetSystemType("System.Byte"));

                case vsCMTypeRef.vsCMTypeRefBool: return(GetSystemType("System.Boolean"));

                case vsCMTypeRef.vsCMTypeRefArray: return(GetSystemType("System.Array"));

                case vsCMTypeRef.vsCMTypeRefVariant:
                case vsCMTypeRef.vsCMTypeRefPointer:
                case vsCMTypeRef.vsCMTypeRefOther:
                    throw new NotImplementedException(String.Format("Unknown system type: {0}", type));
                }
            }

            string stringType = type as string;

            if (stringType != null)
            {
                return(new CodeDomCodeTypeRef(dte, stringType));
            }

            throw new InvalidOperationException(String.Format("unknown type to get type from: {0} ({1})", type.GetType(), type));
        }