Skip to content

Commit

Permalink
Moved IncreaseReadability from constructor to property
Browse files Browse the repository at this point in the history
Removes weird ambiguity that still existed with setting the value
  • Loading branch information
Turnerj committed Feb 25, 2021
1 parent 9a88c7f commit b4f7cf2
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>
/// Creates a new <see cref="InlineFormatter"/>, 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.
/// </summary>
/// <param name="includeTypeInfo">Whether to include a comment after the value, indicating the type, e.g. <c>/* @myParam DbType.Int32 */</c></param>
public InlineFormatter(bool includeTypeInfo = false) : this(true, includeTypeInfo) { }
public bool IncreaseReadability { get; set; } = true;

/// <summary>
/// Creates a new <see cref="InlineFormatter"/>, optionally including the parameter type info
/// in comments beside the replaced value
/// </summary>
/// <param name="increaseReadability">Modifies the output query to increase readibility by adding spaces around crowded commas.</param>
/// <param name="includeTypeInfo">Whether to include a comment after the value, indicating the type, e.g. <c>/* @myParam DbType.Int32 */</c></param>
public InlineFormatter(bool increaseReadability, bool includeTypeInfo = false)
public InlineFormatter(bool includeTypeInfo = false)
{
InlineFormatter.includeTypeInfo = includeTypeInfo;
InlineFormatter.increaseReadability = increaseReadability;
}

/// <summary>
Expand All @@ -46,7 +41,7 @@ public string FormatSql(string commandText, List<SqlTimingParameter> parameters)
return commandText;
}

if (increaseReadability)
if (IncreaseReadability)
{
commandText = CommandSpacing.Replace(commandText, ", $1");
}
Expand Down

0 comments on commit b4f7cf2

Please sign in to comment.