Beispiel #1
0
        public TypeCode ResolveExpression(ICSharpCode.NRefactory.CSharp.Expression expression)
        {
            var annotation = expression.Annotations.OfType <TypeInformation>().FirstOrDefault();

            if (annotation is null || annotation.InferredType is null)
            {
                return(TypeCode.Object);
            }

            var definition = annotation.InferredType.GetScopeTypeDefOrRef().ResolveTypeDef();

            if (definition is null)
            {
                return(TypeCode.Object);
            }

            switch (definition.FullName)
            {
            case "System.String":
                return(TypeCode.String);

            default:
                break;
            }

            return(TypeCode.Object);
        }
        public bool IsMethodGroup(ICSharpCode.NRefactory.CSharp.Expression expression)
        {
            var annotation = expression.Annotation <MethodDef>();

            if (annotation == null)
            {
                return(false);
            }
            return(expression.Annotation <PropertyDef>() == null && expression.Annotation <EventDef>() == null);
        }
Beispiel #3
0
        public bool IsMethodGroup(ICSharpCode.NRefactory.CSharp.Expression expression)
        {
            var annotation = expression.Annotation <MethodDef>();

            if (annotation != null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #4
0
        public bool?IsReferenceType(ICSharpCode.NRefactory.CSharp.Expression expression)
        {
            if (expression is ICSharpCode.NRefactory.CSharp.NullReferenceExpression)
            {
                return(true);
            }

            var annotation = expression.Annotations.OfType <TypeInformation>().FirstOrDefault();

            if (annotation is null || annotation.InferredType is null)
            {
                return(null);
            }

            var definition = annotation.InferredType.GetScopeTypeDefOrRef().ResolveTypeDef();

            if (definition is null)
            {
                return(null);
            }

            return(!definition.IsValueType);
        }
Beispiel #5
0
        public Nullable <bool> IsReferenceType(ICSharpCode.NRefactory.CSharp.Expression expression)
        {
            if (expression is ICSharpCode.NRefactory.CSharp.NullReferenceExpression)
            {
                return(true);
            }

            var annotation = expression.Annotations.OfType <TypeInformation>().FirstOrDefault();

            if (annotation == null || annotation.InferredType == null)
            {
                return(null);
            }

            var definition = annotation.InferredType.Resolve();

            if (definition == null)
            {
                return(null);
            }

            return(!Decompiler.DnlibExtensions.IsValueType(definition));
        }