-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFrameFullClass.cs
More file actions
50 lines (46 loc) · 1.5 KB
/
Copy pathFrameFullClass.cs
File metadata and controls
50 lines (46 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace NetStackBeautifier.Core;
/// <summary>
/// A class represnets a full class, including namespace.
/// </summary>
public record FrameFullClass
{
public IEnumerable<string> NameSections { get; init; } = Enumerable.Empty<string>();
public IEnumerable<string> GenericParameterTypes { get; init; } = Enumerable.Empty<string>();
public IEnumerable<string> RawGenericParameterTypes { get; init; } = Enumerable.Empty<string>();
/// <summary>
/// Gets the full class name.
/// </summary>
/// <value></value>
public string? FullClassNameOrDefault =>
NameSections switch
{
null => null,
_ => string.Join('.', NameSections)
};
/// <summary>
/// Gets the last section in the namespace
/// </summary>
/// <returns></returns>
public string? ShortClassNameOrDefault
{
get
{
string? result = NameSections?.LastOrDefault();
if (string.IsNullOrEmpty(result))
{
return null;
}
// Special: d__9, d__?
if (result.StartsWith("d__", StringComparison.Ordinal))
{
string numberPart = result.Substring("d__".Length);
int sectionNum = NameSections.NullAsEmpty().Count();
if (sectionNum > 1)
{
return string.Join('.', NameSections.NullAsEmpty().Skip(sectionNum - 2));
}
}
return result;
}
}
}