<commit_before>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;
using System.Reflection;

using Oxide.Core;
using Oxide.Core.Plugins;

namespace Oxide.Plugins
{
    public class CSharpPluginLoader : PluginLoader
    {
        public static List<string> ProjectReferences;
        public List<CSharpPlugin> LoadedPlugins = new List<CSharpPlugin>();

        private CSharpExtension extension;
        private Dictionary<string, CompilablePlugin> plugins = new Dictionary<string, CompilablePlugin>();

        public CSharpPluginLoader(CSharpExtension extension)
        {
            this.extension = extension;

            // Plugins inherit all references from Oxide.Ext.CSharp
            ProjectReferences = Assembly.GetExecutingAssembly().GetReferencedAssemblies().Select(r => r.Name).ToList();
            ProjectReferences.Add("Oxide.Ext.CSharp");

            // Check if compatible compiler is installed
            PluginCompiler.BinaryPath = Environment.GetEnvironmentVariable("systemroot") + @"\Microsoft.NET\Framework64\v3.5\csc.exe";
            if (!File.Exists(PluginCompiler.BinaryPath))
            {
                Interface.GetMod().RootLogger.Write(Core.Logging.LogType.Error, "Cannot compile C# plugins. Unable to find csc.exe! Have you installed .Net v3.5 x64?");
                PluginCompiler.BinaryPath = null;
                return;
            }

            // Delete any previously compiled temporary plugin files
            foreach (var path in Directory.GetFiles(Interface.GetMod().TempDirectory, "*.dll"))
                File.Delete(path);
        }
        
        public override IEnumerable<string> ScanDirectory(string directory)
        {<commit_msg>Fix C# plugins locking server when no csc.exe is found. Fixes #106 - Thanks to @bawNg for the fix.<commit_after>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;
using System.Reflection;

using Oxide.Core;
using Oxide.Core.Plugins;

namespace Oxide.Plugins
{
    public class CSharpPluginLoader : PluginLoader
    {
        public static List<string> ProjectReferences;
        public List<CSharpPlugin> LoadedPlugins = new List<CSharpPlugin>();

        private CSharpExtension extension;
        private Dictionary<string, CompilablePlugin> plugins = new Dictionary<string, CompilablePlugin>();

        public CSharpPluginLoader(CSharpExtension extension)
        {
            this.extension = extension;

            // Plugins inherit all references from Oxide.Ext.CSharp
            ProjectReferences = Assembly.GetExecutingAssembly().GetReferencedAssemblies().Select(r => r.Name).ToList();
            ProjectReferences.Add("Oxide.Ext.CSharp");

            // Check if compatible compiler is installed
            PluginCompiler.BinaryPath = Environment.GetEnvironmentVariable("systemroot") + @"\Microsoft.NET\Framework64\v3.5\csc.exe";
            if (!File.Exists(PluginCompiler.BinaryPath))
            {
                Interface.GetMod().RootLogger.Write(Core.Logging.LogType.Error, "Cannot compile C# plugins. Unable to find csc.exe! Have you installed .NET v3.5 x64?");
                PluginCompiler.BinaryPath = null;
                return;
            }

            // Delete any previously compiled temporary plugin files
            foreach (var path in Directory.GetFiles(Interface.GetMod().TempDirectory, "*.dll"))
                File.Delete(path);
        }
        
        public override IEnumerable<string> ScanDirectory(string directory)
        {
            if (PluginCompiler.BinaryPath == null) yield break;
{'fraction_non_alphanumeric': 0.0925875644854738, 'fraction_numerical': 0.005158837903882704, 'mean_word_length': 2.759183673469388, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '5434931', 'n_tokens_mistral': 987, 'n_tokens_neox': 914, 'n_words': 232}