| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | |
| | | 4 | | namespace NexusLabs.Needlr.Generators.Models; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Information about a bindable property on an options class (for AOT code generation). |
| | | 8 | | /// </summary> |
| | | 9 | | internal readonly struct OptionsPropertyInfo |
| | | 10 | | { |
| | | 11 | | public OptionsPropertyInfo( |
| | | 12 | | string name, |
| | | 13 | | string typeName, |
| | | 14 | | bool isNullable, |
| | | 15 | | bool hasInitOnlySetter, |
| | | 16 | | bool isEnum = false, |
| | | 17 | | string? enumTypeName = null, |
| | | 18 | | ComplexTypeKind complexTypeKind = ComplexTypeKind.None, |
| | | 19 | | string? elementTypeName = null, |
| | | 20 | | IReadOnlyList<OptionsPropertyInfo>? nestedProperties = null, |
| | | 21 | | IReadOnlyList<DataAnnotationInfo>? dataAnnotations = null) |
| | | 22 | | { |
| | 279 | 23 | | Name = name; |
| | 279 | 24 | | TypeName = typeName; |
| | 279 | 25 | | IsNullable = isNullable; |
| | 279 | 26 | | HasInitOnlySetter = hasInitOnlySetter; |
| | 279 | 27 | | IsEnum = isEnum; |
| | 279 | 28 | | EnumTypeName = enumTypeName; |
| | 279 | 29 | | ComplexTypeKind = complexTypeKind; |
| | 279 | 30 | | ElementTypeName = elementTypeName; |
| | 279 | 31 | | NestedProperties = nestedProperties; |
| | 279 | 32 | | DataAnnotations = dataAnnotations ?? Array.Empty<DataAnnotationInfo>(); |
| | 279 | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary>Property name.</summary> |
| | 341 | 36 | | public string Name { get; } |
| | | 37 | | |
| | | 38 | | /// <summary>Fully qualified type name.</summary> |
| | 147 | 39 | | public string TypeName { get; } |
| | | 40 | | |
| | | 41 | | /// <summary>True if the property type is nullable.</summary> |
| | 20 | 42 | | public bool IsNullable { get; } |
| | | 43 | | |
| | | 44 | | /// <summary>True if the property has an init-only setter.</summary> |
| | 127 | 45 | | public bool HasInitOnlySetter { get; } |
| | | 46 | | |
| | | 47 | | /// <summary>True if the property type is an enum.</summary> |
| | 129 | 48 | | public bool IsEnum { get; } |
| | | 49 | | |
| | | 50 | | /// <summary>The underlying enum type name (for nullable enums, this is the non-nullable type).</summary> |
| | 24 | 51 | | public string? EnumTypeName { get; } |
| | | 52 | | |
| | | 53 | | /// <summary>The kind of complex type (nested object, array, list, dictionary).</summary> |
| | 168 | 54 | | public ComplexTypeKind ComplexTypeKind { get; } |
| | | 55 | | |
| | | 56 | | /// <summary>For collections, the element type. For dictionaries, the value type.</summary> |
| | 14 | 57 | | public string? ElementTypeName { get; } |
| | | 58 | | |
| | | 59 | | /// <summary>For nested objects and collection element types, the bindable properties.</summary> |
| | 36 | 60 | | public IReadOnlyList<OptionsPropertyInfo>? NestedProperties { get; } |
| | | 61 | | |
| | | 62 | | /// <summary>DataAnnotation validation attributes on this property.</summary> |
| | 685 | 63 | | public IReadOnlyList<DataAnnotationInfo> DataAnnotations { get; } |
| | | 64 | | |
| | | 65 | | /// <summary>True if this property has any DataAnnotation validation attributes.</summary> |
| | 663 | 66 | | public bool HasDataAnnotations => DataAnnotations.Count > 0; |
| | | 67 | | } |