<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Compilation;
using System.Web.Hosting;
using Umbraco.Core;

namespace Umbraco.ModelsBuilder.Embedded
{
    internal static class ReferencedAssemblies
    {
        private static readonly Lazy<IEnumerable<string>> LazyLocations;

        static ReferencedAssemblies()
        {
            LazyLocations = new Lazy<IEnumerable<string>>(() => HostingEnvironment.IsHosted
                ? GetAllReferencedAssembliesLocationFromBuildManager()
                : GetAllReferencedAssembliesFromDomain());
        }

        /// <summary>
        /// Gets the assembly locations of all the referenced assemblies, that
        /// are not dynamic, and have a non-null nor empty location.
        /// </summary>
        public static IEnumerable<string> Locations => LazyLocations.Value;

        public static Assembly GetNetStandardAssembly(List<Assembly> assemblies)
        {
            if (assemblies == null)
                assemblies = BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToList();

            // for some reason, netstandard is also missing from BuildManager.ReferencedAssemblies and yet, is part of<commit_msg>Adds correct reference for HostingEnvironment<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Umbraco.Composing;

namespace Umbraco.ModelsBuilder.Embedded
{
    internal static class ReferencedAssemblies
    {
        private static readonly Lazy<IEnumerable<string>> LazyLocations;

        static ReferencedAssemblies()
        {
            LazyLocations = new Lazy<IEnumerable<string>>(() => Current.HostingEnvironment.IsHosted // fixme inject!
                ? GetAllReferencedAssembliesLocationFromBuildManager()
                : GetAllReferencedAssembliesFromDomain());
        }

        /// <summary>
        /// Gets the assembly locations of all the referenced assemblies, that
        /// are not dynamic, and have a non-null nor empty location.
        /// </summary>
        public static IEnumerable<string> Locations => LazyLocations.Value;

        public static Assembly GetNetStandardAssembly(List<Assembly> assemblies)
        {
            if (assemblies == null)
                assemblies = BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToList();

            // for some reason, netstandard is also missing from BuildManager.ReferencedAssemblies and yet, is part of
{'fraction_non_alphanumeric': 0.0832012678288431, 'fraction_numerical': 0.0, 'mean_word_length': 2.939157566302652, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '1789343', 'n_tokens_mistral': 660, 'n_tokens_neox': 625, 'n_words': 169}