StrongCX.SourceGenerators 2.0.6

dotnet add package StrongCX.SourceGenerators --version 2.0.6
                    
NuGet\Install-Package StrongCX.SourceGenerators -Version 2.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StrongCX.SourceGenerators" Version="2.0.6">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StrongCX.SourceGenerators" Version="2.0.6" />
                    
Directory.Packages.props
<PackageReference Include="StrongCX.SourceGenerators">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StrongCX.SourceGenerators --version 2.0.6
                    
#r "nuget: StrongCX.SourceGenerators, 2.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package StrongCX.SourceGenerators@2.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=StrongCX.SourceGenerators&version=2.0.6
                    
Install as a Cake Addin
#tool nuget:?package=StrongCX.SourceGenerators&version=2.0.6
                    
Install as a Cake Tool

StrongCX.SourceGenerators

OrnamentERPNew 的源生成器

  • 最低要求 Visual Studio 2022 >= 17.10
  • 仅支持 SDK样式项目
  1. BackupEntityAttribute 备份实体生成器

BackupEntityAttribute

备份实体特性,用于自动生成要备份的实体类的备份类。

  1. 在实体类上添加 BackupEntityAttribute 特性。
/// <summary>
/// 原始实体
/// </summary>
[Table("Base_Original_Entity")]
[BackupEntity(Suffix = "History", UseInterface = true)]
public partial class OriginalEntity : EntityBase
{
    /// <summary>
    /// Id
    /// </summary>
    [Key]
    [Column(TypeName = "bigint")]
    public long Id { get; set; }

    /// <summary>
    /// 编码
    /// </summary>
    [Column(TypeName = "nvarchar")]
    [MaxLength(64)]
    public string Code { get; set; }

    /// <summary>
    /// 分类Id
    /// </summary>
    [Column(TypeName = "bigint")]
    public long ClassId { get; set; }

}
  1. 生成器将会生成以下实体
/// <summary>
/// 原始实体
/// </summary>
[TableAttribute("Base_Original_Entity_History")]
public partial class OriginalEntityHistory : EntityBase, IHistoryEntityBase<OriginalEntityBackup>
{
    /// <summary>
    /// Id
    /// </summary>
    [Key]
    [Column(TypeName = "bigint")]
    public long Id { get; set; }

    /// <summary>
    /// 编码
    /// </summary>
    [Column(TypeName = "nvarchar")]
    [MaxLength(64)]
    public string Code { get; set; }

    /// <summary>
    /// 分类Id
    /// </summary>
    [Column(TypeName = "bigint")]
    public long ClassId { get; set; }
}

Attribute

在项目中定义需要使用的特性,确保命名空间为 StrongCX.Attributes

#pragma warning disable IDE0130
namespace StrongCX.Attributes
{
    /// <summary>
    /// 标识一个实体类,并为其生成备份实体类。
    /// </summary>
    [System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    public sealed class BackupEntityAttribute : System.Attribute
    {
        /// <summary>
        /// 备份类的后缀名,默认为 "Backup"。
        /// </summary>
        public string Suffix { get; set; } = "Backup";

        /// <summary>
        /// 备份类是否继承自 <see cref="Model.IHistoryEntityBase{T}"/>,默认为 "false"。
        /// </summary>
        public bool UseInterface { get; set; } = false;
    }
}

Interface

在项目中定义需要使用的接口,确保命名空间为 StrongCX.Model

#pragma warning disable IDE0130
namespace StrongCX.Model
{
    /// <summary>
    /// 备份类接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IHistoryEntityBase<T> where T : EntityBase { }
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.6 126 1/21/2026
2.0.6-alpha1 110 1/21/2026
2.0.5 589 7/22/2025
2.0.4 683 7/1/2025 2.0.4 is deprecated because it has critical bugs.

降低 Roslyn 依赖版本,最低支持 Visual Studio 2022 17.10