Skip to content

Commit

Permalink
Refactor "IncreaseReadability" to "SpaceAfterComma"
Browse files Browse the repository at this point in the history
This more precisely covers what the formatter option does.
  • Loading branch information
Turnerj committed Jul 1, 2021
1 parent 202ab85 commit 5a32d33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/MiniProfiler.Shared/SqlFormatters/InlineFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class InlineFormatter : ISqlFormatter
private static bool includeTypeInfo;

/// <summary>
/// Modifies the output query to increase readibility by adding spaces around crowded commas.
/// Modifies the output query by adding spaces after commas.
/// </summary>
public bool IncreaseReadability { get; set; } = true;
public bool SpaceAfterComma { get; set; } = true;

/// <summary>
/// Creates a new <see cref="InlineFormatter"/>, optionally including the parameter type info
Expand All @@ -40,7 +40,7 @@ public string FormatSql(string commandText, List<SqlTimingParameter> parameters)
return commandText;
}

if (IncreaseReadability)
if (SpaceAfterComma)
{
commandText = CommandSpacing.Replace(commandText, ", $1");
}
Expand Down
6 changes: 3 additions & 3 deletions src/MiniProfiler.Shared/SqlFormatters/SqlServerFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class SqlServerFormatter : ISqlFormatter
public bool IncludeParameterValues { get; set; } = true;

/// <summary>
/// Modifies the output query to increase readibility by adding spaces around crowded commas.
/// Modifies the output query by adding spaces after commas.
/// </summary>
public bool IncreaseReadability { get; set; } = true;
public bool SpaceAfterComma { get; set; } = true;

/// <summary>
/// Lookup a function for translating a parameter by parameter type
Expand Down Expand Up @@ -120,7 +120,7 @@ public virtual string FormatSql(string commandText, List<SqlTimingParameter> par
.Append("\n\n");
}

if (IncreaseReadability)
if (SpaceAfterComma)
{
commandText = CommandSpacing.Replace(commandText, ", $1");
}
Expand Down
18 changes: 9 additions & 9 deletions tests/MiniProfiler.Tests/SqlFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void InlineParameterNamesInParameterValues()
{
var formatter = new InlineFormatter()
{
IncreaseReadability = false
SpaceAfterComma = false
};
var parameters = new List<SqlTimingParameter>
{
Expand All @@ -119,11 +119,11 @@ public void InlineParameterValuesDisplayNullForStrings()
}

[Fact]
public void InlineIncreaseReadabilityEnabled()
public void InlineSpaceAfterCommaEnabled()
{
var formatter = new InlineFormatter()
{
IncreaseReadability = true
SpaceAfterComma = true
};
var parameters = new List<SqlTimingParameter>
{
Expand All @@ -136,11 +136,11 @@ public void InlineIncreaseReadabilityEnabled()
}

[Fact]
public void InlineIncreaseReadabilityDisabled()
public void InlineSpaceAfterCommaDisabled()
{
var formatter = new InlineFormatter()
{
IncreaseReadability = false
SpaceAfterComma = false
};
var parameters = new List<SqlTimingParameter>
{
Expand Down Expand Up @@ -264,7 +264,7 @@ public void TableQueryWithTwoParametersDisabled(string at)

[Theory]
[MemberData(nameof(GetParamPrefixes))]
public void TableQueryWithIncreasedReadabilityEnabled(string at)
public void TableQueryWithSpaceAfterCommaEnabled(string at)
{
const string text = "select 1 from dbo.Table where x = @x,y = @y";
var cmd = CreateDbCommand(CommandType.Text, text);
Expand All @@ -273,7 +273,7 @@ public void TableQueryWithIncreasedReadabilityEnabled(string at)

var formatter = new SqlServerFormatter()
{
IncreaseReadability = true
SpaceAfterComma = true
};
var actualOutput = GenerateOutput(formatter, cmd, text);

Expand All @@ -283,7 +283,7 @@ public void TableQueryWithIncreasedReadabilityEnabled(string at)

[Theory]
[MemberData(nameof(GetParamPrefixes))]
public void TableQueryWithIncreasedReadabilityDisabled(string at)
public void TableQueryWithSpaceAfterCommaDisabled(string at)
{
const string text = "select 1 from dbo.Table where x = @x,y = @y";
var cmd = CreateDbCommand(CommandType.Text, text);
Expand All @@ -292,7 +292,7 @@ public void TableQueryWithIncreasedReadabilityDisabled(string at)

var formatter = new SqlServerFormatter()
{
IncreaseReadability = false
SpaceAfterComma = false
};
var actualOutput = GenerateOutput(formatter, cmd, text);

Expand Down

0 comments on commit 5a32d33

Please sign in to comment.