<commit_before>using System;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Routing;
using StackExchange.Profiling;
using Umbraco.Core.Configuration;

namespace Umbraco.Web.Profiling
{
    /// <summary>
    /// This is a custom MiniProfiler WebRequestProfilerProvider (which is generally the default) that allows
    /// us to profile items during app startup - before an HttpRequest is created
    /// </summary>
    /// <remarks>
    /// Once the boot phase is changed to StartupPhase.Request then the base class (default) provider will handle all
    /// profiling data and this sub class no longer performs any logic.
    /// </remarks>
    internal class WebProfilerProvider : WebRequestProfilerProvider
    {
        private readonly ReaderWriterLockSlim _locker = new ReaderWriterLockSlim();
        private MiniProfiler _startupProfiler;
        private int _first;
        private volatile BootPhase _bootPhase;

        public WebProfilerProvider()
        {
            // booting...
            _bootPhase = BootPhase.Boot;

            // Remove Mini Profiler routes when not in debug mode
            if (GlobalSettings.DebugMode == false)
            {
                var prefix = MiniProfiler.Settings.RouteBasePath.Replace("~/", string.Empty);

                using (RouteTable.Routes.GetWriteLock())
                {
                    var routes = RouteTable.Routes.Where(x => x is Route r && r.Url.StartsWith(prefix)).ToList();
                    foreach(var r in routes)
                        RouteTable.Routes.Remove(r);
                }
            }
        }

        /// <summary>
        /// Indicates the boot phase.
        /// </summary><commit_msg>strangely i need the fully qualified name here else i get an error, otherwise works great.<commit_after>using System;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Routing;
using StackExchange.Profiling;
using Umbraco.Core.Configuration;

namespace Umbraco.Web.Profiling
{
    /// <summary>
    /// This is a custom MiniProfiler WebRequestProfilerProvider (which is generally the default) that allows
    /// us to profile items during app startup - before an HttpRequest is created
    /// </summary>
    /// <remarks>
    /// Once the boot phase is changed to StartupPhase.Request then the base class (default) provider will handle all
    /// profiling data and this sub class no longer performs any logic.
    /// </remarks>
    internal class WebProfilerProvider : WebRequestProfilerProvider
    {
        private readonly ReaderWriterLockSlim _locker = new ReaderWriterLockSlim();
        private MiniProfiler _startupProfiler;
        private int _first;
        private volatile BootPhase _bootPhase;

        public WebProfilerProvider()
        {
            // booting...
            _bootPhase = BootPhase.Boot;

            // Remove Mini Profiler routes when not in debug mode
            if (GlobalSettings.DebugMode == false)
            {
                //NOTE: Keep the global fully qualified name, for some reason without it I was getting null refs
                var prefix = global::StackExchange.Profiling.MiniProfiler.Settings.RouteBasePath.Replace("~/", string.Empty);

                using (RouteTable.Routes.GetWriteLock())
                {
                    var routes = RouteTable.Routes.Where(x => x is Route r && r.Url.StartsWith(prefix)).ToList();
                    foreach(var r in routes)
                        RouteTable.Routes.Remove(r);
                }
            }
        }

        /// <summary>
        /// Indicates the boot phase.
        /// </summary>
{'fraction_non_alphanumeric': 0.08583925642427556, 'fraction_numerical': 0.0, 'mean_word_length': 2.1061120543293717, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '4662574', 'n_tokens_mistral': 928, 'n_tokens_neox': 917, 'n_words': 301}