Add ToonDescription attributes to core entities and DTOs

Introduced ToonDescription annotations across DTO and entity classes to provide metadata, business rules, and documentation for classes and properties. Updated usings to include AyCode.Core.Serializers.Toons where needed. These changes improve code clarity and support tooling for documentation and code generation.
This commit is contained in:
Loretta 2026-01-15 11:34:06 +01:00
parent 954b99fcbc
commit c0073815ae
15 changed files with 41 additions and 2 deletions

View File

@ -15,6 +15,7 @@ public class CustomerDto : ModelDtoBase<Customer>, ISoftDeletedEntity
public string FirstName { get; set; } public string FirstName { get; set; }
public string LastName { get; set; } public string LastName { get; set; }
[ToonDescription(BusinessRule = "get => $\"{LastName} {FirstName}\"")]
public string FullName => $"{LastName} {FirstName}"; public string FullName => $"{LastName} {FirstName}";
public int RegisteredInStoreId { get; set; } public int RegisteredInStoreId { get; set; }

View File

@ -1,4 +1,5 @@
using AyCode.Core.Extensions; using AyCode.Core.Extensions;
using AyCode.Core.Serializers.Toons;
using AyCode.Core.Helpers; using AyCode.Core.Helpers;
using LinqToDB.Mapping; using LinqToDB.Mapping;
using Mango.Nop.Core.Entities; using Mango.Nop.Core.Entities;
@ -14,6 +15,7 @@ using System.Linq.Expressions;
namespace Mango.Nop.Core.Dtos; namespace Mango.Nop.Core.Dtos;
[ToonDescription("Base DTO for orders with items, customer and status tracking")]
public abstract class MgOrderDto<TOrderItemDto, TProductDto> : MgEntityBase, IModelDtoBase<Order>, IMgOrderDto<TOrderItemDto, TProductDto> where TOrderItemDto : IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto public abstract class MgOrderDto<TOrderItemDto, TProductDto> : MgEntityBase, IModelDtoBase<Order>, IMgOrderDto<TOrderItemDto, TProductDto> where TOrderItemDto : IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto
{ {
public Guid OrderGuid { get; set; } public Guid OrderGuid { get; set; }
@ -40,16 +42,19 @@ public abstract class MgOrderDto<TOrderItemDto, TProductDto> : MgEntityBase, IMo
[Association(ThisKey = nameof(Id), OtherKey = nameof(OrderNote.OrderId), CanBeNull = true)] [Association(ThisKey = nameof(Id), OtherKey = nameof(OrderNote.OrderId), CanBeNull = true)]
public List<OrderNote> OrderNotes { get; set; } public List<OrderNote> OrderNotes { get; set; }
[ToonDescription(Purpose = "Enum wrapper", BusinessRule = "get, set => OrderStatusId")]
public OrderStatus OrderStatus public OrderStatus OrderStatus
{ {
get => (OrderStatus)OrderStatusId; get => (OrderStatus)OrderStatusId;
set => OrderStatusId = (int)value; set => OrderStatusId = (int)value;
} }
[ToonDescription(Purpose = "Enum wrapper", BusinessRule = "get, set => ShippingStatusId")]
public ShippingStatus ShippingStatus public ShippingStatus ShippingStatus
{ {
get => (ShippingStatus)ShippingStatusId; get => (ShippingStatus)ShippingStatusId;
set => ShippingStatusId = (int)value; set => ShippingStatusId = (int)value;
} }
[ToonDescription(Purpose = "Enum wrapper", BusinessRule = "get, set => PaymentStatusId")]
public PaymentStatus PaymentStatus public PaymentStatus PaymentStatus
{ {
get => (PaymentStatus)PaymentStatusId; get => (PaymentStatus)PaymentStatusId;

View File

@ -1,4 +1,5 @@
using AyCode.Core.Extensions; using AyCode.Core.Extensions;
using AyCode.Core.Serializers.Toons;
using AyCode.Core.Helpers; using AyCode.Core.Helpers;
using LinqToDB.Mapping; using LinqToDB.Mapping;
using Mango.Nop.Core.Entities; using Mango.Nop.Core.Entities;
@ -8,6 +9,7 @@ using Nop.Core.Domain.Orders;
namespace Mango.Nop.Core.Dtos; namespace Mango.Nop.Core.Dtos;
[ToonDescription("Base DTO for order items with product association")]
public abstract class MgOrderItemDto<TProductDto> : MgEntityBase, IModelDtoBase<OrderItem>, IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto public abstract class MgOrderItemDto<TProductDto> : MgEntityBase, IModelDtoBase<OrderItem>, IMgOrderItemDto<TProductDto> where TProductDto : IMgProductDto
{ {
public Guid OrderItemGuid { get; set; } public Guid OrderItemGuid { get; set; }
@ -24,6 +26,7 @@ public abstract class MgOrderItemDto<TProductDto> : MgEntityBase, IModelDtoBase<
public string AttributesXml { get; set; } public string AttributesXml { get; set; }
public decimal? ItemWeight { get; set; } public decimal? ItemWeight { get; set; }
[ToonDescription(BusinessRule = "get => ProductDto?.Name ?? 'ProductDto is null!!!'")]
public string ProductName => ProductDto?.Name ?? "ProductDto is null!!!"; public string ProductName => ProductDto?.Name ?? "ProductDto is null!!!";
[Association(ThisKey = nameof(ProductId), OtherKey = nameof(BaseEntity.Id), CanBeNull = true)] [Association(ThisKey = nameof(ProductId), OtherKey = nameof(BaseEntity.Id), CanBeNull = true)]

View File

@ -1,10 +1,12 @@
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Core.Serializers.Toons;
using Mango.Nop.Core.Entities; using Mango.Nop.Core.Entities;
using Mango.Nop.Core.Interfaces; using Mango.Nop.Core.Interfaces;
//using Nop.Core.Domain.Catalog; //using Nop.Core.Domain.Catalog;
namespace Mango.Nop.Core.Dtos; namespace Mango.Nop.Core.Dtos;
[ToonDescription("Base DTO for products with warehouse and pricing")]
public abstract class MgProductDto : MgEntityBase, /*Product,*/ IMgProductDto//IModelDtoBase<Product>//, IDiscountSupported<DiscountProductMapping> public abstract class MgProductDto : MgEntityBase, /*Product,*/ IMgProductDto//IModelDtoBase<Product>//, IDiscountSupported<DiscountProductMapping>
{ {
//public int Id { get; set; } //public int Id { get; set; }

View File

@ -1,4 +1,5 @@
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Core.Serializers.Toons;
using LinqToDB.Mapping; using LinqToDB.Mapping;
using Mango.Nop.Core.Entities; using Mango.Nop.Core.Entities;
using Mango.Nop.Core.Interfaces; using Mango.Nop.Core.Interfaces;
@ -18,6 +19,7 @@ namespace Mango.Nop.Core.Dtos
public TProductDto ProductDto { get; set; } public TProductDto ProductDto { get; set; }
} }
[ToonDescription("Base DTO for stock quantity history with product")]
public abstract class MgStockQuantityHistoryDto<TProductDto> : MgEntityBase, IModelDtoBase<StockQuantityHistory>, public abstract class MgStockQuantityHistoryDto<TProductDto> : MgEntityBase, IModelDtoBase<StockQuantityHistory>,
IMgTStockQuantityHistoryDto<TProductDto> where TProductDto : IMgProductDto IMgTStockQuantityHistoryDto<TProductDto> where TProductDto : IMgProductDto
{ {

View File

@ -1,8 +1,10 @@
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Core.Serializers.Toons;
using Nop.Core; using Nop.Core;
namespace Mango.Nop.Core.Entities; namespace Mango.Nop.Core.Entities;
[ToonDescription("Base entity class with Id property and ToString override")]
public abstract class MgEntityBase : BaseEntity, IEntityInt public abstract class MgEntityBase : BaseEntity, IEntityInt
{ {
public override string ToString() public override string ToString()

View File

@ -1,4 +1,5 @@
using System.ComponentModel.Design; using System.ComponentModel.Design;
using AyCode.Core.Serializers.Toons;
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using LinqToDB.Mapping; using LinqToDB.Mapping;
@ -13,6 +14,7 @@ public interface IMgStockTaking : IEntityInt, ITimeStampInfo
public bool IsReadyForClose(); public bool IsReadyForClose();
} }
[ToonDescription("Base entity for stock taking sessions with items")]
public abstract class MgStockTaking<TStockTakingItem> : MgEntityBase, IMgStockTaking where TStockTakingItem : class, IMgStockTakingItem public abstract class MgStockTaking<TStockTakingItem> : MgEntityBase, IMgStockTaking where TStockTakingItem : class, IMgStockTakingItem
{ {
public DateTime StartDateTime { get; set; } public DateTime StartDateTime { get; set; }

View File

@ -1,4 +1,5 @@
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;
using AyCode.Core.Serializers.Toons;
using AyCode.Interfaces.TimeStampInfo; using AyCode.Interfaces.TimeStampInfo;
using LinqToDB; using LinqToDB;
using LinqToDB.Mapping; using LinqToDB.Mapping;
@ -18,6 +19,7 @@ public interface IMgStockTakingItem : IEntityInt, ITimeStampInfo
public int MeasuredStockQuantity { get; set; } public int MeasuredStockQuantity { get; set; }
} }
[ToonDescription("Base entity for stock taking items with product association")]
public abstract class MgStockTakingItem<TStockTaking, TProduct> : MgEntityBase, IMgStockTakingItem public abstract class MgStockTakingItem<TStockTaking, TProduct> : MgEntityBase, IMgStockTakingItem
where TStockTaking : class, IMgStockTaking where TProduct : class, IMgProductDto where TStockTaking : class, IMgStockTaking where TProduct : class, IMgProductDto
{ {

View File

@ -1,4 +1,6 @@
//namespace Nop.Core.Domain.Common; //namespace Nop.Core.Domain.Common;
using AyCode.Core.Serializers.Toons;
using AyCode.Interfaces.Entities; using AyCode.Interfaces.Entities;

View File

@ -1,4 +1,5 @@
using Nop.Core.Domain.Common; using AyCode.Core.Serializers.Toons;
using Nop.Core.Domain.Common;
using Nop.Core.Domain.Tax; using Nop.Core.Domain.Tax;
namespace Nop.Core.Domain.Customers; namespace Nop.Core.Domain.Customers;
@ -6,6 +7,7 @@ namespace Nop.Core.Domain.Customers;
/// <summary> /// <summary>
/// Represents a customer /// Represents a customer
/// </summary> /// </summary>
[ToonDescription("NopCommerce customer entity")]
public partial class Customer : BaseEntity, ISoftDeletedEntity public partial class Customer : BaseEntity, ISoftDeletedEntity
{ {
public Customer() public Customer()

View File

@ -5,6 +5,7 @@ namespace Nop.Core.Domain.Common;
/// <summary> /// <summary>
/// Represents a generic attribute /// Represents a generic attribute
/// </summary> /// </summary>
[ToonDescription("NopCommerce generic attribute for key-value storage", Purpose = "A flexible key-value store used to extend entities with custom business logic data without changing the database schema")]
public partial class GenericAttribute : BaseEntity public partial class GenericAttribute : BaseEntity
{ {
/// <summary> /// <summary>
@ -27,6 +28,7 @@ public partial class GenericAttribute : BaseEntity
/// <summary> /// <summary>
/// Gets or sets the value /// Gets or sets the value
/// </summary> /// </summary>
[ToonDescription(Purpose = "Raw string representation of the Key's value")]
public string Value { get; set; } public string Value { get; set; }
/// <summary> /// <summary>

View File

@ -1,4 +1,6 @@
using Nop.Core.Domain.Common; using Nop.Core.Domain.Common;
using AyCode.Core.Serializers.Toons;
using Nop.Core.Domain.Payments; using Nop.Core.Domain.Payments;
using Nop.Core.Domain.Shipping; using Nop.Core.Domain.Shipping;
using Nop.Core.Domain.Tax; using Nop.Core.Domain.Tax;
@ -8,6 +10,7 @@ namespace Nop.Core.Domain.Orders;
/// <summary> /// <summary>
/// Represents an order /// Represents an order
/// </summary> /// </summary>
[ToonDescription("NopCommerce order entity with payment and shipping")]
public partial class Order : BaseEntity, ISoftDeletedEntity public partial class Order : BaseEntity, ISoftDeletedEntity
{ {
#region Properties #region Properties
@ -309,6 +312,7 @@ public partial class Order : BaseEntity, ISoftDeletedEntity
/// <summary> /// <summary>
/// Gets or sets the payment status /// Gets or sets the payment status
/// </summary> /// </summary>
[ToonDescription(Purpose = "Enum wrapper", BusinessRule = "get, set => PaymentStatusId")]
public PaymentStatus PaymentStatus public PaymentStatus PaymentStatus
{ {
get => (PaymentStatus)PaymentStatusId; get => (PaymentStatus)PaymentStatusId;
@ -318,6 +322,7 @@ public partial class Order : BaseEntity, ISoftDeletedEntity
/// <summary> /// <summary>
/// Gets or sets the shipping status /// Gets or sets the shipping status
/// </summary> /// </summary>
[ToonDescription(Purpose = "Enum wrapper", BusinessRule = "get, set => ShippingStatusId")]
public ShippingStatus ShippingStatus public ShippingStatus ShippingStatus
{ {
get => (ShippingStatus)ShippingStatusId; get => (ShippingStatus)ShippingStatusId;
@ -327,6 +332,7 @@ public partial class Order : BaseEntity, ISoftDeletedEntity
/// <summary> /// <summary>
/// Gets or sets the customer tax display type /// Gets or sets the customer tax display type
/// </summary> /// </summary>
[ToonDescription(Purpose = "Enum wrapper", BusinessRule = "get, set => CustomerTaxDisplayTypeId")]
public TaxDisplayType CustomerTaxDisplayType public TaxDisplayType CustomerTaxDisplayType
{ {
get => (TaxDisplayType)CustomerTaxDisplayTypeId; get => (TaxDisplayType)CustomerTaxDisplayTypeId;

View File

@ -1,8 +1,11 @@
namespace Nop.Core.Domain.Orders; namespace Nop.Core.Domain.Orders;
using AyCode.Core.Serializers.Toons;
/// <summary> /// <summary>
/// Represents an order item /// Represents an order item
/// </summary> /// </summary>
[ToonDescription("NopCommerce order item entity")]
public partial class OrderItem : BaseEntity public partial class OrderItem : BaseEntity
{ {
/// <summary> /// <summary>

View File

@ -5,6 +5,7 @@ namespace Nop.Core.Domain.Orders;
/// <summary> /// <summary>
/// Represents an order note /// Represents an order note
/// </summary> /// </summary>
[ToonDescription("NopCommerce order note entity")]
public partial class OrderNote : BaseEntity public partial class OrderNote : BaseEntity
{ {
/// <summary> /// <summary>

View File

@ -1,4 +1,6 @@
using AyCode.Interfaces.Entities; using AyCode.Core.Serializers.Toons;
using AyCode.Interfaces.Entities;
using LinqToDB.Mapping;
using Mango.Nop.Core.Interfaces; using Mango.Nop.Core.Interfaces;
namespace Nop.Core.Domain.Catalog; namespace Nop.Core.Domain.Catalog;
@ -17,6 +19,8 @@ public interface IMgStockQuantityHistory
/// <summary> /// <summary>
/// Represents a stock quantity change entry /// Represents a stock quantity change entry
/// </summary> /// </summary>
[Table(Name = nameof(StockQuantityHistory))]
[ToonDescription("NopCommerce stock movement log", Purpose = "Audit trail for physical and logical stock movements")]
public partial class StockQuantityHistory : BaseEntity, IMgStockQuantityHistory public partial class StockQuantityHistory : BaseEntity, IMgStockQuantityHistory
{ {
/// <summary> /// <summary>