You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <summary>/// Pager Interface/// </summary>publicinterfaceIPager{/// <summary>/// current page/// </summary>[DefaultValue(0),Description("start 0 to int.max")][Range(0,int.MaxValue)]int?CurrentPage{get;set;}/// <summary>/// length of page /// </summary>[DefaultValue(10),Description("between 10 an 30")][Range(10,30)]int?PageLen{get;set;}}/// <summary>/// Query Interface/// </summary>publicinterfaceIQuery{/// <summary>/// KeyWord/// </summary>[StringLength(100),Description("Keyword for search")]string?KeyWord{get;set;}}/// <summary>/// Tenant Request/// </summary>publicinterfaceITenantRequest{/// <summary>/// TenantId/// </summary>[Required,Description("Tenant ID"),DefaultValue("default")][FromHeader(Name="tenant-id")]string?TenantId{get;set;}}
2.Inherent unit interfaces and mark [AutoGen] Attribute
//can add multi AutoGen Attribute[AutoGen("QueryRequest","Biwen.AutoClassGen.Models")][AutoGen("Query2Request","Biwen.AutoClassGen.Models")]publicinterfaceIQueryRequest:IPager,IQuery{}/// <summary>/// MyTenantRequest/// </summary>[AutoGen("MyTenantRequest","Biwen.AutoClassGen.Models")]publicinterfaceITenantRealRequest:ITenantRequest{}//partial class for your logicpublicpartialclassQueryRequest{publicstringTestMethod(stringarg1,intarg2){return$"{arg1}{arg2}";}}
3.Enjoy!!! finally auto generated class for you
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.ComponentModel.DataAnnotations;usingSystem.Text;usingSystem.Threading.Tasks;usingBiwen.AutoClassGen.TestConsole.Interfaces;
#pragma warning disable
namespaceBiwen.AutoClassGen.Models{publicpartialclassQueryRequest:IQueryRequest{/// <inheritdoc cref = "IPager.CurrentPage"/>[System.ComponentModel.DefaultValueAttribute(0)][System.ComponentModel.DescriptionAttribute("start 0 to int.max")][System.ComponentModel.DataAnnotations.RangeAttribute(0,2147483647)]publicint?CurrentPage{get;set;}/// <inheritdoc cref = "IPager.PageLen"/>[System.ComponentModel.DefaultValueAttribute(10)][System.ComponentModel.DescriptionAttribute("between 10 an 30")][System.ComponentModel.DataAnnotations.RangeAttribute(10,30)]publicint?PageLen{get;set;}/// <inheritdoc cref = "IQuery.KeyWord"/>[System.ComponentModel.DataAnnotations.StringLengthAttribute(100)][System.ComponentModel.DescriptionAttribute("Keyword for search")]publicstring?KeyWord{get;set;}}publicpartialclassQuery2Request:IQueryRequest{/// <inheritdoc cref = "IPager.CurrentPage"/>[System.ComponentModel.DefaultValueAttribute(0)][System.ComponentModel.DescriptionAttribute("start 0 to int.max")][System.ComponentModel.DataAnnotations.RangeAttribute(0,2147483647)]publicint?CurrentPage{get;set;}/// <inheritdoc cref = "IPager.PageLen"/>[System.ComponentModel.DefaultValueAttribute(10)][System.ComponentModel.DescriptionAttribute("between 10 an 30")][System.ComponentModel.DataAnnotations.RangeAttribute(10,30)]publicint?PageLen{get;set;}/// <inheritdoc cref = "IQuery.KeyWord"/>[System.ComponentModel.DataAnnotations.StringLengthAttribute(100)][System.ComponentModel.DescriptionAttribute("Keyword for search")]publicstring?KeyWord{get;set;}}publicpartialclassMyTenantRequest:ITenantRealRequest{/// <inheritdoc cref = "ITenantRequest.TenantId"/>[System.ComponentModel.DataAnnotations.RequiredAttribute][System.ComponentModel.DescriptionAttribute("Tenant ID")][System.ComponentModel.DefaultValueAttribute("default")][Microsoft.AspNetCore.Mvc.FromHeaderAttribute(Name="tenant-id")]publicstring?TenantId{get;set;}}}
#pragma warning restore
Report Diagnostic Code
GEN001: The interface marked [AutoGen] should be inherent one or more interface
GEN011: Illegal naming
GEN021: It is recommended to use the same namespace name
GEN031: Suggestions to use [AutoGen] attribute to mark the interface