//生成clr绑定
 static void GenCLRBindingByAnalysis()
 {
     //用新的分析热更dll调用引用来生成绑定代码
     ILRuntimeHelper.LoadHotfix(false);
     BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain, "Assets/Code/Game/ILRuntime/Binding");
     AssetDatabase.Refresh();
 }
    /// <summary>
    /// 生成预绑定
    /// </summary>
    static private void GenPreCLRBinding()
    {
        preBindingTypes = new List <Type>();
        var types = typeof(Button).Assembly.GetTypes().ToList(); //所有UI相关接口预绑定

        //移除黑名单
        foreach (var blackType in blackTypeList)
        {
            types.Remove(blackType);
        }
        foreach (var t in types)
        {
            if (t.IsClass && t.IsPublic && !t.IsEnum)
            {
                //除开被弃用的
                var attrs = t.GetCustomAttributes(typeof(System.ObsoleteAttribute), false);
                if (attrs.Length == 0)
                {
                    preBindingTypes.Add(t);
                }
            }
        }

        BindingCodeGenerator.GenerateBindingCode(preBindingTypes, clrbingdingClassName: "PreCLRBinding",
                                                 outputPath: "Assets/Code/Game/ILRuntime/Binding/PreBinding",
                                                 excludeMethods: blackMethodList);
    }
Пример #3
0
    //生成clr绑定
    public static void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
#if ILRUNTIME
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }
        //默认读StreammingAssets下面path
        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath + "/" + DLLPATH;
        }

        //不参与自动绑定的
        List <Type> notGenerateTypes = new List <Type>()
        {
            typeof(MethodBase), typeof(MemberInfo), typeof(FieldInfo), typeof(MethodInfo), typeof(PropertyInfo)
            , typeof(Component), typeof(Type)
        };


        //用新的分析热更dll调用引用来生成绑定代码


        ILRuntimeHelper.LoadHotfix(dllpath, false);
        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain, "Assets/LWFramework/ILRuntime/Binding/Analysis", notGenTypes: notGenerateTypes);
        ILRuntimeHelper.Close();
        AssetDatabase.Refresh();
#else
        Debug.Log("当前不是IL模式");
#endif


        //暂时先不处理
    }
Пример #4
0
    //生成clr绑定
    static public void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }
        //默认读StreammingAssets下面path
        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + "/hotfix/hotfix.dll";
        }

        //不参与自动绑定的
        List <Type> notGenerateTypes = new List <Type>()
        {
            typeof(MethodBase), typeof(MemberInfo), typeof(FieldInfo), typeof(MethodInfo), typeof(PropertyInfo)
            , typeof(Component), typeof(Type)
        };


        //用新的分析热更dll调用引用来生成绑定代码

        ILRuntimeHelper.LoadHotfix(dllpath, false);

        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain, "Assets/Code/Game/ILRuntime/Binding/Analysis", notGenTypes: notGenerateTypes);

        ILRuntimeHelper.Close();
        AssetDatabase.Refresh();

        //暂时先不处理
    }
Пример #5
0
    /// <summary>
    /// 生成预绑定
    /// </summary>
    static private void GenPreCLRBinding()
    {
        preBindingTypes = new List <Type>();
        var types = typeof(Button).Assembly.GetTypes().ToList(); //所有UI相关接口预绑定

        //移除黑名单
        foreach (var blackType in blackTypeList)
        {
            types.Remove(blackType);
        }
        foreach (var t in types)
        {
            if (t.IsClass && t.IsPublic && !t.IsEnum)
            {
                //除开被弃用的
                var attrs = t.GetCustomAttributes(typeof(System.ObsoleteAttribute), false);
                if (attrs.Length == 0)
                {
                    preBindingTypes.Add(t);
                }
            }
        }
        var output     = "Assets/Code/Game/ILRuntime/Binding/PreBinding";
        var clrbinding = IPath.Combine(output, "CLRBindings.cs");
        var prebinding = IPath.Combine(output, "PreCLRBinding.cs");

        //
        BindingCodeGenerator.GenerateBindingCode(preBindingTypes, output, excludeMethods: blackMethodList);
        var oldContent = File.ReadAllText(clrbinding);
        var newContent = oldContent.Replace("class CLRBindings", "class PreCLRBinding");

        //写入新的,删除老的
        File.WriteAllText(prebinding, newContent);
        File.Delete(clrbinding);
    }
    /// <summary>
    /// 分析dll生成
    /// </summary>
    /// <param name="platform"></param>
    /// <param name="dllpath"></param>
    static private void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }

        //默认读StreammingAssets下面path
        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath + "/" + BApplication.GetPlatformPath(platform) + DLLPATH;
        }

        //不参与自动绑定的
        List <Type> excludeTypes = new List <Type>(); //

        excludeTypes.AddRange(manualBindingTypes);
        excludeTypes.AddRange(preBindingTypes);

        //用新的分析热更dll调用引用来生成绑定代码
        var targetPath = "Assets/Code/Game/ILRuntime/Binding/Analysis";

        ILRuntimeHelper.LoadHotfix(dllpath, false);
        BindingCodeGenerator.GenerateAnalysisBindingCode(ILRuntimeHelper.AppDomain, targetPath,
                                                         blackTypes: excludeTypes);

        ILRuntimeHelper.Close();
        AssetDatabase.Refresh();
        //暂时先不处理
    }
    /// <summary>
    /// 生成手动绑定部分
    /// </summary>
    static private void GenCLRBinding()
    {
        var types = new List <Type>();

        //反射类优先生成
        types.Add(typeof(UnityEngine.Debug));
        //PreBinding
        BindingCodeGenerator.GenerateBindingCode(types, "Assets/Code/Game/ILRuntime/Binding/PreBinding");
        AssetDatabase.Refresh();
    }
Пример #8
0
    static public void GenCLRBindingBySelf()
    {
        var types = new List <Type>();

        //反射类优先生成
        types.Add(typeof(Type));
        //PreBinding
        BindingCodeGenerator.GenerateBindingCode(types, "Assets/Code/Game/ILRuntime/Binding/PreBinding");
        AssetDatabase.Refresh();
    }
    //生成clr绑定
    static public void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin)
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }

        //用新的分析热更dll调用引用来生成绑定代码
        var dllpath = Application.streamingAssetsPath + "/" + BDUtils.GetPlatformPath(platform) + "/hotfix/hotfix.dll";

        ILRuntimeHelper.LoadHotfix(dllpath, false);
        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain,
                                                 "Assets/Code/Game/ILRuntime/Binding/Analysis");
        AssetDatabase.Refresh();
        return;

        //暂时先不处理
        var assemblies = new List <Assembly>()
        {
            typeof(UnityEngine.UI.Button).Assembly,
        };
        var types = new List <Type>();

        types.Add(typeof(Vector4));
        //
//        foreach (var assm in assemblies)
//        {
//            var _ts = assm.GetTypes();
//            foreach (var t in _ts)
//            {
//                if (t.Namespace != null)
//                {
//                    if (t.FullName.Contains("UnityEngine.Android")
//                        || t.FullName.Contains("UnityEngine.iPhone")
//                        || t.FullName.Contains("UnityEngine.WSA")
//                        || t.FullName.Contains("UnityEngine.iOS")
//                        || t.FullName.Contains("UnityEngine.Windows")
//                        || t.FullName.Contains("JetBrains")
//                        || t.FullName.Contains("Editor"))
//                    {
//                        continue;
//                    }
//                }
//
//
//                types.Add(t);
//            }
//        }
//
//        types = types.Distinct().ToList();
        //PreBinding
        BindingCodeGenerator.GenerateBindingCode(types, "Assets/Code/Game/ILRuntime/Binding/PreBinding");
        AssetDatabase.Refresh();
    }
Пример #10
0
        public void BuildCLRBinding()
        {
            AppDomain appDomain = new AppDomain();

            using (MemoryStream dll = new MemoryStream(RijndaelUtil.RijndaelDecrypt("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", FileUtil.GetAsset("Assets/Resources/DLL/Unity.Hotfix.dll.bytes"))))
            {
                appDomain.LoadAssembly(dll);
                ILRuntimeUtil.LccFrameworkRegisterCrossBindingAdaptor(appDomain);
                BindingCodeGenerator.GenerateBindingCode(appDomain, "Assets/Scripts/Runtime/Core/Manager/ILRuntime/Generated");
            }
            AssetDatabase.Refresh();
        }
Пример #11
0
    static void GenerateCLRBindingByAnalysis()
    {
        //分析热更dll调用引用来生成绑定代码
        ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain();
        using (FileStream fsHotfix = new FileStream(s_ILRuntimeAnalysisHotfixDllDir, FileMode.Open, FileAccess.Read))
        {
            domain.LoadAssembly(fsHotfix);
            ILHelper.InitILRuntime(domain);
            BindingCodeGenerator.GenerateBindingCode(domain, s_ILRuntimeGeneratedCodeOutputDir);
        }

        AssetDatabase.Refresh();
    }
Пример #12
0
    static public void GenCLRBindingBySelf()
    {
#if ILRUNTIME
        var types = new List <Type>();
        //反射类优先生成
        types.Add(typeof(Type));
        //PreBinding

        BindingCodeGenerator.GenerateBindingCode(types, "Assets/LWFramework/ILRuntime/Binding/PreBinding");
        AssetDatabase.Refresh();
#else
        Debug.Log("当前不是IL模式");
#endif
    }
        public static void GenerateCLRBinding()
        {
            var types = new List <Type>
            {
                typeof(IHotfixEntry),
                typeof(IDebug)
            };

            var ms   = MonoScript.FromScriptableObject(CreateInstance(typeof(Generater)));
            var path = Path.GetDirectoryName(AssetDatabase.GetAssetPath(ms));

            path = Path.Combine(path, ".." + Path.DirectorySeparatorChar);
            BindingCodeGenerator.GenerateBindingCode(types, Path.Combine(path, "Runtime/Generated/CLR"));
        }
Пример #14
0
    public static void GenerateCLRBindingByAnalysis()
    {
        // 用新的分析热更dll调用引用来生成绑定代码
        ILRAppDomain domain  = new ILRAppDomain();
        string       dllPath = FrameDefine.P_STREAMING_ASSETS_PATH + FrameDefine.ILR_FILE_NAME;

        using (FileStream fs = new FileStream(dllPath, FileMode.Open, FileAccess.Read))
        {
            domain.LoadAssembly(fs);
            //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用
            ILRLaunch.registeCrossAdaptor(domain);
            BindingCodeGenerator.GenerateBindingCode(domain, FrameDefine.P_SCRIPT_GAME_PATH + "ILRuntime/GeneratedCLRBinding");
        }
        AssetDatabase.Refresh();
    }
Пример #15
0
        public static void GenCode()
        {
            //config
            var config = TinaX.XConfig.GetConfig <TinaX.XILRuntime.Internal.XRuntimeConfig>(TinaX.XILRuntime.Const.XRuntimeConst.ConfigPath_Resources, TinaX.AssetLoadType.Resources, false);

            if (config == null)
            {
                Debug.LogError("Generate failed: X ILRuntime config file not found.");
                return;
            }

            string output_path = config.CLRBindingOutputFolder;

            if (!output_path.StartsWith("Assets/"))
            {
                Debug.LogError("Generate failed: Output folder path in config file is invalid :" + output_path);
                return;
            }


            List <Type> list_types  = new List <Type>(CLRBindingDefineInternal.BindTypes);
            Type        t_interface = typeof(ICLRBindingData);
            var         types       = AppDomain.CurrentDomain.GetAssemblies()
                                      .SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(t_interface)))
                                      .ToArray();

            if (types.Count() > 0)
            {
                foreach (var type in types)
                {
                    ICLRBindingData obj    = (ICLRBindingData)Activator.CreateInstance(type);
                    var             _types = obj.GetCLRBindingTypes();
                    if (_types != null && _types.Count > 0)
                    {
                        foreach (var _type in _types)
                        {
                            if (!list_types.Contains(_type))
                            {
                                list_types.Add(_type);
                            }
                        }
                    }
                }
            }

            //gen
            BindingCodeGenerator.GenerateBindingCode(list_types, output_path);
        }
        //生成clr绑定
        private static void GenClrBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin)
        {
            if (platform == RuntimePlatform.Lumin)
            {
                platform = Application.platform;
            }

            //用新的分析热更dll调用引用来生成绑定代码
            var dllpath = Application.streamingAssetsPath + "/AssetBundles/" + AssetBundleSettings.GetPlatformForAssetBundles(platform) +
                          "/hotfix.dll";

            ILRuntimeHelper.LoadHotfix(dllpath, false);
            BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain,
                                                     "Assets/" + ILRuntimeScriptSetting.Default.GenClrBindPath.CreateDirIfNotExists());
            AssetDatabase.Refresh();
        }
Пример #17
0
    static void GenerateCLRBindingByAnalysis()
    {
        //用新的分析热更dll调用引用来生成绑定代码
        AppDomain domain = new AppDomain();

        using (FileStream fs = new FileStream("Assets/HotUpdateResources/Dll/Hidden~/HotUpdateScripts.dll", FileMode.Open, FileAccess.Read))
        {
            domain.LoadAssembly(fs);

            //Crossbind Adapter is needed to generate the correct binding code
            InitILRuntime(domain);
            BindingCodeGenerator.GenerateBindingCode(domain, "Assets/Dependencies/ILRuntime/Generated");
        }

        AssetDatabase.Refresh();
    }
    //生成clr绑定
    static void GenCLRBindingByAnalysis()
    {
        //用新的分析热更dll调用引用来生成绑定代码
        ILRuntimeHelper.LoadHotfix(Application.streamingAssetsPath, false);
        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain,
                                                 "Assets/Code/Game/ILRuntime/Binding/Analysis");
        AssetDatabase.Refresh();
        return;

        //暂时先不处理
        //预先绑定所有的
        var assemblies = new List <Assembly>()
        {
            typeof(UnityEngine.UI.Button).Assembly,
        };
        var types = new List <Type>();

        //
        foreach (var assm in assemblies)
        {
            var _ts = assm.GetTypes();
            foreach (var t in _ts)
            {
                if (t.Namespace != null)
                {
                    if (t.FullName.Contains("UnityEngine.Android") ||
                        t.FullName.Contains("UnityEngine.iPhone") ||
                        t.FullName.Contains("UnityEngine.WSA") ||
                        t.FullName.Contains("UnityEngine.iOS") ||
                        t.FullName.Contains("UnityEngine.Windows") ||
                        t.FullName.Contains("JetBrains") ||
                        t.FullName.Contains("Editor"))
                    {
                        continue;
                    }
                }


                types.Add(t);
            }
        }

        types = types.Distinct().ToList();
        //PreBinding
        BindingCodeGenerator.GenerateBindingCode(types, "Assets/Code/Game/ILRuntime/Binding/PreBinding");
        AssetDatabase.Refresh();
    }
Пример #19
0
        public static void GenerateCLRBindingByAnalysis()
        {
            //用新的分析热更dll调用引用来生成绑定代码
            AppDomain domain = new AppDomain();

            using (FileStream fs = new FileStream("Assets/Resources/DLL/Unity.Hotfix.dll.bytes", FileMode.Open, FileAccess.Read))
            {
                byte[] bytes = new byte[fs.ReadByte()];
                fs.Read(bytes, 0, bytes.Length);
                MemoryStream dll = new MemoryStream(RijndaelUtil.RijndaelDecrypt("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", bytes));
                domain.LoadAssembly(dll);
                //Crossbind Adapter is needed to generate the correct binding code
                InitILRuntime(domain);
                BindingCodeGenerator.GenerateBindingCode(domain, "Assets/Scripts/Runtime/Core/Manager/ILRuntime/Generated");
            }
            AssetDatabase.Refresh();
        }
    /// <summary>
    /// 生成预绑定
    /// </summary>
    static public void GenPreCLRBinding()
    {
        preBindingTypes = new List <Type>();
        var types = typeof(Button).Assembly.GetTypes(); //所有UI相关接口预绑定

        foreach (var t in types)
        {
            if (t.IsClass && t.IsPublic && !t.IsEnum)
            {
                //除开被弃用的
                var attrs = t.GetCustomAttributes(typeof(System.ObsoleteAttribute), false);
                if (attrs.Length == 0)
                {
                    preBindingTypes.Add(t);
                }
            }
        }

        BindingCodeGenerator.GenerateBindingCode(preBindingTypes, clrbingdingClassName: "PreCLRBinding",
                                                 outputPath: "Assets/Code/Game/ILRuntime/Binding/PreBinding");
    }
Пример #21
0
    private static void GenerateCLRBinding()
    {
        List <Type> types = new List <Type>();

        types.Add(typeof(int));
        types.Add(typeof(float));
        types.Add(typeof(long));
        types.Add(typeof(object));
        types.Add(typeof(string));
        types.Add(typeof(Array));
        types.Add(typeof(Vector2));
        types.Add(typeof(Vector3));
        types.Add(typeof(Quaternion));
        types.Add(typeof(GameObject));
        types.Add(typeof(UnityEngine.Object));
        types.Add(typeof(Transform));
        types.Add(typeof(RectTransform));
        types.Add(typeof(Time));
        types.Add(typeof(Debug));
        types.Add(typeof(List <ILTypeInstance>));

        BindingCodeGenerator.GenerateBindingCode(types, "Assets/HTFrameworkILHotfix/RunTime/ILRuntime/Generated");
        AssetDatabase.Refresh();
    }
Пример #22
0
    /// <summary>
    /// 分析dll生成
    /// </summary>
    /// <param name="platform"></param>
    /// <param name="dllpath"></param>
    static private void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
        //默认参数
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }

        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath;
        }

        //路径
        dllpath = dllpath + "/" + BDApplication.GetPlatformPath(platform) + DLLPATH;
        //不参与自动绑定的
        List <Type> excludeTypes = new List <Type>(); //

        excludeTypes.AddRange(manualBindingTypes);
        excludeTypes.AddRange(preBindingTypes);
        //用新的分析热更dll调用引用来生成绑定代码
        var outputPath = "Assets/Code/BDFramework.Game/ILRuntime/Binding/Analysis";
        //游戏工程的Bind
        Action <bool> mainProjectIlrBindAction = null;
        var           type = BDFrameEditorLife.Types.FirstOrDefault((t) => t.FullName == "Game.ILRuntime.GameLogicCLRBinding");

        if (type != null)
        {
            var      method       = type.GetMethod("Bind", BindingFlags.Public | BindingFlags.Static);
            Delegate bindDelegate = Delegate.CreateDelegate(typeof(Action <bool>), null, method);
            mainProjectIlrBindAction = bindDelegate as Action <bool>;
        }
        else
        {
            Debug.LogError("Not find CLRBinding logic!!!");
        }
        //注册
        ILRuntimeHelper.LoadHotfix(dllpath, mainProjectIlrBindAction, false);
        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain, outputPath);
        ILRuntimeHelper.Close();


        /******************移除已经被绑定的部分****************/
        var analysisClrBinding = IPath.Combine(outputPath, "CLRBindings.cs");
        var manualPath         = "Assets/Code/BDFramework.Game/ILRuntime/Binding/Manual";
        var prebindingPath     = "Assets/Code/BDFramework.Game/ILRuntime/Binding/PreBinding";
        //手动绑定的所有文件
        var bindingFs = Directory.GetFiles(manualPath, "*.*").ToList();

        if (Directory.Exists(prebindingPath))
        {
            bindingFs.AddRange(Directory.GetFiles(prebindingPath, "*.*"));
        }

        for (int i = 0; i < bindingFs.Count; i++)
        {
            //删除被手动绑定的文件
            var f = IPath.Combine(outputPath, Path.GetFileName(bindingFs[i]));
            if (f != analysisClrBinding && File.Exists(f))
            {
                File.Delete(f);
            }

            bindingFs[i] = Path.GetFileNameWithoutExtension(bindingFs[i]);
        }

        var analysisContent = File.ReadAllLines(analysisClrBinding).ToList();

        //修改CLRbindding内容
        for (int i = analysisContent.Count - 1; i >= 0; i--)
        {
            var line = analysisContent[i];
            //移除line
            foreach (var mf in bindingFs)
            {
                if (line.Contains(mf + ".Register(app);"))
                {
                    analysisContent.RemoveAt(i);
                    Debug.Log("移除[已经绑定]:" + line);
                    break;
                }
            }
        }

        //写入
        File.WriteAllLines(analysisClrBinding, analysisContent);

        //Manual

        AssetDatabase.Refresh();
    }
    /// <summary>
    /// 分析dll生成
    /// </summary>
    /// <param name="platform"></param>
    /// <param name="dllpath"></param>
    static private void GenCLRBindingByAnalysis(RuntimePlatform platform = RuntimePlatform.Lumin, string dllpath = "")
    {
        if (platform == RuntimePlatform.Lumin)
        {
            platform = Application.platform;
        }

        //默认读StreammingAssets下面path
        if (dllpath == "")
        {
            dllpath = Application.streamingAssetsPath + "/" + BApplication.GetPlatformPath(platform) + DLLPATH;
        }

        //不参与自动绑定的
        List <Type> excludeTypes = new List <Type>(); //

        excludeTypes.AddRange(manualBindingTypes);
        excludeTypes.AddRange(preBindingTypes);

        //用新的分析热更dll调用引用来生成绑定代码
        var outputPath = "Assets/Code/Game/ILRuntime/Binding/Analysis";

        ILRuntimeHelper.LoadHotfix(dllpath, false);
        BindingCodeGenerator.GenerateBindingCode(ILRuntimeHelper.AppDomain, outputPath);
        ILRuntimeHelper.Close();


        /******************移除已经被绑定的部分****************/
        var analysisClrBinding = IPath.Combine(outputPath, "CLRBindings.cs");
        var manualPath         = "Assets/Code/Game/ILRuntime/Binding/Manual";
        var prebindingPath     = "Assets/Code/Game/ILRuntime/Binding/PreBinding";
        //手动绑定的所有文件
        var bindingFs = Directory.GetFiles(manualPath, "*.*").ToList();

        if (Directory.Exists(prebindingPath))
        {
            bindingFs.AddRange(Directory.GetFiles(prebindingPath, "*.*"));
        }

        for (int i = 0; i < bindingFs.Count; i++)
        {
            //删除被手动绑定的文件
            var f = IPath.Combine(outputPath, Path.GetFileName(bindingFs[i]));
            if (f != analysisClrBinding && File.Exists(f))
            {
                File.Delete(f);
            }

            bindingFs[i] = Path.GetFileNameWithoutExtension(bindingFs[i]);
        }

        var analysisContent = File.ReadAllLines(analysisClrBinding).ToList();

        //修改CLRbingding内容
        for (int i = analysisContent.Count - 1; i >= 0; i--)
        {
            var line = analysisContent[i];
            //移除line
            foreach (var mf in bindingFs)
            {
                if (line.Contains(mf + ".Register(app);"))
                {
                    analysisContent.RemoveAt(i);
                    Debug.Log("移除[已经绑定]:" + line);
                    break;
                }
            }
        }

        //写入
        File.WriteAllLines(analysisClrBinding, analysisContent);

        //Manual

        AssetDatabase.Refresh();
    }
        public static void GenCodeByAssemblies()
        {
            var config = XConfig.GetConfig <TinaX.XILRuntime.Internal.XILRTConfig>(XILConst.ConfigPath_Resources);

            if (config == null)
            {
                Debug.LogError($"[{XILConst.ServiceName}] Generate CLRBinding code failed: config file not found.");
                return;
            }
            string output_path = config.EditorCLRBindingCodeOutputPath;

            if (!output_path.StartsWith("Assets/"))
            {
                Debug.LogError($"[{XILConst.ServiceName}]Generate failed: Output folder path is invalid :" + output_path);
                return;
            }

            ILAppDomain     domain   = new ILAppDomain();
            DisposableGroup disGroup = new DisposableGroup();

            foreach (var path in config.EditorLoadAssemblyPaths)
            {
                if (!path.AssemblyPath.IsNullOrEmpty())
                {
                    var fs = new FileStream(path.AssemblyPath, FileMode.Open, FileAccess.Read);
                    disGroup.Register(fs);
                    domain.LoadAssembly(fs);
                }
            }

            List <Type> gen_valueTypes = new List <Type>(s_InternalValueTypes);
            List <Type> gen_delegates  = new List <Type>(s_InternalDelegateTypes);

            Type t_define = typeof(ICLRGenerateDefine);
            var  types    = AppDomain.CurrentDomain.GetAssemblies()
                            .SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(t_define)))
                            .ToArray();

            if (types.Length > 0)
            {
                foreach (var type in types)
                {
                    ICLRGenerateDefine define_obj = (ICLRGenerateDefine)Activator.CreateInstance(type);
                    define_obj.GenerateByAssemblies_InitILRuntime(domain);

                    var _valueTypes = define_obj.GetValueTypeBinders();
                    if (_valueTypes != null && _valueTypes.Count > 0)
                    {
                        foreach (var __valueType in _valueTypes)
                        {
                            if (!gen_valueTypes.Contains(__valueType))
                            {
                                gen_valueTypes.Add(__valueType);
                            }
                        }
                    }

                    var _delegates = define_obj.GetDelegateTypes();
                    if (_delegates != null && _delegates.Count > 0)
                    {
                        foreach (var __delegate in _delegates)
                        {
                            if (!gen_delegates.Contains(__delegate))
                            {
                                gen_delegates.Add(__delegate);
                            }
                        }
                    }
                }
            }


            Internal_HandleBeforeGenCodeByAssemblies(domain);
            BindingCodeGenerator.GenerateBindingCode(domain, output_path, gen_valueTypes, gen_delegates);
            disGroup.Dispose();
            Debug.Log($"<color=#{TinaX.Internal.XEditorColorDefine.Color_Safe_16}>Generate code finish.</color>");
            AssetDatabase.Refresh();
        }
        public static void GenCodeByTypes()
        {
            var config = XConfig.GetConfig <TinaX.XILRuntime.Internal.XILRTConfig>(XILConst.ConfigPath_Resources);

            if (config == null)
            {
                Debug.LogError($"[{XILConst.ServiceName}] Generate CLRBinding code failed: config file not found.");
                return;
            }
            string output_path = config.EditorCLRBindingCodeOutputPath;

            if (!output_path.StartsWith("Assets/"))
            {
                Debug.LogError($"[{XILConst.ServiceName}]Generate failed: Output folder path is invalid :" + output_path);
                return;
            }

            List <Type>          gen_types           = new List <Type>(s_InternalDefineTypes);
            HashSet <MethodBase> gen_exclude_methods = new HashSet <MethodBase>(s_InternalExcludeMethods);
            HashSet <FieldInfo>  gen_exclude_fields  = new HashSet <FieldInfo>(s_InternalExcludeFields);
            List <Type>          gen_valueTypes      = new List <Type>(s_InternalValueTypes);
            List <Type>          gen_delegates       = new List <Type>(s_InternalDelegateTypes);


            Type t_define = typeof(ICLRGenerateDefine);
            var  types    = AppDomain.CurrentDomain.GetAssemblies()
                            .SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(t_define)))
                            .ToArray();

            if (types.Length > 0)
            {
                foreach (var type in types)
                {
                    ICLRGenerateDefine define_obj = (ICLRGenerateDefine)Activator.CreateInstance(type);
                    var _types = define_obj.GetCLRBindingTypes();
                    if (_types != null && _types.Count > 0)
                    {
                        foreach (var __type in _types)
                        {
                            if (!gen_types.Contains(__type))
                            {
                                gen_types.Add(__type);
                            }
                        }
                    }

                    var _exclude_methods = define_obj.GetCLRBindingExcludeMethods();
                    if (_exclude_methods != null && _exclude_methods.Count > 0)
                    {
                        foreach (var __method in _exclude_methods)
                        {
                            if (!gen_exclude_methods.Contains(__method))
                            {
                                gen_exclude_methods.Add(__method);
                            }
                        }
                    }

                    var _exclude_fields = define_obj.GetCLRBindingExcludeFields();
                    if (_exclude_fields != null && _exclude_fields.Count > 0)
                    {
                        foreach (var __field in _exclude_fields)
                        {
                            if (!gen_exclude_fields.Contains(__field))
                            {
                                gen_exclude_fields.Add(__field);
                            }
                        }
                    }

                    var _valueTypes = define_obj.GetValueTypeBinders();
                    if (_valueTypes != null && _valueTypes.Count > 0)
                    {
                        foreach (var __valueType in _valueTypes)
                        {
                            if (!gen_valueTypes.Contains(__valueType))
                            {
                                gen_valueTypes.Add(__valueType);
                            }
                        }
                    }

                    var _delegates = define_obj.GetDelegateTypes();
                    if (_delegates != null && _delegates.Count > 0)
                    {
                        foreach (var __delegate in _delegates)
                        {
                            if (!gen_delegates.Contains(__delegate))
                            {
                                gen_delegates.Add(__delegate);
                            }
                        }
                    }
                }
            }


            BindingCodeGenerator.GenerateBindingCode(gen_types, output_path, gen_exclude_methods, gen_exclude_fields, gen_valueTypes, gen_delegates);
            Debug.Log($"<color=#{TinaX.Internal.XEditorColorDefine.Color_Safe_16}>Generate code finish.</color>");
            AssetDatabase.Refresh();
        }