From d17357b4faffe30e522a7fd930ffb31898baca6d Mon Sep 17 00:00:00 2001 From: Turnerj Date: Thu, 25 Feb 2021 16:08:33 +1030 Subject: [PATCH] Moved IncreaseReadability from constructor to property Removes weird ambiguity that still existed with setting the value --- .../SqlFormatters/InlineFormatter.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs b/src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs index 6009f742..4d3b1cae 100644 --- a/src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs +++ b/src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs @@ -11,25 +11,20 @@ public class InlineFormatter : ISqlFormatter { private static readonly Regex CommandSpacing = new Regex(@",([^\s])", RegexOptions.Compiled); private static bool includeTypeInfo; - private static bool increaseReadability; /// - /// Creates a new , optionally including the parameter type info - /// in comments beside the replaced value + /// Modifies the output query to increase readibility by adding spaces around crowded commas. /// - /// Whether to include a comment after the value, indicating the type, e.g. /* @myParam DbType.Int32 */ - public InlineFormatter(bool includeTypeInfo = false) : this(true, includeTypeInfo) { } + public bool IncreaseReadability { get; set; } = true; /// /// Creates a new , optionally including the parameter type info /// in comments beside the replaced value /// - /// Modifies the output query to increase readibility by adding spaces around crowded commas. /// Whether to include a comment after the value, indicating the type, e.g. /* @myParam DbType.Int32 */ - public InlineFormatter(bool increaseReadability, bool includeTypeInfo = false) + public InlineFormatter(bool includeTypeInfo = false) { InlineFormatter.includeTypeInfo = includeTypeInfo; - InlineFormatter.increaseReadability = increaseReadability; } /// @@ -45,7 +40,7 @@ public string FormatSql(string commandText, List parameters) return commandText; } - if (increaseReadability) + if (IncreaseReadability) { commandText = CommandSpacing.Replace(commandText, ", $1"); }