-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocProperty.cs
41 lines (34 loc) · 1.43 KB
/
DocProperty.cs
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
using Summary.Extensions;
namespace Summary;
/// <summary>
/// A <see cref="DocMember" /> that represents a documented property in the parsed source code.
/// </summary>
public record DocProperty : DocMember
{
/// <summary>
/// The type of the property.
/// </summary>
public required DocType Type { get; init; }
/// <summary>
/// The accessors of the property (e.g., <c>get</c>, <c>set</c>, <c>init</c>).
/// </summary>
public required DocPropertyAccessor[] Accessors { get; init; }
/// <summary>
/// Whether this property was generated by compiler (e.g., it's a property of a record).
/// </summary>
public required bool Generated { get; init; }
// TODO: Consider having a separate `DocEvent` type since events are more specialized properties (@j.light).
/// <summary>
/// Whether this property represents an event.
/// </summary>
public required bool Event { get; init; }
/// <summary>
/// The declaration of property accessors as they declared in the C# source code.
/// </summary>
public string AccessorsDeclaration => Accessors
.Select(x => $"{AccessDeclaration(x).ToLower().Space() ?? ""}{x.Kind.ToString().ToLower()};")
.Separated(with: " ")
.Surround("{ ", " }");
private string AccessDeclaration(DocPropertyAccessor x) =>
x.Access is null || x.Access == Access ? "" : x.Access.Value.ToString();
}