private static ICollection<TypeReference> GetCustomAttributeUsedTypes(CustomAttribute attribute)
		{
			V_0 = new List<TypeReference>();
			attribute.Resolve();
			V_0.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(attribute.get_AttributeType()));
			V_1 = 0;
			while (V_1 < attribute.get_ConstructorArguments().get_Count())
			{
				V_0.AddRange(AttributesUtilities.GetAttributeArgumentValueUsedTypes(attribute.get_ConstructorArguments().get_Item(V_1)));
				V_1 = V_1 + 1;
			}
			if (attribute.get_HasConstructorArguments() || attribute.get_HasFields() || attribute.get_HasProperties())
			{
				if (attribute.get_HasProperties())
				{
					V_2 = attribute.get_AttributeType().Resolve();
					V_0.AddRange(AttributesUtilities.GetAttributeNamedArgsUsedTypes(V_2, attribute.get_Properties(), false));
				}
				if (attribute.get_HasFields())
				{
					V_3 = attribute.get_AttributeType().Resolve();
					V_0.AddRange(AttributesUtilities.GetAttributeNamedArgsUsedTypes(V_3, attribute.get_Fields(), true));
				}
			}
			return V_0;
		}
        private static ICollection <TypeReference> GetCustomAttributeUsedTypes(CustomAttribute attribute)
        {
            List <TypeReference> usedTypes = new List <TypeReference>();

            attribute.Resolve();

            usedTypes.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(attribute.AttributeType));

            for (int argIndex = 0; argIndex < attribute.ConstructorArguments.Count; argIndex++)
            {
                usedTypes.AddRange(GetAttributeArgumentValueUsedTypes(attribute.ConstructorArguments[argIndex]));
            }

            if (attribute.HasConstructorArguments || attribute.HasFields || attribute.HasProperties)
            {
                if (attribute.HasProperties)
                {
                    TypeDefinition attributeType = attribute.AttributeType.Resolve();
                    usedTypes.AddRange(GetAttributeNamedArgsUsedTypes(attributeType, attribute.Properties, false));
                }
                if (attribute.HasFields)
                {
                    TypeDefinition attributeType = attribute.AttributeType.Resolve();
                    usedTypes.AddRange(GetAttributeNamedArgsUsedTypes(attributeType, attribute.Fields, true));
                }
            }

            return(usedTypes);
        }
Ejemplo n.º 3
0
 public override void VisitExplicitCastExpression(ExplicitCastExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_ExpressionType()));
     if (node.get_UnresolvedReferenceForAmbiguousCastToObject() != null)
     {
         dummyVar0 = this.get_AmbiguousCastsToObject().Add(node);
     }
     this.VisitExplicitCastExpression(node);
     return;
 }
Ejemplo n.º 4
0
        public override void VisitCastExpression(CastExpression node)
        {
            TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.ExpressionType));
            if (node.UnresolvedReferenceForAmbiguousCastToObject != null)
            {
                this.AmbiguousCastsToObject.Add(node);
            }

            base.VisitCastExpression(node);
        }
		private static ICollection<TypeReference> GetAttributeArgumentValueUsedTypes(CustomAttributeArgument argument)
		{
			if (argument.get_Value() as CustomAttributeArgument != null)
			{
				return AttributesUtilities.GetAttributeArgumentValueUsedTypes((CustomAttributeArgument)argument.get_Value());
			}
			if (argument.get_Value() as CustomAttributeArgument[] != null)
			{
				return AttributesUtilities.GetAttributeArgumentArrayUsedTypes(argument);
			}
			V_0 = new List<TypeReference>();
			if (argument.get_Type().get_IsDefinition())
			{
				stackVariable12 = argument.get_Type() as TypeDefinition;
			}
			else
			{
				stackVariable12 = argument.get_Type().Resolve();
			}
			V_1 = stackVariable12;
			if (V_1 == null || !V_1.get_IsEnum())
			{
				if (String.op_Equality(argument.get_Type().get_Name(), "Type") && String.op_Equality(argument.get_Type().get_Namespace(), "System"))
				{
					V_0.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(argument.get_Value() as TypeReference));
				}
			}
			else
			{
				V_2 = EnumValueToFieldCombinationMatcher.GetEnumFieldDefinitionByValue(V_1.get_Fields(), argument.get_Value(), V_1.get_CustomAttributes());
				if (V_2.get_Count() != 0)
				{
					V_3 = 0;
					while (V_3 < V_2.get_Count())
					{
						V_0.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(V_2.get_Item(V_3).get_DeclaringType()));
						V_3 = V_3 + 1;
					}
				}
			}
			return V_0;
		}
        private static ICollection <TypeReference> GetAttributeArgumentValueUsedTypes(CustomAttributeArgument argument)
        {
            if (argument.Value is CustomAttributeArgument)
            {
                return(GetAttributeArgumentValueUsedTypes((CustomAttributeArgument)argument.Value));
            }
            else if (argument.Value is CustomAttributeArgument[])
            {
                return(GetAttributeArgumentArrayUsedTypes(argument));
            }

            List <TypeReference> usedTypes = new List <TypeReference>();

            TypeDefinition argumentTypeDefinition = argument.Type.IsDefinition ? argument.Type as TypeDefinition : argument.Type.Resolve();

            if (argumentTypeDefinition != null && argumentTypeDefinition.IsEnum)
            {
                List <FieldDefinition> fields = EnumValueToFieldCombinationMatcher.GetEnumFieldDefinitionByValue(argumentTypeDefinition.Fields, argument.Value, argumentTypeDefinition.CustomAttributes);
                if (fields.Count != 0)
                {
                    for (int i = 0; i < fields.Count; i++)
                    {
                        usedTypes.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(fields[i].DeclaringType));
                    }
                }
            }
            else
            {
                if (argument.Type.Name == "Type" && argument.Type.Namespace == "System")
                {
                    usedTypes.AddRange(Utilities.GetTypeReferenceTypesDepedningOn(argument.Value as TypeReference));
                }
            }

            return(usedTypes);
        }
Ejemplo n.º 7
0
 public override void VisitPropertyReferenceExpression(PropertyReferenceExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_Property().get_DeclaringType()));
     this.VisitPropertyReferenceExpression(node);
     return;
 }
Ejemplo n.º 8
0
 public override void VisitObjectCreationExpression(ObjectCreationExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_ExpressionType()));
     this.VisitObjectCreationExpression(node);
     return;
 }
Ejemplo n.º 9
0
 public override void VisitMethodReferenceExpression(MethodReferenceExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_Method().get_DeclaringType()));
     this.Visit(node.get_Target());
     return;
 }
Ejemplo n.º 10
0
 public override void VisitEnumExpression(EnumExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.ExpressionType));
     base.VisitEnumExpression(node);
 }
Ejemplo n.º 11
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_Variable().get_VariableType()));
     this.VisitVariableDeclarationExpression(node);
     return;
 }
Ejemplo n.º 12
0
 public override void VisitMethodReferenceExpression(MethodReferenceExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.Method.DeclaringType));
     Visit(node.Target);
 }
Ejemplo n.º 13
0
 public override void VisitCanCastExpression(CanCastExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.TargetType));
     base.VisitCanCastExpression(node);
 }
Ejemplo n.º 14
0
 public override void VisitArrayCreationExpression(ArrayCreationExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.ElementType));
     base.VisitArrayCreationExpression(node);
 }
Ejemplo n.º 15
0
 public override void VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.ExpressionType));
     base.VisitAnonymousObjectCreationExpression(node);
 }
Ejemplo n.º 16
0
 public override void VisitPropertyReferenceExpression(PropertyReferenceExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.Property.DeclaringType));
     base.VisitPropertyReferenceExpression(node);
 }
Ejemplo n.º 17
0
 public override void VisitCanCastExpression(CanCastExpression node)
 {
     this.get_TypesDependingOn().UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.get_TargetType()));
     this.VisitCanCastExpression(node);
     return;
 }
Ejemplo n.º 18
0
 public override void VisitVariableDeclarationExpression(VariableDeclarationExpression node)
 {
     TypesDependingOn.UnionWith(Utilities.GetTypeReferenceTypesDepedningOn(node.Variable.VariableType));
     base.VisitVariableDeclarationExpression(node);
 }