<commit_before>using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using Hadouken.Fx;
using Hadouken.Fx.Bootstrapping;
using Hadouken.Fx.Bootstrapping.TinyIoC;
using Hadouken.Fx.Reflection;

namespace Hadouken.Plugins.Isolation
{
    public class Sandbox : MarshalByRefObject
    {
        private IPluginHost _pluginHost;

        public static Sandbox Create(string applicationBase)
        {
            var rand = Path.GetRandomFileName();

            var setup = new AppDomainSetup()
            {
                ApplicationBase = applicationBase,
                ApplicationName = rand,
                ConfigurationFile = "", // DO not set to empty string if we want to use the conf file from this domain
                DisallowBindingRedirects = true,
                DisallowCodeDownload = true,
                DisallowPublisherPolicy = true
            };

            var permissions = new PermissionSet(PermissionState.Unrestricted);

            var domain = AppDomain.CreateDomain(rand, null, setup, permissions);
            return (Sandbox)Activator.CreateInstanceFrom(domain, typeof(Sandbox).Assembly.ManifestModule.FullyQualifiedName, typeof(Sandbox).FullName).Unwrap();
        }

        public void Load(PluginConfiguration configuration)
        {
            var retriever = new AssemblyNameRetriever();
            var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
            var assemblyNames = retriever.GetAssemblyNames(files);

            var assembly = Assembly.LoadFile(assemblyNames.First().CodeBase.Replace("file:///", ""));<commit_msg>Let the sandbox live forever<commit_after>using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using Hadouken.Fx;
using Hadouken.Fx.Bootstrapping;
using Hadouken.Fx.Bootstrapping.TinyIoC;
using Hadouken.Fx.Reflection;

namespace Hadouken.Plugins.Isolation
{
    public class Sandbox : MarshalByRefObject
    {
        private IPluginHost _pluginHost;

        public static Sandbox Create(string applicationBase)
        {
            var rand = Path.GetRandomFileName();

            var setup = new AppDomainSetup()
            {
                ApplicationBase = applicationBase,
                ApplicationName = rand,
                ConfigurationFile = "", // DO not set to empty string if we want to use the conf file from this domain
                DisallowBindingRedirects = true,
                DisallowCodeDownload = true,
                DisallowPublisherPolicy = true
            };

            var permissions = new PermissionSet(PermissionState.Unrestricted);

            var domain = AppDomain.CreateDomain(rand, null, setup, permissions);
            return (Sandbox)Activator.CreateInstanceFrom(domain, typeof(Sandbox).Assembly.ManifestModule.FullyQualifiedName, typeof(Sandbox).FullName).Unwrap();
        }

        public override object InitializeLifetimeService()
        {
            return null;
        }

        public void Load(PluginConfiguration configuration)
        {
            var retriever = new AssemblyNameRetriever();
            var files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
            var assemblyNames = retriever.GetAssemblyNames(files);

            var assembly = Assembly.LoadFile(assemblyNames.First().CodeBase.Replace("file:///", ""));
{'fraction_non_alphanumeric': 0.08166189111747851, 'fraction_numerical': 0.0, 'mean_word_length': 2.636458333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7383249', 'n_tokens_mistral': 896, 'n_tokens_neox': 856, 'n_words': 212}