Ejemplo n.º 1
0
        public TypeKind GetTypeKindForAstType(ICSharpCode.NRefactory.CSharp.AstType type)
        {
            var annotation = type.Annotation <ITypeDefOrRef>();

            if (annotation is null)
            {
                return(TypeKind.Unknown);
            }

            var definition = annotation.ResolveTypeDef();

            if (definition is null)
            {
                return(TypeKind.Unknown);
            }
            if (definition.IsClass)
            {
                return(TypeKind.Class);
            }
            if (definition.IsInterface)
            {
                return(TypeKind.Interface);
            }
            if (definition.IsEnum)
            {
                return(TypeKind.Enum);
            }
            if (definition.IsValueType)
            {
                return(TypeKind.Struct);
            }

            return(TypeKind.Unknown);
        }
Ejemplo n.º 2
0
        public TypeKind GetTypeKindForAstType(ICSharpCode.NRefactory.CSharp.AstType type)
        {
            var annotation = type.Annotation <TypeReference>();

            if (annotation == null)
            {
                return(TypeKind.Unknown);
            }

            var definition = annotation.ResolveOrThrow();

            if (definition.IsClass)
            {
                return(TypeKind.Class);
            }
            if (definition.IsInterface)
            {
                return(TypeKind.Interface);
            }
            if (definition.IsEnum)
            {
                return(TypeKind.Enum);
            }
            if (definition.IsFunctionPointer)
            {
                return(TypeKind.Delegate);
            }
            if (definition.IsValueType)
            {
                return(TypeKind.Struct);
            }

            return(TypeKind.Unknown);
        }