• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / FluentCommand / 26594173245

28 May 2026 06:28PM UTC coverage: 55.553% (+0.7%) from 54.902%
26594173245

push

github

pwelter34
Move JSON support, add docs and examples

1358 of 3215 branches covered (42.24%)

Branch coverage included in aggregate %.

103 of 234 new or added lines in 9 files covered. (44.02%)

371 existing lines in 26 files now uncovered.

4389 of 7130 relevant lines covered (61.56%)

312.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/FluentCommand/DataQueryFormatter.cs
1
using System.Data;
2

3
using FluentCommand.Internal;
4

5
namespace FluentCommand;
6

7
/// <summary>
8
/// A class to format an <see cref="IDbCommand"/> for logging
9
/// </summary>
10
public class DataQueryFormatter
11
    : IDataQueryFormatter
12
{
13
    /// <summary>
14
    /// Formats the command for logging.
15
    /// </summary>
16
    /// <param name="command">The command to log.</param>
17
    /// <param name="duration">The execution duration.</param>
18
    /// <param name="exception">The exception thrown when executing the command.</param>
19
    /// <returns>The command formatted as a string</returns>
20
    /// <exception cref="System.ArgumentNullException">command</exception>
21
    public string FormatCommand(IDbCommand command, TimeSpan duration, Exception? exception)
22
    {
23
        ArgumentNullException.ThrowIfNull(command);
×
24

UNCOV
25
        var elapsed = duration.TotalMilliseconds;
×
26
        var commandType = command.CommandType;
×
27
        var commandTimeout = command.CommandTimeout;
×
28
        var resultText = exception == null ? "Executed" : "Error Executing";
×
29

UNCOV
30
        var buffer = StringBuilderCache.Acquire();
×
31

UNCOV
32
        buffer
×
33
            .Append(resultText)
×
34
            .Append(" DbCommand (")
×
35
            .Append(elapsed)
×
36
            .Append("ms) [CommandType='")
×
37
            .Append(commandType)
×
38
            .Append("', CommandTimeout='")
×
39
            .Append(commandTimeout)
×
40
            .Append("']")
×
41
            .AppendLine()
×
42
            .AppendLine(command.CommandText);
×
43

UNCOV
44
        foreach (IDataParameter parameter in command.Parameters)
×
45
        {
UNCOV
46
            int precision = 0;
×
47
            int scale = 0;
×
48
            int size = 0;
×
49

UNCOV
50
            if (parameter is IDbDataParameter dataParameter)
×
51
            {
UNCOV
52
                precision = dataParameter.Precision;
×
53
                scale = dataParameter.Scale;
×
54
                size = dataParameter.Size;
×
55
            }
56

UNCOV
57
            buffer
×
58
                .Append("-- ")
×
59
                .Append(parameter.ParameterName)
×
60
                .Append(": ")
×
61
                .Append(parameter.Direction)
×
62
                .Append(" ")
×
63
                .Append(parameter.DbType)
×
64
                .Append("(Size=")
×
65
                .Append(size)
×
66
                .Append("; Precision=")
×
67
                .Append(precision)
×
68
                .Append("; Scale=")
×
69
                .Append(scale)
×
70
                .Append(") [")
×
71
                .Append(parameter.Value)
×
72
                .Append("]")
×
73
                .AppendLine();
×
74
        }
75

UNCOV
76
        return StringBuilderCache.ToString(buffer);
×
77
    }
78

79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc