private static MonoMenuItem[] ExtractMenuCommands(Assembly assembly, bool modifiedSinceLastReload)
        {
            BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static;

            if (modifiedSinceLastReload)
            {
                bindingAttr |= BindingFlags.Instance;
            }
            bool @bool = EditorPrefs.GetBool("InternalMode", false);
            Dictionary <string, MonoMenuItem> dictionary = new Dictionary <string, MonoMenuItem>();

            System.Type[] typesFromAssembly = AssemblyHelper.GetTypesFromAssembly(assembly);
            foreach (System.Type type in typesFromAssembly)
            {
                MethodInfo[] methods = type.GetMethods(bindingAttr);
                for (int i = 0; i < methods.GetLength(0); i++)
                {
                    MethodInfo mi = methods[i];
                    object[]   customAttributes = mi.GetCustomAttributes(typeof(UnityEditor.MenuItem), false);
                    if ((customAttributes.Length > 0) && type.IsGenericTypeDefinition)
                    {
                        object[] args = new object[] { type.Name, mi.Name };
                        UnityEngine.Debug.LogWarningFormat("Method {0}.{1} cannot be used for menu commands because class {0} is an open generic type.", args);
                    }
                    else
                    {
                        foreach (UnityEditor.MenuItem item in customAttributes)
                        {
                            MonoMenuItem item2 = !dictionary.ContainsKey(item.menuItem) ? new MonoMenuItem() : dictionary[item.menuItem];
                            if (!ValidateMethodForMenuCommand(mi, false))
                            {
                                break;
                            }
                            if (item.menuItem.StartsWith("internal:", StringComparison.Ordinal))
                            {
                                if (!@bool)
                                {
                                    continue;
                                }
                                item2.menuItem = item.menuItem.Substring(9);
                            }
                            else
                            {
                                item2.menuItem = item.menuItem;
                            }
                            if (item.validate)
                            {
                                item2.validateType   = type;
                                item2.validateMethod = mi;
                                item2.validateName   = mi.Name;
                            }
                            else
                            {
                                item2.index         = i;
                                item2.priority      = item.priority;
                                item2.executeType   = type;
                                item2.executeMethod = mi;
                                item2.executeName   = mi.Name;
                            }
                            dictionary[item.menuItem] = item2;
                        }
                    }
                }
            }
            MonoMenuItem[] array = dictionary.Values.ToArray <MonoMenuItem>();
            Array.Sort(array, new CompareMenuIndex());
            return(array);
        }
示例#2
0
        // Called on demand
        private static void BuildDrawerTypeForTypeDictionary()
        {
            s_DrawerTypeForType = new Dictionary <Type, DrawerKeySet>();

            var loadedTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => AssemblyHelper.GetTypesFromAssembly(x)).ToArray();

            foreach (var type in EditorAssemblies.SubclassesOf(typeof(GUIDrawer)))
            {
                //Debug.Log("Drawer: " + type);
                object[] attrs = type.GetCustomAttributes(typeof(CustomPropertyDrawer), true);
                foreach (CustomPropertyDrawer editor in attrs)
                {
                    //Debug.Log("Base type: " + editor.type);
                    s_DrawerTypeForType[editor.m_Type] = new DrawerKeySet()
                    {
                        drawer = type,
                        type   = editor.m_Type
                    };

                    if (!editor.m_UseForChildren)
                    {
                        continue;
                    }

                    var candidateTypes = loadedTypes.Where(x => x.IsSubclassOf(editor.m_Type));
                    foreach (var candidateType in candidateTypes)
                    {
                        //Debug.Log("Candidate Type: "+ candidateType);
                        if (s_DrawerTypeForType.ContainsKey(candidateType) &&
                            (editor.m_Type.IsAssignableFrom(s_DrawerTypeForType[candidateType].type)))
                        {
                            //  Debug.Log("skipping");
                            continue;
                        }

                        //Debug.Log("Setting");
                        s_DrawerTypeForType[candidateType] = new DrawerKeySet()
                        {
                            drawer = type,
                            type   = editor.m_Type
                        };
                    }
                }
            }
        }
示例#3
0
 private static void BuildDrawerTypeForTypeDictionary()
 {
     ScriptAttributeUtility.s_DrawerTypeForType = new Dictionary <Type, ScriptAttributeUtility.DrawerKeySet>();
     Type[] source = AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly x) => AssemblyHelper.GetTypesFromAssembly(x)).ToArray <Type>();
     foreach (Type current in EditorAssemblies.SubclassesOf(typeof(GUIDrawer)))
     {
         object[] customAttributes = current.GetCustomAttributes(typeof(CustomPropertyDrawer), true);
         object[] array            = customAttributes;
         for (int i = 0; i < array.Length; i++)
         {
             CustomPropertyDrawer editor = (CustomPropertyDrawer)array[i];
             ScriptAttributeUtility.s_DrawerTypeForType[editor.m_Type] = new ScriptAttributeUtility.DrawerKeySet
             {
                 drawer = current,
                 type   = editor.m_Type
             };
             if (editor.m_UseForChildren)
             {
                 IEnumerable <Type> enumerable = from x in source
                                                 where x.IsSubclassOf(editor.m_Type)
                                                 select x;
                 foreach (Type current2 in enumerable)
                 {
                     if (!ScriptAttributeUtility.s_DrawerTypeForType.ContainsKey(current2) || !editor.m_Type.IsAssignableFrom(ScriptAttributeUtility.s_DrawerTypeForType[current2].type))
                     {
                         ScriptAttributeUtility.s_DrawerTypeForType[current2] = new ScriptAttributeUtility.DrawerKeySet
                         {
                             drawer = current,
                             type   = editor.m_Type
                         };
                     }
                 }
             }
         }
     }
 }
 public MaterialEnumDrawer(string enumName)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     MaterialEnumDrawer.\u003CMaterialEnumDrawer\u003Ec__AnonStorey97 drawerCAnonStorey97 = new MaterialEnumDrawer.\u003CMaterialEnumDrawer\u003Ec__AnonStorey97();
     // ISSUE: reference to a compiler-generated field
     drawerCAnonStorey97.enumName = enumName;
     // ISSUE: explicit constructor call
     base.\u002Ector();
     System.Type[] array = ((IEnumerable <Assembly>)AppDomain.CurrentDomain.GetAssemblies()).SelectMany <Assembly, System.Type>((Func <Assembly, IEnumerable <System.Type> >)(x => (IEnumerable <System.Type>)AssemblyHelper.GetTypesFromAssembly(x))).ToArray <System.Type>();
     try
     {
         // ISSUE: reference to a compiler-generated method
         System.Type enumType = ((IEnumerable <System.Type>)array).FirstOrDefault <System.Type>(new Func <System.Type, bool>(drawerCAnonStorey97.\u003C\u003Em__181));
         this.names = Enum.GetNames(enumType);
         Array values = Enum.GetValues(enumType);
         this.values = new int[values.Length];
         for (int index = 0; index < values.Length; ++index)
         {
             this.values[index] = (int)values.GetValue(index);
         }
     }
     catch (Exception ex)
     {
         // ISSUE: reference to a compiler-generated field
         Debug.LogWarningFormat("Failed to create MaterialEnum, enum {0} not found", (object)drawerCAnonStorey97.enumName);
         throw;
     }
 }
示例#5
0
 public MaterialEnumDrawer(string enumName)
 {
     Type[] source = AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly x) => AssemblyHelper.GetTypesFromAssembly(x)).ToArray <Type>();
     try
     {
         Type enumType = source.FirstOrDefault((Type x) => x.IsSubclassOf(typeof(Enum)) && (x.Name == enumName || x.FullName == enumName));
         this.names = Enum.GetNames(enumType);
         Array array = Enum.GetValues(enumType);
         this.values = new int[array.Length];
         for (int i = 0; i < array.Length; i++)
         {
             this.values[i] = (int)array.GetValue(i);
         }
     }
     catch (Exception)
     {
         Debug.LogWarningFormat("Failed to create MaterialEnum, enum {0} not found", new object[]
         {
             enumName
         });
         throw;
     }
 }
 private static void AddReferencedAssembliesRecurse(string assemblyPath, List <string> alreadyFoundAssemblies, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache, BuildTarget target)
 {
     if (!AssemblyHelper.IgnoreAssembly(assemblyPath, target))
     {
         AssemblyDefinition assemblyDefinitionCached = AssemblyHelper.GetAssemblyDefinitionCached(assemblyPath, cache);
         if (assemblyDefinitionCached == null)
         {
             throw new ArgumentException("Referenced Assembly " + Path.GetFileName(assemblyPath) + " could not be found!");
         }
         if (alreadyFoundAssemblies.IndexOf(assemblyPath) == -1)
         {
             alreadyFoundAssemblies.Add(assemblyPath);
             IEnumerable <string> source = (from i in PluginImporter.GetImporters(target).Where(delegate(PluginImporter i)
             {
                 string platformData = i.GetPlatformData(target, "CPU");
                 return(!string.IsNullOrEmpty(platformData) && !string.Equals(platformData, "AnyCPU", StringComparison.InvariantCultureIgnoreCase));
             })
                                            select Path.GetFileName(i.assetPath)).Distinct <string>();
             using (Collection <AssemblyNameReference> .Enumerator enumerator = assemblyDefinitionCached.MainModule.AssemblyReferences.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     AssemblyNameReference referencedAssembly = enumerator.Current;
                     if (!(referencedAssembly.Name == "BridgeInterface"))
                     {
                         if (!(referencedAssembly.Name == "WinRTBridge"))
                         {
                             if (!(referencedAssembly.Name == "UnityEngineProxy"))
                             {
                                 if (!AssemblyHelper.IgnoreAssembly(referencedAssembly.Name + ".dll", target))
                                 {
                                     string text = AssemblyHelper.FindAssemblyName(referencedAssembly.FullName, referencedAssembly.Name, allAssemblyPaths, foldersToSearch, cache);
                                     if (text == "")
                                     {
                                         bool     flag  = false;
                                         string[] array = new string[]
                                         {
                                             ".dll",
                                             ".winmd"
                                         };
                                         for (int j = 0; j < array.Length; j++)
                                         {
                                             string extension = array[j];
                                             if (source.Any((string p) => string.Equals(p, referencedAssembly.Name + extension, StringComparison.InvariantCultureIgnoreCase)))
                                             {
                                                 flag = true;
                                                 break;
                                             }
                                         }
                                         if (!flag)
                                         {
                                             throw new ArgumentException(string.Format("The Assembly {0} is referenced by {1} ('{2}'). But the dll is not allowed to be included or could not be found.", referencedAssembly.Name, assemblyDefinitionCached.MainModule.Assembly.Name.Name, assemblyPath));
                                         }
                                     }
                                     else
                                     {
                                         AssemblyHelper.AddReferencedAssembliesRecurse(text, alreadyFoundAssemblies, allAssemblyPaths, foldersToSearch, cache, target);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#7
0
        public static void WriteCPlusPlusFileForStaticAOTModuleRegistration(BuildTarget buildTarget, string file, CrossCompileOptions crossCompileOptions, bool advancedLic, string targetDevice, bool stripping, RuntimeClassRegistry usedClassRegistry, AssemblyReferenceChecker checker, string stagingAreaDataManaged, IIl2CppPlatformProvider platformProvider)
        {
            string text = Path.Combine(stagingAreaDataManaged, "ICallSummary.txt");
            IEnumerable <string> source = Directory.GetFiles(stagingAreaDataManaged, "UnityEngine.*Module.dll").Concat(new string[]
            {
                Path.Combine(stagingAreaDataManaged, "UnityEngine.dll")
            });
            string exe  = Path.Combine(MonoInstallationFinder.GetFrameWorksFolder(), "Tools/InternalCallRegistrationWriter/InternalCallRegistrationWriter.exe");
            string args = string.Format("-assembly=\"{0}\" -summary=\"{1}\"", source.Aggregate((string dllArg, string next) => dllArg + ";" + next), text);

            Runner.RunManagedProgram(exe, args);
            HashSet <UnityType> hashSet;
            HashSet <string>    nativeModules;

            CodeStrippingUtils.GenerateDependencies(Path.GetDirectoryName(stagingAreaDataManaged), text, usedClassRegistry, stripping, out hashSet, out nativeModules, platformProvider);
            using (TextWriter textWriter = new StreamWriter(file))
            {
                string[]             assemblyFileNames   = checker.GetAssemblyFileNames();
                AssemblyDefinition[] assemblyDefinitions = checker.GetAssemblyDefinitions();
                bool      flag      = (crossCompileOptions & CrossCompileOptions.FastICall) != CrossCompileOptions.Dynamic;
                ArrayList arrayList = MonoAOTRegistration.BuildNativeMethodList(assemblyDefinitions);
                if (buildTarget == BuildTarget.iOS)
                {
                    textWriter.WriteLine("#include \"RegisterMonoModules.h\"");
                    textWriter.WriteLine("#include <stdio.h>");
                }
                textWriter.WriteLine("");
                textWriter.WriteLine("#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR");
                textWriter.WriteLine("    #define DECL_USER_FUNC(f) void f() __attribute__((weak_import))");
                textWriter.WriteLine("    #define REGISTER_USER_FUNC(f)\\");
                textWriter.WriteLine("        do {\\");
                textWriter.WriteLine("        if(f != NULL)\\");
                textWriter.WriteLine("            mono_dl_register_symbol(#f, (void*)f);\\");
                textWriter.WriteLine("        else\\");
                textWriter.WriteLine("            ::printf_console(\"Symbol '%s' not found. Maybe missing implementation for Simulator?\\n\", #f);\\");
                textWriter.WriteLine("        }while(0)");
                textWriter.WriteLine("#else");
                textWriter.WriteLine("    #define DECL_USER_FUNC(f) void f() ");
                textWriter.WriteLine("    #if !defined(__arm64__)");
                textWriter.WriteLine("    #define REGISTER_USER_FUNC(f) mono_dl_register_symbol(#f, (void*)&f)");
                textWriter.WriteLine("    #else");
                textWriter.WriteLine("        #define REGISTER_USER_FUNC(f)");
                textWriter.WriteLine("    #endif");
                textWriter.WriteLine("#endif");
                textWriter.WriteLine("extern \"C\"\n{");
                textWriter.WriteLine("    typedef void* gpointer;");
                textWriter.WriteLine("    typedef int gboolean;");
                if (buildTarget == BuildTarget.iOS)
                {
                    textWriter.WriteLine("    const char*         UnityIPhoneRuntimeVersion = \"{0}\";", Application.unityVersion);
                    textWriter.WriteLine("    void                mono_dl_register_symbol (const char* name, void *addr);");
                    textWriter.WriteLine("#if !defined(__arm64__)");
                    textWriter.WriteLine("    extern int          mono_ficall_flag;");
                    textWriter.WriteLine("#endif");
                }
                textWriter.WriteLine("    void                mono_aot_register_module(gpointer *aot_info);");
                textWriter.WriteLine("#if __ORBIS__ || SN_TARGET_PSP2");
                textWriter.WriteLine("#define DLL_EXPORT __declspec(dllexport)");
                textWriter.WriteLine("#else");
                textWriter.WriteLine("#define DLL_EXPORT");
                textWriter.WriteLine("#endif");
                textWriter.WriteLine("#if !(TARGET_IPHONE_SIMULATOR)");
                textWriter.WriteLine("    extern gboolean     mono_aot_only;");
                for (int i = 0; i < assemblyFileNames.Length; i++)
                {
                    string arg   = assemblyFileNames[i];
                    string text2 = assemblyDefinitions[i].Name.Name;
                    text2 = text2.Replace(".", "_");
                    text2 = text2.Replace("-", "_");
                    text2 = text2.Replace(" ", "_");
                    textWriter.WriteLine("    extern gpointer*    mono_aot_module_{0}_info; // {1}", text2, arg);
                }
                textWriter.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR)");
                IEnumerator enumerator = arrayList.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        string arg2 = (string)enumerator.Current;
                        textWriter.WriteLine("    DECL_USER_FUNC({0});", arg2);
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                textWriter.WriteLine("}");
                textWriter.WriteLine("DLL_EXPORT void RegisterMonoModules()");
                textWriter.WriteLine("{");
                textWriter.WriteLine("#if !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)");
                textWriter.WriteLine("    mono_aot_only = true;");
                if (buildTarget == BuildTarget.iOS)
                {
                    textWriter.WriteLine("    mono_ficall_flag = {0};", (!flag) ? "false" : "true");
                }
                AssemblyDefinition[] array = assemblyDefinitions;
                for (int j = 0; j < array.Length; j++)
                {
                    AssemblyDefinition assemblyDefinition = array[j];
                    string             text3 = assemblyDefinition.Name.Name;
                    text3 = text3.Replace(".", "_");
                    text3 = text3.Replace("-", "_");
                    text3 = text3.Replace(" ", "_");
                    textWriter.WriteLine("    mono_aot_register_module(mono_aot_module_{0}_info);", text3);
                }
                textWriter.WriteLine("#endif // !(TARGET_IPHONE_SIMULATOR) && !defined(__arm64__)");
                textWriter.WriteLine("");
                if (buildTarget == BuildTarget.iOS)
                {
                    IEnumerator enumerator2 = arrayList.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            string arg3 = (string)enumerator2.Current;
                            textWriter.WriteLine("    REGISTER_USER_FUNC({0});", arg3);
                        }
                    }
                    finally
                    {
                        IDisposable disposable2;
                        if ((disposable2 = (enumerator2 as IDisposable)) != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }
                textWriter.WriteLine("}");
                textWriter.WriteLine("");
                if (buildTarget == BuildTarget.iOS)
                {
                    List <AssemblyDefinition> list = new List <AssemblyDefinition>();
                    for (int k = 0; k < assemblyDefinitions.Length; k++)
                    {
                        if (AssemblyHelper.IsUnityEngineModule(assemblyDefinitions[k]))
                        {
                            list.Add(assemblyDefinitions[k]);
                        }
                    }
                    MonoAOTRegistration.GenerateRegisterInternalCalls(list.ToArray(), textWriter);
                    MonoAOTRegistration.GenerateRegisterModules(hashSet, nativeModules, textWriter, stripping);
                    if (stripping && usedClassRegistry != null)
                    {
                        MonoAOTRegistration.GenerateRegisterClassesForStripping(hashSet, textWriter);
                    }
                    else
                    {
                        MonoAOTRegistration.GenerateRegisterClasses(hashSet, textWriter);
                    }
                }
                textWriter.Close();
            }
        }
示例#8
0
        internal static void Rebuild(Assembly assembly)
        {
            Type[] typesFromAssembly = AssemblyHelper.GetTypesFromAssembly(assembly);
            Type[] array             = typesFromAssembly;
            for (int i = 0; i < array.Length; i++)
            {
                Type     type             = array[i];
                object[] customAttributes = type.GetCustomAttributes(typeof(CustomEditor), false);
                object[] array2           = customAttributes;
                int      j = 0;
                while (j < array2.Length)
                {
                    CustomEditor customEditor = (CustomEditor)array2[j];
                    CustomEditorAttributes.MonoEditorType monoEditorType = new CustomEditorAttributes.MonoEditorType();
                    if (customEditor.m_InspectedType == null)
                    {
                        Debug.Log("Can't load custom inspector " + type.Name + " because the inspected type is null.");
                    }
                    else if (!type.IsSubclassOf(typeof(Editor)))
                    {
                        if (!(type.FullName == "TweakMode") || !type.IsEnum || !(customEditor.m_InspectedType.FullName == "BloomAndFlares"))
                        {
                            Debug.LogWarning(type.Name + " uses the CustomEditor attribute but does not inherit from Editor.\nYou must inherit from Editor. See the Editor class script documentation.");
                        }
                    }
                    else
                    {
                        monoEditorType.m_InspectedType         = customEditor.m_InspectedType;
                        monoEditorType.m_InspectorType         = type;
                        monoEditorType.m_EditorForChildClasses = customEditor.m_EditorForChildClasses;
                        monoEditorType.m_IsFallback            = customEditor.isFallback;
                        CustomEditorForRenderPipelineAttribute customEditorForRenderPipelineAttribute = customEditor as CustomEditorForRenderPipelineAttribute;
                        if (customEditorForRenderPipelineAttribute != null)
                        {
                            monoEditorType.m_RenderPipelineType = customEditorForRenderPipelineAttribute.renderPipelineType;
                        }
                        List <CustomEditorAttributes.MonoEditorType> list;
                        if (!CustomEditorAttributes.kSCustomEditors.TryGetValue(customEditor.m_InspectedType, out list))
                        {
                            list = new List <CustomEditorAttributes.MonoEditorType>();
                            CustomEditorAttributes.kSCustomEditors[customEditor.m_InspectedType] = list;
                        }
                        list.Add(monoEditorType);
                        if (type.GetCustomAttributes(typeof(CanEditMultipleObjects), false).Length > 0)
                        {
                            List <CustomEditorAttributes.MonoEditorType> list2;
                            if (!CustomEditorAttributes.kSCustomMultiEditors.TryGetValue(customEditor.m_InspectedType, out list2))
                            {
                                list2 = new List <CustomEditorAttributes.MonoEditorType>();
                                CustomEditorAttributes.kSCustomMultiEditors[customEditor.m_InspectedType] = list2;
                            }
                            list2.Add(monoEditorType);
                        }
                    }
IL_1CF:
                    j++;
                    continue;
                    goto IL_1CF;
                }
            }
        }
        // Single argument: enum type name; entry names & values fetched via reflection
        public MaterialEnumDrawer(string enumName)
        {
            var loadedTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => AssemblyHelper.GetTypesFromAssembly(x)).ToArray();

            try
            {
                var enumType = loadedTypes.FirstOrDefault(
                    x => x.IsSubclassOf(typeof(Enum)) && (x.Name == enumName || x.FullName == enumName)
                    );
                var enumNames = Enum.GetNames(enumType);
                this.names = new GUIContent[enumNames.Length];
                for (int i = 0; i < enumNames.Length; ++i)
                {
                    this.names[i] = new GUIContent(enumNames[i]);
                }

                var enumVals = Enum.GetValues(enumType);
                values = new int[enumVals.Length];
                for (var i = 0; i < enumVals.Length; ++i)
                {
                    values[i] = (int)enumVals.GetValue(i);
                }
            }
            catch (Exception)
            {
                Debug.LogWarningFormat("Failed to create MaterialEnum, enum {0} not found", enumName);
                throw;
            }
        }
示例#10
0
        internal static ICollection <string> FindAssemblies(string basePath, int maxDepth)
        {
            List <string> stringList = new List <string>();

            if (maxDepth == 0)
            {
                return((ICollection <string>)stringList);
            }
            try
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(basePath);
                stringList.AddRange(((IEnumerable <FileInfo>)directoryInfo.GetFiles()).Where <FileInfo>((Func <FileInfo, bool>)(file => AssemblyHelper.IsManagedAssembly(file.FullName))).Select <FileInfo, string>((Func <FileInfo, string>)(file => file.FullName)));
                foreach (DirectoryInfo directory in directoryInfo.GetDirectories())
                {
                    stringList.AddRange((IEnumerable <string>)AssemblyHelper.FindAssemblies(directory.FullName, maxDepth - 1));
                }
            }
            catch (Exception ex)
            {
            }
            return((ICollection <string>)stringList);
        }
示例#11
0
 internal static ICollection <string> FindAssemblies(string basePath)
 {
     return(AssemblyHelper.FindAssemblies(basePath, 10));
 }
示例#12
0
 public static string[] FindAssembliesReferencedBy(string path, string[] foldersToSearch, BuildTarget target)
 {
     return(AssemblyHelper.FindAssembliesReferencedBy(new string[1] {
         path
     }, foldersToSearch, target));
 }
示例#13
0
        private static void AddReferencedAssembliesRecurse(string assemblyPath, List <string> alreadyFoundAssemblies, string[] allAssemblyPaths, string[] foldersToSearch, Dictionary <string, AssemblyDefinition> cache, BuildTarget target)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2D recurseCAnonStorey2D = new AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2D();
            // ISSUE: reference to a compiler-generated field
            recurseCAnonStorey2D.target = target;
            // ISSUE: reference to a compiler-generated field
            if (AssemblyHelper.IgnoreAssembly(assemblyPath, recurseCAnonStorey2D.target))
            {
                return;
            }
            AssemblyDefinition definitionCached = AssemblyHelper.GetAssemblyDefinitionCached(assemblyPath, cache);

            if (definitionCached == null)
            {
                throw new ArgumentException("Referenced Assembly " + Path.GetFileName(assemblyPath) + " could not be found!");
            }
            if (alreadyFoundAssemblies.IndexOf(assemblyPath) != -1)
            {
                return;
            }
            alreadyFoundAssemblies.Add(assemblyPath);
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated method
            IEnumerable <string> source = ((IEnumerable <PluginImporter>)PluginImporter.GetImporters(recurseCAnonStorey2D.target)).Where <PluginImporter>(new Func <PluginImporter, bool>(recurseCAnonStorey2D.\u003C\u003Em__40)).Select <PluginImporter, string>((Func <PluginImporter, string>)(i => Path.GetFileName(i.assetPath))).Distinct <string>();

            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2E recurseCAnonStorey2E = new AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2E();
            using (Collection <AssemblyNameReference> .Enumerator enumerator = definitionCached.get_MainModule().get_AssemblyReferences().GetEnumerator())
            {
                // ISSUE: explicit reference operation
                while (((Collection <AssemblyNameReference> .Enumerator)@enumerator).MoveNext())
                {
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: explicit reference operation
                    recurseCAnonStorey2E.referencedAssembly = ((Collection <AssemblyNameReference> .Enumerator)@enumerator).get_Current();
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    // ISSUE: reference to a compiler-generated field
                    if (!(recurseCAnonStorey2E.referencedAssembly.get_Name() == "BridgeInterface") && !(recurseCAnonStorey2E.referencedAssembly.get_Name() == "WinRTBridge") && (!(recurseCAnonStorey2E.referencedAssembly.get_Name() == "UnityEngineProxy") && !AssemblyHelper.IgnoreAssembly(recurseCAnonStorey2E.referencedAssembly.get_Name() + ".dll", recurseCAnonStorey2D.target)))
                    {
                        // ISSUE: reference to a compiler-generated field
                        // ISSUE: reference to a compiler-generated field
                        string assemblyName = AssemblyHelper.FindAssemblyName(recurseCAnonStorey2E.referencedAssembly.get_FullName(), recurseCAnonStorey2E.referencedAssembly.get_Name(), allAssemblyPaths, foldersToSearch, cache);
                        if (assemblyName == string.Empty)
                        {
                            bool flag = false;
                            // ISSUE: object of a compiler-generated type is created
                            // ISSUE: variable of a compiler-generated type
                            AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2F recurseCAnonStorey2F = new AssemblyHelper.\u003CAddReferencedAssembliesRecurse\u003Ec__AnonStorey2F();
                            // ISSUE: reference to a compiler-generated field
                            recurseCAnonStorey2F.\u003C\u003Ef__ref\u002446 = recurseCAnonStorey2E;
                            string[] strArray = new string[2]
                            {
                                ".dll",
                                ".winmd"
                            };
                            foreach (string str in strArray)
                            {
                                // ISSUE: reference to a compiler-generated field
                                recurseCAnonStorey2F.extension = str;
                                // ISSUE: reference to a compiler-generated method
                                if (source.Any <string>(new Func <string, bool>(recurseCAnonStorey2F.\u003C\u003Em__42)))
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                // ISSUE: reference to a compiler-generated field
                                throw new ArgumentException(string.Format("The Assembly {0} is referenced by {1} ('{2}'). But the dll is not allowed to be included or could not be found.", (object)recurseCAnonStorey2E.referencedAssembly.get_Name(), (object)((AssemblyNameReference)definitionCached.get_MainModule().get_Assembly().get_Name()).get_Name(), (object)assemblyPath));
                            }
                        }
                        else
                        {
                            // ISSUE: reference to a compiler-generated field
                            AssemblyHelper.AddReferencedAssembliesRecurse(assemblyName, alreadyFoundAssemblies, allAssemblyPaths, foldersToSearch, cache, recurseCAnonStorey2D.target);
                        }
                    }
                }
            }
        }