* Update gitignore * Move csproj * Update project references * Update solutions * Update build scripts * Tests used to share editorconfig with projects in src * Fix broken tests. * Stop copying around .editorconfig merged root one with linting * csharp_style_expression_bodied -> suggestion * Move StyleCop rulesets to matching directories and update shared build properties * Remove legacy build files, update NuGet.cofig and solution files * Restore myget source * Clean up .gitignore * Update .gitignore * Move new test classes to tests after merge * Gitignore + nuget config * Move new test Co-authored-by: Ronald Barendse <ronald@barend.se>
47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System;
|
|
using StackExchange.Profiling;
|
|
using StackExchange.Profiling.SqlFormatters;
|
|
using Umbraco.Cms.Core.Logging;
|
|
|
|
namespace Umbraco.Cms.Tests.Common.TestHelpers.Stubs
|
|
{
|
|
public class TestProfiler : IProfiler
|
|
{
|
|
public static void Enable() => s_enabled = true;
|
|
|
|
public static void Disable() => s_enabled = false;
|
|
|
|
private static bool s_enabled;
|
|
|
|
public IDisposable Step(string name) => s_enabled ? MiniProfiler.Current.Step(name) : null;
|
|
|
|
public void Start()
|
|
{
|
|
if (s_enabled == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// See https://miniprofiler.com/dotnet/AspDotNet
|
|
MiniProfiler.Configure(new MiniProfilerOptions
|
|
{
|
|
SqlFormatter = new SqlServerFormatter(),
|
|
StackMaxLength = 5000,
|
|
});
|
|
|
|
MiniProfiler.StartNew();
|
|
}
|
|
|
|
public void Stop(bool discardResults = false)
|
|
{
|
|
if (s_enabled)
|
|
{
|
|
MiniProfiler.Current.Stop(discardResults);
|
|
}
|
|
}
|
|
}
|
|
}
|