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 Jul 1, 2021
1 parent fc762a7 commit d17357b
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 @@ -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;

/// <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 @@ -45,7 +40,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 d17357b

Please sign in to comment.