public ICodeNode VisitMethodInvocationExpression(MethodInvocationExpression node)
 {
     V_0 = node.get_MethodExpression();
     if (V_0 == null)
     {
         return(null);
     }
     V_1 = V_0.get_Method() as MethodDefinition;
     if (V_1 == null)
     {
         V_2 = V_0.get_Method();
         if (V_2 != null && !String.IsNullOrEmpty(V_2.get_Name()) && V_2.get_Name().StartsWith("set_") || V_2.get_Name().StartsWith("get_") || V_2.get_Name().StartsWith("put_"))
         {
             V_1 = V_2.Resolve();
         }
     }
     if (V_1 == null || !V_1.get_IsGetter() && !V_1.get_IsSetter())
     {
         return(null);
     }
     V_3 = new PropertyReferenceExpression(node, null);
     if (V_3.get_Property() == null)
     {
         return(node);
     }
     V_4 = V_3;
     if (V_1.get_IsSetter())
     {
         V_5 = node.get_Arguments().get_Count() - 1;
         V_4 = new BinaryExpression(26, V_3, node.get_Arguments().get_Item(V_5), this.typeSystem, null, false);
     }
     return(V_4);
 }
 private static void GenericInstanceFriendlyFullName(this IGenericInstance self, ILanguage language, StringBuilder builder, bool useGenericName, string leftBracket, string rightBracket)
 {
     dummyVar0 = builder.Append(leftBracket);
     V_0       = self.get_GenericArguments();
     V_1       = 0;
     while (V_1 < V_0.get_Count())
     {
         V_2 = V_0.get_Item(V_1);
         if (self.get_PostionToArgument().ContainsKey(V_1))
         {
             V_2 = self.get_PostionToArgument().get_Item(V_1);
         }
         if (V_1 > 0)
         {
             dummyVar1 = builder.Append(",");
         }
         V_3 = V_2.GetFriendlyFullName(language);
         if (useGenericName)
         {
             V_4 = V_2.Resolve();
             if (V_4 != null)
             {
                 V_3 = V_4.GetGenericFullName(language);
             }
         }
         dummyVar2 = builder.Append(V_3);
         V_1       = V_1 + 1;
     }
     dummyVar3 = builder.Append(rightBracket);
     return;
 }
Ejemplo n.º 3
0
 private string GetNameByType(TypeReference typeReference)
 {
     V_0 = typeReference.Resolve();
     if (V_0 != null && V_0.HasCompilerGeneratedAttribute())
     {
         return("variable");
     }
     if (!this.ShouldBePluralized(typeReference))
     {
         return(this.GetFriendlyNameByType(typeReference));
     }
     if (!typeReference.get_IsGenericInstance())
     {
         if (typeReference.get_GenericParameters().get_Count() != 0)
         {
             return(this.Camelize(this.GetFriendlyGenericName(typeReference), 1));
         }
         V_5 = typeReference.GetFriendlyTypeName(null, "<", ">");
         return(this.Camelize(V_5, 2));
     }
     V_1 = (GenericInstanceType)typeReference;
     V_2 = V_1.get_GenericArguments().get_Item(0);
     if (V_1.get_PostionToArgument().ContainsKey(0))
     {
         V_2 = V_1.get_PostionToArgument().get_Item(0);
     }
     V_0 = V_2.Resolve();
     if (V_0 != null && V_0.HasCompilerGeneratedAttribute())
     {
         return("collection");
     }
     return(this.Camelize(this.GetFriendlyGenericName(V_2), 2));
 }
Ejemplo n.º 4
0
 private bool IsAsyncFirstAssignmentStatement(Statement statement, out TypeDefinition asyncStateMachineType)
 {
     asyncStateMachineType = null;
     if (statement as ExpressionStatement != null)
     {
         V_0 = statement as ExpressionStatement;
         if (V_0.get_Expression() as BinaryExpression != null)
         {
             V_1 = V_0.get_Expression() as BinaryExpression;
             if (V_1.get_Right() as ThisReferenceExpression != null && V_1.get_Left() as FieldReferenceExpression != null)
             {
                 V_2 = (V_1.get_Left() as FieldReferenceExpression).get_Field().get_DeclaringType();
                 if (V_2 == null)
                 {
                     return(false);
                 }
                 V_3 = V_2.Resolve();
                 if (V_3 == null || (object)V_3.get_DeclaringType() != (object)this.methodContext.get_Method().get_DeclaringType() || !V_3.IsAsyncStateMachine())
                 {
                     return(false);
                 }
                 asyncStateMachineType = V_3;
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
 protected virtual void WriteMemberAttributesInternal(IMemberDefinition member, bool isWinRTImplementation)
 {
     this.securityAttributeToDeclaration = new Dictionary <SecurityAttribute, SecurityDeclaration>();
     V_0 = this.CollectSecurityAttributes(member);
     V_1 = member.get_CustomAttributes().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = V_1.get_Current();
             V_2.Resolve();
             if (isWinRTImplementation && this.IsWinRTActivatableAttribute(V_2))
             {
                 continue;
             }
             V_0.Add(V_2);
         }
     }
     finally
     {
         V_1.Dispose();
     }
     V_0.AddRange(this.WritePropertiesAsAttributes(member));
     this.SortAttributes(V_0);
     this.WriteAttributesInternal(member, V_0, false, false);
     return;
 }
		public static List<TypeDefinition> GetBaseTypes(this TypeDefinition targetType)
		{
			V_0 = new List<TypeDefinition>();
			if (targetType == null)
			{
				return V_0;
			}
			V_0.Add(targetType);
			V_1 = 0;
			while (V_1 < V_0.get_Count())
			{
				stackVariable10 = V_0.get_Item(V_1);
				V_2 = stackVariable10.get_BaseType();
				if (V_2 != null)
				{
					V_3 = V_2.Resolve();
					if (V_3 != null)
					{
						V_0.Add(V_3);
					}
				}
				V_4 = stackVariable10.get_Interfaces().GetEnumerator();
				try
				{
					while (V_4.MoveNext())
					{
						V_5 = V_4.get_Current();
						if (V_5 == null)
						{
							continue;
						}
						V_6 = V_5.Resolve();
						if (V_6 == null)
						{
							continue;
						}
						V_0.Add(V_6);
					}
				}
				finally
				{
					V_4.Dispose();
				}
				V_1 = V_1 + 1;
			}
			return V_0;
		}
Ejemplo n.º 7
0
 private void SetParameterMappings(StatementCollection statements)
 {
     V_0 = 0;
     while (V_0 < statements.get_Count())
     {
         if (statements.get_Item(V_0).IsAssignmentStatement())
         {
             V_1 = (statements.get_Item(V_0) as ExpressionStatement).get_Expression() as BinaryExpression;
             if (V_1.get_Left().get_CodeNodeType() == 30)
             {
                 V_2 = (V_1.get_Left() as FieldReferenceExpression).get_Field();
                 if ((object)V_2.get_DeclaringType().Resolve() == (object)this.stateMachineTypeDef)
                 {
                     this.parameterMappings.set_Item(V_2.Resolve(), V_1.get_Right());
                 }
             }
         }
         V_0 = V_0 + 1;
     }
     return;
 }
Ejemplo n.º 8
0
 private void VisitInvocationArguments(ExpressionCollection arguments, MethodReference method)
 {
     V_0 = method.get_Parameters();
     V_1 = 0;
     while (V_1 < arguments.get_Count())
     {
         V_2 = V_0.get_Item(V_1).ResolveParameterType(method);
         if (this.NeedsCast(arguments.get_Item(V_1).get_ExpressionType(), V_2))
         {
             if (arguments.get_Item(V_1).get_CodeNodeType() != 22)
             {
                 arguments.set_Item(V_1, new ExplicitCastExpression(arguments.get_Item(V_1), V_2, null));
             }
             else
             {
                 arguments.set_Item(V_1, EnumHelper.GetEnumExpression(V_2.Resolve(), arguments.get_Item(V_1) as LiteralExpression, this.typeSystem));
             }
         }
         V_1 = V_1 + 1;
     }
     return;
 }
Ejemplo n.º 9
0
 public void WriteModuleAttributes(ModuleDefinition module, ICollection <string> attributesToIgnore = null)
 {
     V_0 = new List <CustomAttribute>();
     V_1 = module.get_CustomAttributes().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = V_1.get_Current();
             V_2.Resolve();
             V_0.Add(V_2);
         }
     }
     finally
     {
         V_1.Dispose();
     }
     V_0.Sort(new Comparison <CustomAttribute>(this.u003cWriteModuleAttributesu003eb__45_0));
     V_3 = V_0.GetEnumerator();
     try
     {
         while (V_3.MoveNext())
         {
             V_4 = V_3.get_Current();
             if (attributesToIgnore != null && attributesToIgnore.Contains(V_4.get_AttributeType().get_FullName()))
             {
                 continue;
             }
             this.WriteModuleAttribute(V_4);
         }
     }
     finally
     {
         ((IDisposable)V_3).Dispose();
     }
     return;
 }
 private void WriteCustomAttributeConstructorArguments(Collection <CustomAttributeArgument> constructorArguments)
 {
     V_0 = constructorArguments.GetEnumerator();
     try
     {
         while (V_0.MoveNext())
         {
             V_1 = V_0.get_Current();
             V_2 = V_1.get_Type();
             if (!V_2.get_IsArray())
             {
                 V_5 = 2;
                 if (V_2.get_IsPrimitive() || String.op_Equality(V_2.get_FullName(), "System.String"))
                 {
                     V_5 = 3;
                 }
                 V_6 = V_2.Resolve();
                 if (V_6 == null)
                 {
                     this.WriteNotResolvedReference(V_2.get_FullName(), V_2, "Enum keyword might be missing. Please, locate the assembly where the type is defined.");
                 }
                 else
                 {
                     if (V_6.get_IsEnum())
                     {
                         V_2 = this.GetEnumerationUnderlayingType(V_6);
                         V_5 = 3;
                     }
                     this.WriteType(V_2, V_5);
                 }
             }
             else
             {
                 if ((V_2 as ArrayType).get_ElementType().get_IsPrimitive() || String.op_Equality(V_2.get_FullName(), "System.String"))
                 {
                     V_3 = 3;
                 }
                 else
                 {
                     V_3 = 2;
                 }
                 this.WriteType((V_2 as ArrayType).get_ElementType(), V_3);
                 this.Write("[");
                 V_4 = (V_1.get_Value() as Array).get_Length();
                 this.WriteLiteral(V_4.ToString());
                 this.Write("]");
             }
             this.Write("(");
             this.WriteSpace();
             if (V_1.get_Value() as Boolean == false)
             {
                 if (V_1.get_Value() as String == null)
                 {
                     if (V_1.get_Value() as CustomAttributeArgument[] == null)
                     {
                         this.WriteLiteral(V_1.get_Value().ToString());
                     }
                     else
                     {
                         this.WriteArrayValues(V_1.get_Value() as CustomAttributeArgument[]);
                     }
                 }
                 else
                 {
                     this.WriteStringLiteral((String)V_1.get_Value());
                 }
             }
             else
             {
                 this.WriteBooleanLiteral((Boolean)V_1.get_Value());
             }
             this.WriteSpace();
             this.Write(")");
             this.WriteLine();
         }
     }
     finally
     {
         V_0.Dispose();
     }
     return;
 }