<commit_before>﻿using FluentNHibernate.Conventions.AcceptanceCriteria;
using Microsoft.Build.Evaluation;
using System.IO;
using System.Linq;
using System.Reflection;

namespace DatabaseManagement.ProjectHelpers
{
    /// <summary>
    /// Helper to load MS Build Evaulation projects.
    /// </summary>
    internal class ProjectEvalutionHelper
    {
        /// <summary>
        /// Finds and builds project and returns the built assembly.
        /// </summary>
        /// <param name="projectPath"></param>
        /// <returns></returns>
        internal Assembly LoadEvalutionProject(string projectPath)
        {
            Logger.Log("Loading project file: " + projectPath, isDebugMessage: true);
            var project = GetEvalutionProject(projectPath);
            Logger.Log("Building project file", isDebugMessage: true);
            project.Build(new Logger());

            var outputPath = project.GetPropertyValue("OutputPath");
            Logger.Log("Project file outputpath: " + (!string.IsNullOrWhiteSpace(outputPath) ? outputPath : "output path was EMPTY -- this might cause an error"), isDebugMessage: true);
            
            var name = project.GetPropertyValue("AssemblyName");
            Logger.Log("Project file assembly name: " + name, isDebugMessage: true);
            
            var fullPath = Path.Combine(project.DirectoryPath, outputPath);
            var path = Path.Combine(fullPath, name + ".dll");
            Logger.Log("Loading DLL: " + path, isDebugMessage: true); 
            
            var projectAssembly = Assembly.LoadFile(path);

            Logger.Log("", isDebugMessage: true); 
            return projectAssembly;
        }

        /// <summary>
        /// Finds the root namespace for the given project.
        /// </summary>
        /// <param name="projectPath"></param>
        /// <returns></returns>
        internal string RootNameSpace(string projectPath)
        {
            var project = GetEvalutionProject(projectPath);
            var projectNamespace = project.GetPropertyValue("RootNamespace");<commit_msg>Defaulted project build configuration to debug<commit_after>﻿using FluentNHibernate.Conventions.AcceptanceCriteria;
using Microsoft.Build.Evaluation;
using System.IO;
using System.Linq;
using System.Reflection;

namespace DatabaseManagement.ProjectHelpers
{
    /// <summary>
    /// Helper to load MS Build Evaulation projects.
    /// </summary>
    internal class ProjectEvalutionHelper
    {
        /// <summary>
        /// Finds and builds project and returns the built assembly.
        /// </summary>
        /// <param name="projectPath"></param>
        /// <returns></returns>
        internal Assembly LoadEvalutionProject(string projectPath)
        {
            Logger.Log("Loading project file: " + projectPath, isDebugMessage: true);
            var project = GetEvalutionProject(projectPath);
            Logger.Log("Building project file", isDebugMessage: true);
            project.SetGlobalProperty("Configuration", "Debug");
            project.Build(new Logger());

            var outputPath = project.GetPropertyValue("OutputPath");
            Logger.Log("Project file outputpath: " + (!string.IsNullOrWhiteSpace(outputPath) ? outputPath : "output path was EMPTY -- this might cause an error"), isDebugMessage: true);
            
            var name = project.GetPropertyValue("AssemblyName");
            Logger.Log("Project file assembly name: " + name, isDebugMessage: true);
            
            var fullPath = Path.Combine(project.DirectoryPath, outputPath);
            var path = Path.Combine(fullPath, name + ".dll");
            Logger.Log("Loading DLL: " + path, isDebugMessage: true); 
            
            var projectAssembly = Assembly.LoadFile(path);

            Logger.Log("", isDebugMessage: true); 
            return projectAssembly;
        }

        /// <summary>
        /// Finds the root namespace for the given project.
        /// </summary>
        /// <param name="projectPath"></param>
        /// <returns></returns>
        internal string RootNameSpace(string projectPath)
        {
            var project = GetEvalutionProject(projectPath);
            var projectNamespace = project.GetPropertyValue("RootNamespace");
{'fraction_non_alphanumeric': 0.11186361513311537, 'fraction_numerical': 0.0, 'mean_word_length': 2.391132224861441, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '4330608', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1021, 'n_words': 270}