<commit_before>﻿using System.Linq;
using System.Reflection;
using AlcoholV.Detouring;
using Verse;

namespace AlcoholV
{
    [StaticConstructorOnStartup]
    public class AcEnhancedCrafting
    {
        private static readonly BindingFlags[] BindingFlagCombos =
        {
            BindingFlags.Instance | BindingFlags.Public, BindingFlags.Static | BindingFlags.Public,
            BindingFlags.Instance | BindingFlags.NonPublic, BindingFlags.Static | BindingFlags.NonPublic
        };


        static AcEnhancedCrafting()
        {
            LongEventHandler.QueueLongEvent(Inject, "Initializing", true, null);
        }

        public static Assembly Assembly => Assembly.GetAssembly(typeof(AcEnhancedCrafting));

        public static string AssemblyName => Assembly.FullName.Split(',').First();

        private static void Inject()
        {
            #region Automatic hookup

            // Loop through all detour attributes and try to hook them up
            foreach (var targetType in Assembly.GetTypes())
                foreach (var bindingFlags in BindingFlagCombos)
                    foreach (var targetMethod in targetType.GetMethods(bindingFlags))
                        foreach (DetourAttribute detour in targetMethod.GetCustomAttributes(typeof(DetourAttribute), true))
                        {
                            var flags = detour.bindingFlags != default(BindingFlags) ? detour.bindingFlags : bindingFlags;
                            var sourceMethod = detour.source.GetMethod(targetMethod.Name, flags);
                            if (sourceMethod == null)
                                Log.Error(string.Format(AssemblyName + " Can't find source method {0} with bindingflags {1}", targetMethod.Name, flags));
                            if (!Detours.TryDetourFromTo(sourceMethod, targetMethod)) Log.Message(AssemblyName + " Failed to get injected properly.");
                        }

            #endregion

            //InjectTab(typeof(ITab_Bills), typeof(Detouring.ITab_Bills));
            Log.Message(AssemblyName + " injected.");
        }

        //    foreach (var def in defs)
        //    defs.RemoveDuplicates();
        //    var defs = DefDatabase<ThingDef>.AllDefs.Where(c => (c.inspectorTabs != null) && c.inspectorTabs.Contains(source)).ToList();
        //{

        //private static void InjectTab(Type source, Type dest)
        //    {
        //        def.inspectorTabs.Remove(source);
        //        def.inspectorTabs.Add(dest);
        //        def.inspectorTabsResolved.Remove(InspectTabManager.GetSharedInstance(source));
        //        def.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(dest));
        //    }
        //}
    }
}<commit_msg>fix : remove Itab injection and resize<commit_after>﻿using System.Linq;
using System.Reflection;
using AlcoholV.Detouring;
using Verse;

namespace AlcoholV
{
    [StaticConstructorOnStartup]
    public class AcEnhancedCrafting
    {
        private static readonly BindingFlags[] BindingFlagCombos =
        {
            BindingFlags.Instance | BindingFlags.Public, BindingFlags.Static | BindingFlags.Public,
            BindingFlags.Instance | BindingFlags.NonPublic, BindingFlags.Static | BindingFlags.NonPublic
        };


        static AcEnhancedCrafting()
        {
            LongEventHandler.QueueLongEvent(Inject, "Initializing", true, null);
        }

        public static Assembly Assembly => Assembly.GetAssembly(typeof(AcEnhancedCrafting));

        public static string AssemblyName => Assembly.FullName.Split(',').First();

        private static void Inject()
        {
            #region Automatic hookup

            // Loop through all detour attributes and try to hook them up
            foreach (var targetType in Assembly.GetTypes())
                foreach (var bindingFlags in BindingFlagCombos)
                    foreach (var targetMethod in targetType.GetMethods(bindingFlags))
                        foreach (DetourAttribute detour in targetMethod.GetCustomAttributes(typeof(DetourAttribute), true))
                        {
                            var flags = detour.bindingFlags != default(BindingFlags) ? detour.bindingFlags : bindingFlags;
                            var sourceMethod = detour.source.GetMethod(targetMethod.Name, flags);
                            if (sourceMethod == null)
                                Log.Error(string.Format(AssemblyName + " Can't find source method {0} with bindingflags {1}", targetMethod.Name, flags));
                            if (!Detours.TryDetourFromTo(sourceMethod, targetMethod)) Log.Message(AssemblyName + " Failed to get injected properly.");
                        }

            #endregion

            Log.Message(AssemblyName + " injected.");
        }
    }
}
{'fraction_non_alphanumeric': 0.08922628951747089, 'fraction_numerical': 0.0008319467554076539, 'mean_word_length': 2.1349413298565842, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4852911', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1156, 'n_words': 266}