Ejemplo n.º 1
0
        public override MultiValue VisitFieldReference(IFieldReferenceOperation fieldRef, StateValue state)
        {
            var field = fieldRef.Field;

            switch (field.Name)
            {
            case "EmptyTypes" when field.ContainingType.IsTypeOf("System", "Type"): {
                return(ArrayValue.Create(0));
            }

            case "Empty" when field.ContainingType.IsTypeOf("System", "String"): {
                return(new KnownStringValue(string.Empty));
            }
            }

            if (TryGetConstantValue(fieldRef, out var constValue))
            {
                return(constValue);
            }

            if (fieldRef.Field.Type.IsTypeInterestingForDataflow())
            {
                return(new FieldValue(fieldRef.Field));
            }

            return(TopValue);
        }