<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Interpreter.Vm
{
    public class LibraryRegistry
    {
        public void LoadAssembly(string name, string version, string startupFunction)
        {
            // TODO: load a DLL once they are split out.

            TranslationHelper.runAssemblyStartupFunction(name, startupFunction);
        }

        public LibraryRegistry(Dictionary<string, string> libraryVersions)
        {
            foreach (string libraryName in libraryVersions.Keys.OrderBy(n => n))
            {
                string libraryVersion = libraryVersions[libraryName];
                string crayonHome = System.Environment.GetEnvironmentVariable("CRAYON_HOME");
                string dllFile = System.IO.Path.Combine(crayonHome, "vm", libraryName + ".dll");
                System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllFile);

                // TODO: compare assembly reported version against required version.
<commit_msg>Skip assembly loading for libraries in C# exported projects if the library doesn't have one.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Interpreter.Vm
{
    public class LibraryRegistry
    {
        public void LoadAssembly(string name, string version, string startupFunction)
        {
            // TODO: load a DLL once they are split out.

            TranslationHelper.runAssemblyStartupFunction(name, startupFunction);
        }

        public LibraryRegistry(Dictionary<string, string> libraryVersions)
        {
            foreach (string libraryName in libraryVersions.Keys.OrderBy(n => n))
            {
                string libraryVersion = libraryVersions[libraryName];
                string crayonHome = System.Environment.GetEnvironmentVariable("CRAYON_HOME");
                string dllFile = System.IO.Path.Combine(crayonHome, "vm", libraryName + ".dll");

                if (!System.IO.File.Exists(dllFile)) continue;

                System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom(dllFile);

                // TODO: compare assembly reported version against required version.

{'fraction_non_alphanumeric': 0.08076225045372051, 'fraction_numerical': 0.0, 'mean_word_length': 2.6627906976744184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '416747', 'n_tokens_mistral': 548, 'n_tokens_neox': 521, 'n_words': 143}