Skip to content

Show names of parameters #3389

Closed
Closed
@lobster2012-user

Description

@lobster2012-user

Hi!
Maybe I don’t know something, but to my surprise, in the test window (VS), I could not display the parameter names, in xunit they are displayed. This is solved simply enough to enable it by default. I would like to have such an opportunity at least optionally.

            public override string GetText(MethodInfo method, object[] arglist)
            {
                var sb = new StringBuilder();

                if (arglist != null)
                {
                    sb.Append('(');
                    var parameters = method.GetParameters();
                    for (int i = 0; i < arglist.Length; i++)
                    {
//sample code, nothing more.
                        if (i > 0) sb.Append(", ");
                        var paramName = parameters.Length > i ? parameters[i].Name : "?";
                        sb.Append(paramName);
                        sb.Append(": ");
                        sb.Append(GetDisplayString(arglist[i], Math.Max(1, _maxStringLength - paramName.Length - 3)));
                    }

                    sb.Append(')');
                }

                return sb.ToString();
            }

The result is pleasing.
What do you think about it?
(Above is a sample code for adding default functionality)

изображение

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions