中文 | English
你们的反馈是我的动力,文档还有很多不足之处;
当你看完文档之后仍然不知道如何实现你的需求,您可以查看 FAQ 或者在issue中提出你的需求。
基于 [Roslyn](https://github.com/dotnet/roslyn) 的 C# 动态程序集构建库,该库允许开发者在运行时使用 C# 代码构建域 / 程序集 / 类 / 结构体 / 枚举 / 接口 / 方法等,使得程序在运行的时候可以增加新的模块及功能。Natasha 集成了域管理/插件管理,可以实现域隔离,域卸载,热拔插等功能。 该库遵循完整的编译流程,提供完整的错误提示, 可自动添加引用,完善的数据结构构建模板让开发者只专注于程序集脚本的编写,兼容 netstandard2.0, 跨平台,统一、简便的链式 API。 且我们会尽快修复您的问题及回复您的 [issue](https://github.com/dotnetcore/Natasha/issues/new) . [这里有更多的使用文档](https://natasha.dotnetcore.xyz/zh-Hans/docs)
引入包 DotNetCore.Natasha.CSharp.Compiler
编译单元主体
引入包 DotNetCore.Natasha.CSharp.Compiler.Domain
编译域 (netcore3.1+)
NatashaManagement //获取链式构造器 .GetInitializer() //使用引用程序集中的命名空间 .WithMemoryUsing() //使用内存中的元数据 .WithMemoryReference() //注册域构造器 .Preheating<NatashaDomainCreator>();
AssemblyCSharpBuilder assemblyCSharp = new(); assemblyCSharp.ConfigLoadContext(ctx => ctx.AddReferenceAndUsingCode<object>()); assemblyCSharp.Add("public class A{public void Show(){}}"); assemblyCSharp.LogCompilationEvent += (log) => { Console.WriteLine(log.ToString()); }; var newAssembly = assemblyCSharp.GetAssembly();
关闭打赏
感谢老铁们的支持,感激不尽 🙏🙏🙏。
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4