{"id":37043660,"url":"https://github.com/whuanle/czgl.codeanalysis","last_synced_at":"2026-01-14T05:01:16.211Z","repository":{"id":56323348,"uuid":"289693688","full_name":"whuanle/CZGL.CodeAnalysis","owner":"whuanle","description":"代码分析器、反射分析器、动态代码构建、动态代码运行","archived":false,"fork":false,"pushed_at":"2023-04-23T12:41:34.000Z","size":2842,"stargazers_count":34,"open_issues_count":5,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T23:36:12.226Z","etag":null,"topics":["aop","csharp","hacktoberfest","roslyn"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whuanle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-23T13:40:20.000Z","updated_at":"2025-05-30T06:30:29.000Z","dependencies_parsed_at":"2022-08-15T16:40:32.340Z","dependency_job_id":null,"html_url":"https://github.com/whuanle/CZGL.CodeAnalysis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/whuanle/CZGL.CodeAnalysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whuanle%2FCZGL.CodeAnalysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whuanle%2FCZGL.CodeAnalysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whuanle%2FCZGL.CodeAnalysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whuanle%2FCZGL.CodeAnalysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whuanle","download_url":"https://codeload.github.com/whuanle/CZGL.CodeAnalysis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whuanle%2FCZGL.CodeAnalysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28410079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aop","csharp","hacktoberfest","roslyn"],"created_at":"2026-01-14T05:01:15.365Z","updated_at":"2026-01-14T05:01:16.177Z","avatar_url":"https://github.com/whuanle.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"### [✍CZGL.CodeAnalysis](https://roslyn.whuanle.cn/)\n\n![azure-devops](https://img.shields.io/azure-devops/build/whuanle/CZGL.CodeAnalysis/3)    ![](https://img.shields.io/azure-devops/tests/whuanle/CZGL.CodeAnalysis/3)    [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)\n\n[![CZGL.Roslyn](https://img.shields.io/nuget/v/CZGL.Roslyn)](https://www.nuget.org/packages/CZGL.Roslyn/)   ![Download](https://img.shields.io/nuget/dt/CZGL.Roslyn)\n\n\n\n文档 URL：[https://roslyn.whuanle.cn](https://roslyn.whuanle.cn)\n\nAPI URL：[https://api.roslyn.whuanle.cn](https://api.roslyn.whuanle.cn)\n\n\n\nCZGL.CodeAnalysis 主要包含反射解析库和动态代码生成库两部分。\n\nCZGL.Reflect 是用于反射解析的库，可以轻松帮助你从反射中获取到各种需要的信息。\n\n\n\nCZGL.Roslyn 是基于 Roslyn 技术的 C# 动态代码构建器以及编译器，开发者可以使用此库动态构建 C# 代码，并且通过指定条件编译代码。\n\n* 运行时动态构造代码；\n* 运行时为程序提供新的模块功能，拓展能力；\n* 设计函数平台，以代码片段为单位执行；\n* 语法分析提示，编译错误语法警告，精确到代码行；\n* 完善的代码标准，避免动态代码语法错误；\n* 简洁、简单的 API，完整的 Test 测试；\n* ... ...\n\n\n\n### 动图演示\n\n这里使用 Blazor 测试演示，代码可以在源码的 `examples/BlazorExample` 中找到。\n\n注：如无法加载图片，可以点击 [图片git](docs/.images/Blazor运行CZGL.Roslyn.gif)\n\n![Blazor 运行 CZGL.Roslyn](docs/.images/Blazor运行CZGL.Roslyn.gif)\n\n\n\nBlazor 演示的是以命名空间为单位的编译，你可以通过定制后台，实现只需要代码块即可运行，连函数头都不需要。更多功能等你来挖掘！\n\n\n\n### 丰富的文档与示例\n\nCZGL.Roslyn 拥有丰富的文档说明和 API 接口说明，让你使用起来得心应手！\n\n文档 URL：[https://roslyn.whuanle.cn](https://roslyn.whuanle.cn)\n\nAPI URL：[https://api.roslyn.whuanle.cn](https://api.roslyn.whuanle.cn)\n\n![文档说明](./docs/.images/丰富的文档说明.png)\n\n![API 文档](./docs/.images/APIDoc.png)\n\n\n\n### 版本更新计划\n\n- [ ] **0.1.0 α版(完成)**\n\n  特性：一个具有完整功能的初级版本。\n\n- [x] **0.2.0 β（beta）版**\n\n  特性：消除了严重的错误和缺陷，完成大量的单元测试等，对代码的可靠性有了极大的提升；能够上线 Nuget 提供用户试用；对用户的需求进行收集，改进程序；\n\n- [ ] **0.3.0 γ版**\n\n  特性：该版本已经相当成熟了，根据用户使用 β 版本后的建议和需求进行更新；开始关注性能，进行性能测试已经采取措施对性能进行改进。\n\n\n\n### 可以做什么\n\n最大的特点就是动态代码构造以及动态编译，因此我们可以分为两部分讨论。\n\n#### 动态代码生成\n\n* 数据库表还原实体，自动生成类模型文件；(EFCore 有这功能)\n\n* 公司内部定义工具集，通过确定的模板，一键生成代码！\n\n* 通过已确定的逻辑功能，快速生成代码导出！\n\n* 编写 AOP 框架，实现动态代理；\n\n* 代码语法检查；\n\n* 生成计划代码，后台管理哪部分代码可执行；\n\n* 工作流程序通过代码生成一次性构建完毕，工作流程直接写到程序集中，提高性能！\n\n* 快速从表格等各种数据来源，生成代码；\n\n* 自定义 UI 生成器，通过拖拉控件生成代码；\n\n  ... ...\n\n\n\n#### 动态编译\n\n* 自研云函数平台，用户上传代码即可直接执行；\n\n* 公司后台计划任务，以程序集为单位，自定义计划执行程序集；\n\n* 编写 AOP 框架，动态编译程序集；\n\n* 单文件(.cs)编译，不需要 SDK、IDE！脱离开发环境编译！\n\n  ... ...\n\n### 与 Natasha 的关系\n\nNatsha 是一个非常优秀的动态代码框架，由大帅主导，形成了功能完整、性能强悍，并且兼容 .NET FX 4.6~.NET Core ↑ ，通过了大量性能测试以及高性能代码优化。\n\n可以以强到不得了来形容。仓库地址：[https://github.com/dotnetcore/Natasha](https://github.com/dotnetcore/Natasha)\n\n\n\n### 我可以从这个框架学习到什么\n\nCZGL.Roslyn 尽可能做的轻量，而且代码较为简单，代码里面有很多注释，可以帮助读者很好地理解代码功能。\n\nCZGL.Roslyn 适合写小工具，例如 dotnet-tool、数据库还原实体、为 ML.NET 提供快速代码生成等，适合作为小部件为你的程序提供额外的功能；\n\n框架特点是简单易用，你可以从中学习到大量的反射知识，以及 Roslyn 知识，甚至可能学习到 EMIT(后面我会使用这种技术优化性能)。\n\n例如，如何通过取得特性中的属性值？\n\n```csharp\n[Display(Name = \"_Id\")]\npublic int Id {get;set;}\n```\n\n一个 Type ，如何确定他是类、结构体、委托？\n\n如果你查阅资料会发现，`Type.IsClass` 可以识别出类、委托； \n\n以下代码为什么 JAVA 和 C# 执行结果不同？\n\n```csharp\npublic class A\n{\n    public void Test\n    {\n        Console.WriteLine(\"A\");\n    }\n}\npublic class B:A\n{\n    // 隐藏父类 Test 函数\n    public new void Test\n    {\n        Console.WriteLine(\"B\");\n    }\n}\n\nA a = new B();\na.Test();\n```\n\n\n\n目前 CZGL.Roslyn 处于初版，代码还处于非常简单的状态，逻辑也很简单，因此，如果你有意学习 C# 中的反射、动态代码技术等，想了解源代码在生成后如何通过反射获得信息、源代码会被如何编译等，CZGL.Roslyn 就是你最佳的选择。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhuanle%2Fczgl.codeanalysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhuanle%2Fczgl.codeanalysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhuanle%2Fczgl.codeanalysis/lists"}