Skip to content

Question about IColumn.GetValue(..) and SummaryStyle #1784

Open
@mawosoft

Description

@mawosoft

I'm confused by this description of IColumn.GetValue():

/// <summary>
/// Value in this column formatted using the default style.
/// </summary>
string GetValue(Summary summary, BenchmarkCase benchmarkCase);
/// <summary>
/// Value in this column formatted using the specified style.
/// </summary>
string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style);

Now my reading would be to implement this as:

public string GetValue(Summary summary, BenchmarkCase benchmarkCase) => GetValue(summary, benchmarkCase, summary.Style);
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => ValueWithStyle(style);

But most actual implementations do it the other way around:

public string GetValue(Summary summary, BenchmarkCase benchmarkCase)
{
    if (someColumn)
    {
        // Some use the maybe user-defined style of the summary or don't need one
        return ValueWithStyle(summary.Style);
    }
    else
    {
        // Others ignore any user-defined style and use the predefined default
        return ValueWithStyle(SummaryStyle.Default);
    }
}
// While this overload in most cases ignores the explicit style parameter
public string GetValue(Summary summary, BenchmarkCase benchmarkCase, SummaryStyle style) => GetValue(summary, benchmarkCase);

So what am I missing here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions