<commit_before>﻿namespace Fixie.Execution
{
    using System;
    using System.IO;
    using System.Reflection;
    using Cli;

    public class AssemblyRunner
    {
        const int FatalError = -1;

        public static int Main(string[] arguments)
        {
            try
            {
                var options = CommandLine.Parse<Options>(arguments);
                options.Validate();

                var assemblyFullPath = Assembly.GetEntryAssembly().Location;

                var assemblyDirectory = Path.GetDirectoryName(assemblyFullPath);

                using (var executionProxy = new ExecutionProxy(assemblyDirectory))
                    return executionProxy.RunAssembly(assemblyFullPath, arguments);
            }
            catch (Exception exception)
            {
                using (Foreground.Red)
                    Console.WriteLine($"Fatal Error: {exception}");

                return FatalError;
            }
        }
    }
}<commit_msg>AssemblyRunner reads instructions for what execution path to use when FIXIE_NAMED_PIPE is defined.<commit_after>﻿namespace Fixie.Execution
{
    using System;
    using System.IO;
    using System.IO.Pipes;
    using System.Reflection;
    using Cli;
    using Listeners;

    public class AssemblyRunner
    {
        const int Success = 0;
        const int FatalError = -1;

        public static int Main(string[] arguments)
        {
            try
            {
                var options = CommandLine.Parse<Options>(arguments);
                options.Validate();

                var assemblyFullPath = Assembly.GetEntryAssembly().Location;

                var assemblyDirectory = Path.GetDirectoryName(assemblyFullPath);

                using (var executionProxy = new ExecutionProxy(assemblyDirectory))
                {
                    var pipeName = Environment.GetEnvironmentVariable("FIXIE_NAMED_PIPE");

                    if (pipeName == null)
                        return executionProxy.RunAssembly(assemblyFullPath, arguments);

                    using (var clientPipe = new NamedPipeClientStream(".", pipeName, PipeDirection.InOut))
                    {
                        clientPipe.ReadMode = PipeTransmissionMode.Message;
                        clientPipe.Connect();

                        var command = clientPipe.ReceiveMessage();

                        if (command == "DiscoverMethods")
                        {
                            executionProxy.DiscoverMethods(assemblyFullPath, arguments);
                            return Success;
                        }

                        if (command == "RunMethods")
                        {
                            var runMethods = clientPipe.Receive<RunMethods>();

                            return executionProxy.RunMethods(assemblyFullPath, arguments, runMethods.Methods);
                        }

                        return executionProxy.RunAssembly(assemblyFullPath, arguments);
                    }
                }
            }
            catch (Exception exception)
            {
                using (Foreground.Red)
                    Console.WriteLine($"Fatal Error: {exception}");

                return FatalError;
            }
        }
    }

    public class RunMethods
    {
        public string[] Methods { get; set; }
    }
}
{'fraction_non_alphanumeric': 0.07357759904676794, 'fraction_numerical': 0.0008936550491510277, 'mean_word_length': 1.4510948905109489, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '3296232', 'n_tokens_mistral': 778, 'n_tokens_neox': 715, 'n_words': 169}