Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 97c644b

Browse files
committed
Refactor GetXml method for improved readability
1 parent 0db9b5e commit 97c644b

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

tests/BitzArt.XDoc.TestNodes/TestMemberNode.cs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public TestMemberNode(PropertyInfo property, string content)
2121
: this(TestNodeType.Property, GetMemberName(property), content) { }
2222

2323
public TestMemberNode(MethodInfo method, string content)
24-
: this(TestNodeType.Method, GetMemberName(method), content) =>
24+
: this(TestNodeType.Method, GetMemberName(method), content) =>
2525
_parameters = method.GetParameters();
2626

2727
public TestMemberNode(TestNodeType type, string name, string content)
@@ -34,36 +34,25 @@ public TestMemberNode(TestNodeType type, string name, string content)
3434

3535
public string GetXml()
3636
{
37-
var xml = "";
37+
var parameters = "";
3838

3939
if (_type == TestNodeType.Method)
4040
{
41-
var parameters = string.Join(", ", _parameters.Select(Render));
42-
43-
xml = $"""
44-
<member name="{XmlNodeTypeChar}:{_name}({parameters})">
45-
{_content.Offset(4, exceptFirstLine: true)}
46-
</member>
47-
""";
48-
49-
}
50-
else
51-
{
52-
xml = $"""
53-
<member name="{XmlNodeTypeChar}:{_name}">
54-
{_content.Offset(4, exceptFirstLine: true)}
55-
</member>
56-
""";
41+
parameters = $"({string.Join(", ", _parameters.Select(Render))})";
5742
}
5843

59-
return xml;
44+
return $"""
45+
<member name="{XmlNodeTypeChar}:{_name}{parameters}">
46+
{_content.Offset(4, exceptFirstLine: true)}
47+
</member>
48+
""";
6049
}
6150

6251
private string Render(ParameterInfo p)
6352
{
6453
var type = p.ParameterType;
6554
var typeName = type.FullName ?? type.Name;
66-
55+
6756
// Remove the generic parameter count indicators from the type name
6857
// (e.g., List`1 becomes List)
6958
return typeName.Replace("`0", "").Replace("`", "");
@@ -81,4 +70,4 @@ private static string GetMemberName(MemberInfo member)
8170
TestNodeType.Method => 'M',
8271
_ => throw new UnreachableException()
8372
};
84-
}
73+
}

0 commit comments

Comments
 (0)