-
Notifications
You must be signed in to change notification settings - Fork 0
/
PropertyGenerationSpec.cs
44 lines (31 loc) · 1.13 KB
/
PropertyGenerationSpec.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
42
43
44
using Microsoft.CodeAnalysis;
using System.Diagnostics;
namespace Ling.Audit.SourceGeneration;
[DebuggerDisplay("Name={Name}, Type={TypeMetadata}")]
internal class PropertyGenerationSpec
{
public Location Location { get; set; } = null!;
public string ClrName { get; set; } = null!;
public bool IsVirtual { get; set; } = true;
public bool IsValueType { get; set; }
public bool IsNullable { get; set; }
public bool IsUerKeyType { get; set; }
public int Order { get; set; }
public string? Comment { get; set; }
public Type? ImplementingType { get; set; }
/// <summary>
/// Compilable name of the property's declaring type.
/// </summary>
public string DeclaringTypeRef { get; set; } = null!;
public override string ToString()
{
var propertyTypeRef = IsValueType && IsNullable
? $"global::System.Nullable<{DeclaringTypeRef}>"
: (IsValueType ? DeclaringTypeRef : $"{DeclaringTypeRef}?");
return $@"
/// <summary>
/// {Comment}
/// </summary>
public {(IsVirtual ? "virtual " : string.Empty)}{propertyTypeRef} {ClrName} {{ get; set; }}";
}
}