<commit_before>using System;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

namespace ModestTree.Zenject
{
    // Define this class as a component of a top-level game object of your scene heirarchy
    // Then any children will get injected during resolve stage
    public class CompositionRoot : MonoBehaviour
    {
        DiContainer _container;
        IDependencyRoot _dependencyRoot;

        static Action<DiContainer> _extraBindingLookup;
        static Action<DiContainer> _extraInstallerBindingLookup;

        internal static Action<DiContainer> ExtraBindingsLookup
        {
            set
            {
                Assert.IsNull(_extraBindingLookup);
                _extraBindingLookup = value;
            }
        }

        internal static Action<DiContainer> ExtraInstallerBindingsLookup
        {
            set
            {
                Assert.IsNull(_extraInstallerBindingLookup);
                _extraInstallerBindingLookup = value;
            }
        }

        public DiContainer Container
        {
            get
            {
                return _container;
            }
        }

        void Register()
        {
            var sceneInstallers = (from c in gameObject.GetComponents<MonoBehaviour>() where c.GetType().DerivesFrom<ISceneInstaller>() select ((ISceneInstaller)(object)c));

            if (sceneInstallers.HasMoreThan(1))
            {
                Debug.LogError("Found multiple scene installers when only one was expected while initializing CompositionRoot");
                return;
            }

            if (sceneInstallers.IsEmpty())
            {
                Debug.LogError("Could not find scene installer while initializing CompositionRoot");
                return;
            }

            var installer = sceneInstallers.Single();

            var moduleContainer = new DiContainer();

            installer.InstallModules(moduleContainer);

            if (_extraInstallerBindingLookup != null)
            {
                _extraInstallerBindingLookup(moduleContainer);
                _extraInstallerBindingLookup = null;
            }

            var modules = moduleContainer.ResolveMany<Module>();

            if (modules.IsEmpty())
            {
                Debug.Log("No modules found while initializing CompositionRoot");
                return;
            }

            Debug.Log("Initializing Composition Root with " + modules.Count() + " modules");

            foreach (var module in modules)
            {
                module.Container = _container;
                module.AddBindings();
            }
        }

        void InitContainer()
        {
            _container = new DiContainer();

            // Note: This has to go first
            _container.Bind<CompositionRoot>().To(this);

            if (_extraBindingLookup != null)
            {
                _extraBindingLookup(_container);
                _extraBindingLookup = null;
            }
        }

        void Awake()
        {
            InitContainer();
            Register();
            Resolve();
        }
<commit_msg>Changed to initialize logging system early to catch errors<commit_after>using System;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

namespace ModestTree.Zenject
{
    // Define this class as a component of a top-level game object of your scene heirarchy
    // Then any children will get injected during resolve stage
    public class CompositionRoot : MonoBehaviour
    {
        DiContainer _container;
        IDependencyRoot _dependencyRoot;

        static Action<DiContainer> _extraBindingLookup;
        static Action<DiContainer> _extraInstallerBindingLookup;

        internal static Action<DiContainer> ExtraBindingsLookup
        {
            set
            {
                Assert.IsNull(_extraBindingLookup);
                _extraBindingLookup = value;
            }
        }

        internal static Action<DiContainer> ExtraInstallerBindingsLookup
        {
            set
            {
                Assert.IsNull(_extraInstallerBindingLookup);
                _extraInstallerBindingLookup = value;
            }
        }

        public DiContainer Container
        {
            get
            {
                return _container;
            }
        }

        void Register()
        {
            var sceneInstallers = (from c in gameObject.GetComponents<MonoBehaviour>() where c.GetType().DerivesFrom<ISceneInstaller>() select ((ISceneInstaller)(object)c));

            if (sceneInstallers.HasMoreThan(1))
            {
                Debug.LogError("Found multiple scene installers when only one was expected while initializing CompositionRoot");
                return;
            }

            if (sceneInstallers.IsEmpty())
            {
                Debug.LogError("Could not find scene installer while initializing CompositionRoot");
                return;
            }

            var installer = sceneInstallers.Single();

            var moduleContainer = new DiContainer();

            installer.InstallModules(moduleContainer);

            if (_extraInstallerBindingLookup != null)
            {
                _extraInstallerBindingLookup(moduleContainer);
                _extraInstallerBindingLookup = null;
            }

            var modules = moduleContainer.ResolveMany<Module>();

            if (modules.IsEmpty())
            {
                Debug.Log("No modules found while initializing CompositionRoot");
                return;
            }

            Debug.Log("Initializing Composition Root with " + modules.Count() + " modules");

            foreach (var module in modules)
            {
                module.Container = _container;
                module.AddBindings();
            }
        }

        void InitContainer()
        {
            _container = new DiContainer();

            // Note: This has to go first
            _container.Bind<CompositionRoot>().To(this);

            if (_extraBindingLookup != null)
            {
                _extraBindingLookup(_container);
                _extraBindingLookup = null;
            }
        }

        void Awake()
        {
            // Include this log statement early since our logging system initializes lazily
            // This will ensure we log any errors that occur early
            Log.Info("Zenject Started");

            InitContainer();
            Register();
            Resolve();
        }

{'fraction_non_alphanumeric': 0.07011635027556644, 'fraction_numerical': 0.0003061849357011635, 'mean_word_length': 1.6258038585209003, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '903273', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1446, 'n_words': 373}