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> GetAttributeNamedArgsUsedTypes(TypeDefinition attributeType, Collection<CustomAttributeNamedArgument> namedArguments, bool fields) { V_0 = new List<TypeReference>(); V_1 = 0; while (V_1 < namedArguments.get_Count()) { if (attributeType != null) { if (fields) { stackVariable19 = attributeType.get_Fields(); } else { stackVariable19 = attributeType.get_Properties(); } V_2 = null; V_3 = stackVariable19; V_4 = attributeType; do { V_2 = Utilities.FindMemberArgumentRefersTo(V_3, namedArguments.get_Item(V_1)); if (V_4.get_BaseType() == null) { break; } V_4 = V_4.get_BaseType().Resolve(); if (V_4 == null) { break; } if (fields) { stackVariable40 = V_4.get_Fields(); } else { stackVariable40 = V_4.get_Properties(); } V_3 = stackVariable40; } while (V_2 == null); if (V_2 != null) { V_0.Add(V_2.get_DeclaringType()); } } V_6 = namedArguments.get_Item(V_1); V_0.AddRange(AttributesUtilities.GetAttributeArgumentValueUsedTypes(V_6.get_Argument())); V_1 = V_1 + 1; } return V_0; }
private static ICollection<TypeReference> GetAttributeArgumentArrayUsedTypes(CustomAttributeArgument argument) { V_0 = new List<TypeReference>(); V_1 = argument.get_Value() as CustomAttributeArgument[]; V_0.Add(argument.get_Type()); V_2 = 0; while (V_2 < (int)V_1.Length) { V_0.AddRange(AttributesUtilities.GetAttributeArgumentValueUsedTypes(V_1[V_2])); V_2 = V_2 + 1; } return V_0; }
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 void AddMethodImplOptions(MethodDefinition method, CustomAttribute attribute) { if (AttributesUtilities.DoesMethodHaveMethodImplOptions(method)) { V_0 = 0; if (method.get_AggressiveInlining()) { V_0 = V_0 | 0x100; } if (method.get_IsForwardRef()) { V_0 = V_0 | 16; } if (method.get_IsInternalCall()) { V_0 = V_0 | 0x1000; } if (method.get_NoInlining()) { V_0 = V_0 | 8; } if (method.get_NoOptimization()) { V_0 = V_0 | 64; } if (method.get_IsPreserveSig() && !method.get_HasPInvokeInfo()) { V_0 = V_0 | 128; } if (method.get_IsSynchronized()) { V_0 = V_0 | 32; } if (method.get_IsUnmanaged()) { V_0 = V_0 | 4; } attribute.get_ConstructorArguments().Add(AttributesUtilities.GetMethodImplAttributeArgument(method, V_0)); } return; }
private static void AddMethodCodeType(MethodDefinition method, CustomAttribute attribute) { if (method.get_IsNative() || method.get_IsOPTIL() || method.get_IsRuntime()) { V_0 = 0; if (method.get_IsNative()) { V_0 = V_0 | 1; } if (method.get_IsOPTIL()) { V_0 = V_0 | 2; } if (method.get_IsRuntime()) { V_0 = V_0 | 3; } attribute.get_Fields().Add(new CustomAttributeNamedArgument("MethodCodeType", AttributesUtilities.GetMethodImplAttributeArgument(method, V_0))); } return; }
public static ICollection<TypeReference> GetAssemblyAttributesUsedTypes(AssemblyDefinition assembly) { V_0 = new List<TypeReference>(); V_1 = new List<ICustomAttribute>(); V_1.Add(AttributesUtilities.GetAssemblyVersionAttribute(assembly)); V_3 = assembly.get_CustomAttributes().GetEnumerator(); try { while (V_3.MoveNext()) { V_4 = V_3.get_Current(); V_4.Resolve(); V_1.Add(V_4); } } finally { V_3.Dispose(); } if (assembly.get_HasSecurityDeclarations()) { V_5 = assembly.get_SecurityDeclarations().GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); if (!V_6.get_HasSecurityAttributes()) { continue; } V_7 = V_6.get_SecurityAttributes().GetEnumerator(); try { while (V_7.MoveNext()) { V_8 = V_7.get_Current(); V_1.Add(V_8); } } finally { V_7.Dispose(); } } } finally { V_5.Dispose(); } } if (assembly.get_MainModule().get_HasExportedTypes()) { V_9 = assembly.get_MainModule().get_ExportedTypes().GetEnumerator(); try { while (V_9.MoveNext()) { V_10 = V_9.get_Current(); if (V_10.get_Scope() as ModuleReference != null) { continue; } V_1.Add(AttributesUtilities.GetExportedTypeAttribute(V_10, assembly.get_MainModule())); } } finally { V_9.Dispose(); } } V_11 = V_1.GetEnumerator(); try { while (V_11.MoveNext()) { V_12 = V_11.get_Current(); if (V_12 as CustomAttribute == null) { if (V_12 as SecurityAttribute == null) { continue; } V_13 = AttributesUtilities.GetSecurityAttributeUsedTypes(V_12 as SecurityAttribute).GetEnumerator(); try { while (V_13.MoveNext()) { V_15 = V_13.get_Current(); V_0.Add(V_15); } } finally { if (V_13 != null) { V_13.Dispose(); } } } else { V_13 = AttributesUtilities.GetCustomAttributeUsedTypes(V_12 as CustomAttribute).GetEnumerator(); try { while (V_13.MoveNext()) { V_14 = V_13.get_Current(); V_0.Add(V_14); } } finally { if (V_13 != null) { V_13.Dispose(); } } } } } finally { ((IDisposable)V_11).Dispose(); } return V_0; }