<commit_before>using System.Collections.Generic;
using System.Linq;
using Fody;
using Mono.Cecil;

class TypeCache
{
    Dictionary<string, TypeDefinition> cachedTypes = new Dictionary<string, TypeDefinition>();

    public void Initialise(IEnumerable<AssemblyDefinition> assemblyDefinitions)
    {
        var definitions = assemblyDefinitions.ToList();
        foreach (var assembly in definitions)
        {
            foreach (var type in assembly.MainModule.GetTypes())
            {
                AddIfPublic(type);
            }
        }

        foreach (var assembly in definitions)
        {
            foreach (var exportedType in assembly.MainModule.ExportedTypes)
            {
                if (definitions.Any(x => x.Name.Name == exportedType.Scope.Name))
                {
                    continue;
                }

                var typeDefinition = exportedType.Resolve();
                if (typeDefinition == null)
                {
                    continue;
                }

                AddIfPublic(typeDefinition);
            }
        }
    }

    public virtual TypeDefinition FindType(string typeName)
    {
        if (cachedTypes.TryGetValue(typeName, out var type))
        {
            return type;
        }

        throw new WeavingException($"Could not find '{typeName}'.");
    }

    void AddIfPublic(TypeDefinition type)
    {
        if (!type.IsPublic)
        {
            return;
        }
        if (cachedTypes.ContainsKey(type.FullName))
        {
            return;
        }

        cachedTypes.Add(type.FullName, type);
    }
}<commit_msg>Also findtype without full name<commit_after>using System.Collections.Generic;
using System.Linq;
using Fody;
using Mono.Cecil;

class TypeCache
{
    Dictionary<string, TypeDefinition> cachedTypes = new Dictionary<string, TypeDefinition>();

    public void Initialise(IEnumerable<AssemblyDefinition> assemblyDefinitions)
    {
        var definitions = assemblyDefinitions.ToList();
        foreach (var assembly in definitions)
        {
            foreach (var type in assembly.MainModule.GetTypes())
            {
                AddIfPublic(type);
            }
        }

        foreach (var assembly in definitions)
        {
            foreach (var exportedType in assembly.MainModule.ExportedTypes)
            {
                if (definitions.Any(x => x.Name.Name == exportedType.Scope.Name))
                {
                    continue;
                }

                var typeDefinition = exportedType.Resolve();
                if (typeDefinition == null)
                {
                    continue;
                }

                AddIfPublic(typeDefinition);
            }
        }
    }

    public virtual TypeDefinition FindType(string typeName)
    {
        if (cachedTypes.TryGetValue(typeName, out var type))
        {
            return type;
        }

        if (!typeName.Contains('.'))
        {
            foreach (var typeDefinition in cachedTypes.Values)
            {
                if (typeDefinition.Name == typeName)
                {
                    return typeDefinition;
                }
            }
        }

        throw new WeavingException($"Could not find '{typeName}'.");
    }

    void AddIfPublic(TypeDefinition type)
    {
        if (!type.IsPublic)
        {
            return;
        }
        if (cachedTypes.ContainsKey(type.FullName))
        {
            return;
        }

        cachedTypes.Add(type.FullName, type);
    }
}
{'fraction_non_alphanumeric': 0.08609459076748796, 'fraction_numerical': 0.0, 'mean_word_length': 1.5138790035587188, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '3914974', 'n_tokens_mistral': 902, 'n_tokens_neox': 850, 'n_words': 188}