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

namespace ShowRenamer.Extensibility
{
    public class PluginLoader
    {
        public static ICollection<IPlugin> LoadPlugins()
        {
            Type pluginParentType = typeof(IPlugin);
            IEnumerable<Type> visiblePlugins = AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Where(p => pluginParentType.IsAssignableFrom(p));
            ICollection<IPlugin> loadedPlugins = new List<IPlugin>();
            foreach(Type pluginType in visiblePlugins)
            {
                try
                {
                    IPlugin pluginInstance = (IPlugin)Activator.CreateInstance(pluginType);
                    loadedPlugins.Add(pluginInstance);
                }
                catch(TargetInvocationException)
                {
                    Console.WriteLine("Failed to instantiate plugin {0} from assembly {1}.", pluginType.Name, pluginType.Assembly.FullName);
                }
                catch(MissingMethodException)
                {
                    Console.WriteLine("Failed to instantiate plugin {0} from assembly {1}; no public constructor.", pluginType.Name, pluginType.Assembly.FullName);
                }
            }
            return loadedPlugins;
        }

        public static IEnumerable<IFileNameProvider> LoadFileNameProviders(ICollection<IPlugin> plugins)
        {<commit_msg>Fix special case for initialising plugins<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ShowRenamer.Extensibility
{
    public class PluginLoader
    {
        public static ICollection<IPlugin> LoadPlugins()
        {
            Type pluginParentType = typeof(IPlugin);
            IEnumerable<Type> visiblePlugins = AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Where(p => pluginParentType.IsAssignableFrom(p));
            ICollection<IPlugin> loadedPlugins = new List<IPlugin>();
            foreach(Type pluginType in visiblePlugins)
            {
                if (pluginType == typeof(IPlugin))
                    continue;
                try
                {
                    IPlugin pluginInstance = (IPlugin)Activator.CreateInstance(pluginType);
                    loadedPlugins.Add(pluginInstance);
                }
                catch(TargetInvocationException)
                {
                    Console.WriteLine("Failed to instantiate plugin {0} from assembly {1}.", pluginType.Name, pluginType.Assembly.FullName);
                }
                catch(MissingMethodException)
                {
                    Console.WriteLine("Failed to instantiate plugin {0} from assembly {1}; no public constructor.", pluginType.Name, pluginType.Assembly.FullName);
                }
            }
            return loadedPlugins;
        }

        public static IEnumerable<IFileNameProvider> LoadFileNameProviders(ICollection<IPlugin> plugins)
        {
{'fraction_non_alphanumeric': 0.0835144365104005, 'fraction_numerical': 0.0024837007140639552, 'mean_word_length': 2.1996027805362464, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4811133', 'n_tokens_mistral': 791, 'n_tokens_neox': 775, 'n_words': 161}