From b4f7cf2cc5d0253c4566cbe012f9b93188b1546a 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 ce0954ca..f86fc183 100644 --- a/src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs +++ b/src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs @@ -12,25 +12,20 @@ public class InlineFormatter : ISqlFormatter private static readonly Regex CommandSpacing = new Regex(@",([^\s])", RegexOptions.Compiled); private static readonly Regex ParamPrefixes = new Regex("[@:?].+", RegexOptions.IgnoreCase | 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; } /// @@ -46,7 +41,7 @@ public string FormatSql(string commandText, List parameters) return commandText; } - if (increaseReadability) + if (IncreaseReadability) { commandText = CommandSpacing.Replace(commandText, ", $1"); }