mccj - AutoModeCodeGenerator.Analyzers 1.0.0.1-beta-5
Package Description
PM> Install-Package AutoModeCodeGenerator.Analyzers -Version 1.0.0.1-beta-5 -Source https://www.myget.org/F/mccj/api/v3/index.json
> nuget.exe install AutoModeCodeGenerator.Analyzers -Version 1.0.0.1-beta-5 -Source https://www.myget.org/F/mccj/api/v3/index.json
> dotnet add package AutoModeCodeGenerator.Analyzers --version 1.0.0.1-beta-5 --source https://www.myget.org/F/mccj/api/v3/index.json
<PackageReference Include="AutoModeCodeGenerator.Analyzers" Version="1.0.0.1-beta-5" />
Copy to clipboard
source https://www.myget.org/F/mccj/api/v3/index.json
nuget AutoModeCodeGenerator.Analyzers ~> 1.0.0.1-beta-5
Copy to clipboard
> choco install AutoModeCodeGenerator.Analyzers --version 1.0.0.1-beta-5 --source https://www.myget.org/F/mccj/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "mccj" -SourceLocation "https://www.myget.org/F/mccj/api/v2"
Install-Module -Name "AutoModeCodeGenerator.Analyzers" -RequiredVersion "1.0.0.1-beta-5" -Repository "mccj" -AllowPreRelease
Copy to clipboard
AutoModeCodeGenerator
基于 Roslyn 的 C# 增量源生成器:在接口/类上标注特性,编译期生成 SqlSugar / Admin.NET 风格的 Entity / Dto / Create / Update / Detail / Search 等多产物类型(只生成数据形状,不生成 Service / Controller)。
当前版本:1.0.1.0
为何用: 一份接口规格驱动六套 CRUD 类型,按 mode 投影字段,mixin 复用横切;用预设 / Relation / Morph 消灭六模式与外键样板。亦支持 .entity.json 声明式生成。消费架构与 Agent 硬规则见 docs/AI_CONSUMER_GUIDE.md(§0)。
功能概览
相对 nuget.org 1.0.0.17,自 1.0.1.0 起一并提供:
| 能力 | 说明 |
|---|---|
[AutoCodeCrudModes] |
一行展开 CRUD 六模式;OmitModes 支持 Entity-only |
[AutoCodeRelation] |
外键 → Id / Detail / Search / Navigate |
[AutoCodeMorph] |
文件 / 枚举双轨 / Search 区间 / CSV↔数组 |
[AutoCodeColumn] / [AutoCodeIndex] |
列长 / BigString / SugarIndex |
ModeFlags / InheritDto |
压缩 Ids;免拼 InheritStr |
InjectMarkerMembers |
自动投影 InterfaceTypes 未声明成员(如 CreateTime) |
| Detail↔Dto 去重 | 继承同类型时避免 CS0108 |
| 诊断 Mccj001–014 | 含 Mccj012 CodeFix「改用 AutoCodeCrudModes」 |
SearchRangeType / Morph RangeType |
区间开泛型 typeof(...)(亦可用字符串模板) |
| Obsolete 软弃用 | ClassModes / *Str / CustomAttribute → 新 API(行为保留) |
双主入口: 特性(CRUD 预设等)与 .entity.json 并列;默认 ClassStyle Poco。ClassStyle.Record / Inpc 为样式选项。
文档导航
| 文档 | 对象 | 内容 |
|---|---|---|
| Analyzers/README.md | 消费方 | 主文档:安装、CRUD、Morph、Column/Index、诊断、MSBuild |
| docs/AI_CONSUMER_GUIDE.md | AI / Agent | 目的/架构/优势、决策树、标准模板、禁忌、诊断速查 |
| docs/UPGRADE.md | 消费方 | 1.0.0.x → 1.0.1.x 升级与 Obsolete 迁移 |
| docs/CONVENTIONS_TEMPLATE.md | 消费方 | mixin / CreateTime / 列索引可复制模板 |
| docs/ARCHITECTURE.md | 维护者 | 双主入口、管线与分层 |
| docs/ROADMAP.md | 维护者 | 1.0.1 之后建议与非目标 |
| docs/ANALYZER_DX_IMPROVEMENTS.md | 维护者 | DeviceServer 试点驱动的 Analyzers DX 细则 |
| docs/IMPROVEMENT_PLAN.md | 维护者 | 阶段 A–I 完成记录(历史) |
| CHANGELOG.md | 所有人 | 版本变更 |
| PACKAGING.md | 维护者 | NuGet / MyGet 发包 |
| Samples | 本地验证 | CrudCookbook 等 |
更多索引:docs/README.md。
安装
<PackageReference Include="AutoModeCodeGenerator.Analyzers" Version="1.0.1.0" PrivateAssets="all" />
可选约定包(无 SqlSugar 程序集依赖):
<PackageReference Include="AutoModeCodeGenerator.Conventions.SqlSugar" Version="1.0.1.0" />
完整说明见 Analyzers/README.md(随 NuGet 发布)。
本地 ProjectReference
<ProjectReference Include="..\AutoModeCodeGenerator.Analyzers\AutoModeCodeGenerator.Analyzers.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
常用 MSBuild
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)Generated</CompilerGeneratedFilesOutputPath>
<AutoModeGenerateEntityFiles>false</AutoModeGenerateEntityFiles>
<!-- Morph / InjectMarkerMembers 默认区间类型;Device 项目可改为 SearchRangeForStructValue<{0}> -->
<AutoModeSearchRangeTemplate>SearchRangeForStructValue<{0}></AutoModeSearchRangeTemplate>
</PropertyGroup>
最小示例
using AutoCodeGenerator;
[AutoCodeCrudModes(EntityInterfaceTypes = [typeof(IEntityMarker)])]
public interface Product : IHasLongId
{
[AutoCodeProperty(ModeFlags = AutoCodeModeFlags.EntityDtoSearch)]
[AutoCodeColumn(Length = 128)]
string? Name { get; set; }
[AutoCodeRelation(TargetName = nameof(Category), IncludeNavigate = false)]
long Category { get; set; }
}
生成:ProductRecord、ProductDto、ProductCreateInput、ProductUpdateInput、ProductDetailOutput、ProductSearchInput。
项目结构
AutoModeCodeGenerator/
├── README.md / CHANGELOG.md / LICENSE
├── docs/ # 消费方/AI/维护者文档(见 docs/README.md)
└── src/
├── AutoModeCodeGenerator.Analyzers/ # 源生成器 + 诊断/CodeFix(NuGet)
│ ├── Extraction/ / Expansion/ # 管线:见 docs/ARCHITECTURE.md
│ ├── CodeGeneration/ / EntityFiles/ # 共享 Emit / entity.json
│ ├── Diagnostics/ / Templates/ # Mccj* / 嵌入公共 API
├── AutoModeCodeGenerator.Conventions.SqlSugar/
├── AutoModeCodeGenerator.Samples/
└── AutoModeCodeGenerator.Tests/
| 项目 | TFM | 说明 |
|---|---|---|
| Analyzers | netstandard2.0 | 1.0.1.0,PrivateAssets=all 消费 |
| Conventions.SqlSugar | netstandard2.0 | 可选字符串模板 |
| Samples | net8.0 | 本地验证 |
| Tests | net8.0 | GeneratorDriver + Analyzer/CodeFix |
公共 API 命名空间:AutoCodeGenerator。内部:AutoModeCodeGenerator.Internal。
开发与构建
dotnet build src/AutoModeCodeGenerator.slnx
dotnet test src/AutoModeCodeGenerator.Tests/AutoModeCodeGenerator.Tests.csproj
dotnet run --project src/AutoModeCodeGenerator.Samples/Samples.csproj
dotnet pack src/AutoModeCodeGenerator.Analyzers/AutoModeCodeGenerator.Analyzers.csproj -c Release
- 测试覆盖:Poco/Record/Inpc、CRUD/Relation/Morph、Column/Index、Inject、Mccj001–014、CodeFix、nupkg 内容。
- CI:
.github/workflows/ci.yml;发包见 PACKAGING.md。
调试源生成器
在 AutoCodeGenerator.Initialize 开头临时 Debugger.Launch();,编译消费项目时附加;调试完移除。
1.0.1 破坏性变更(相对 1.0.0.17)
ClassStyle.Record→ 真正的record class(init)- Inpc 基类实现
INotifyPropertyChanged - 内部命名空间改为
AutoModeCodeGenerator.Internal
详见 CHANGELOG.md。CRUD 默认 Poco 时升到 1.0.1.x 无破坏。
许可证
Ownersmccj |
AuthorsAutoModeCodeGenerator.Analyzers |
Project URLhttps://github.com/mccj/AutoModeCodeGenerator.git |
LicenseUnknown |
Info712 total downloads |
| 98 downloads for version 1.0.0.1-beta-5 |
| Download (20.67 KB) |
| Found on the current feed only |
Package history
| Version | Size | Last updated | Downloads | Mirrored? | |||
|---|---|---|---|---|---|---|---|
|
|
1.0.1 | 507.29 KB | Mon, 26 Oct 2026 04:24:07 GMT | 1 |
|
||
|
|
1.0.0.17 | 45.07 KB | Sun, 05 Jul 2026 16:05:28 GMT | 7 |
|
||
|
|
1.0.0.16 | 45.07 KB | Sun, 05 Jul 2026 13:49:10 GMT | 7 |
|
||
|
|
1.0.0.15 | 24.53 KB | Tue, 26 Aug 2025 14:45:51 GMT | 63 |
|
||
|
|
1.0.0.14 | 24.39 KB | Fri, 18 Apr 2025 05:45:01 GMT | 84 |
|
||
|
|
1.0.0.13 | 23.41 KB | Tue, 15 Apr 2025 08:48:44 GMT | 76 |
|
||
|
|
1.0.0.9 | 21.48 KB | Wed, 17 Apr 2024 03:18:08 GMT | 84 |
|
||
|
|
1.0.0.8 | 21.47 KB | Wed, 17 Apr 2024 03:07:59 GMT | 85 |
|
||
|
|
1.0.0.1-beta-2 | 20.67 KB | Mon, 18 Sep 2023 17:28:33 GMT | 110 |
|
||
|
|
1.0.0.1-beta-4 | 20.67 KB | Mon, 18 Sep 2023 18:06:12 GMT | 97 |
|
||
|
|
1.0.0.1-beta-5 | 20.67 KB | Mon, 18 Sep 2023 18:10:47 GMT | 98 |
|