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
//If you want to convert the main domain to NatashaDomain, please use the initialization method without parameters and save the instance after creation, do not create repeatedly.
#### Before that, I have to say, how a plugin outputs complete dependencies and shields reference interfaces, please refer to [Microsoft documentation](https://learn.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support#simple-plugin-with-no-dependencies)
24
24
25
-
### 插件加载
25
+
### Plugin loading
26
26
27
-
`LoadPlugin`方法允许用户传入插件文件路径,返回程序集。
27
+
The `LoadPlugin`method allows users to pass in the plugin file path and returns the assembly.
Natasha.Domain self-implements the assembly comparison logic, and uses the SetAssemblyLoadBehavior(AssemblyCompareInfomation loadBehavior) method to specify the loading behavior of assembly dependencies. For example, passing in the "AssemblyCompareInfomation.UseHighVersion" enumeration will compare the program assemblies that the plugin depends on with the assemblies that already exist in the shared domain during the plugin loading process. If the assembly names are the same, the higher version of the assembly will be loaded.
就拿第一个 API 来说,如果比对过程中找到的依赖版本有高有低,则选择高版本的依赖,而非加载低版本依赖,在使用过程中记得看注释,有问题要去 Github 提问。
35
+
Natasha.Domain combines the plugin loading method and the assembly comparer to generate 4 API methods: `LoadPluginWithHighDependency` / `LoadPluginWithLowDependency` / `LoadPluginUseDefaultDependency` / `LoadPluginWithAllDependency`. Take the first API as an example, if there are different versions of dependencies found during the comparison process, it will choose the higher version of the dependency instead of loading the lower version. Remember to read the comments and ask questions on Github if there are any issues.
37
36
38
-
### 注意事项
37
+
### Notes
39
38
40
-
ALC 不允许加载引用程序集,因为引用程序集不可执行。
39
+
ALC does not allow loading of reference assemblies because reference assemblies are not executable.
Implementing assemblies include the specific implementation and private fields of logic, with less memory growth during warm-up. However, implementing assemblies have sensitive dependencies and should be used with caution.
1.Introduce the `DotNetCore.Natasha.CSharp.Compiler.Domain` Core version of the compilation domain package.
12
+
2.Prepare for intelligent compilation using the preheating method.
13
+
3.Intelligent Compilation.
14
14
15
-
## 预热案例
15
+
## Preheating Examples
16
16
17
-
### 普通预热
17
+
### Ordinary Preheating
18
18
19
-
1.泛型预热方法将自动创建 编译域创建者 单例。
20
-
2.传入 true 参数以达到禁用运行时程序集的作用,Natasha 将会选择内存程序集预热。
21
-
3.第一个参数指是否从内存程序集中提取 Using Code, 设置为 true 将从实现程序集中提取 Using。
22
-
4.第二个参数指是否从内存程序集中提取 元数据,设置为 true 将从实现程序集中提取 元数据。
19
+
1.The generic preheating method will automatically create a singleton for the compilation domain creator.
20
+
2.Passing the true parameter to disable runtime assemblies, Natasha will choose to preheat memory assemblies.
21
+
3.The first parameter indicates whether to extract 'Using Code' from memory assemblies. Set it to true to extract 'Using' from implementing assemblies.
22
+
4.The second parameter indicates whether to extract 'Metadata' from memory assemblies. Set it to true to extract 'Metadata' from implementing assemblies.
23
23
24
24
```cs
25
-
//注册编译域并预热方法
25
+
//Register the compilation domain and preheat method
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
31
+
The first generation will write the 'Using Code' into the cache file 'Natasha.Namespace.cache', and subsequent restarts will automatically load it from the file.
> Perhaps your environment is too complex, encountering some unexpected problems. Please simplify the code to ensure that the exception can be reproduced, and submit an issue to Natasha.
65
65
66
-
## 智能编译
66
+
## Intelligent Compilation
67
67
68
-
在预热后请参考以下代码
68
+
Please refer to the following code after preheating
69
69
70
70
```cs
71
71
AssemblyCSharpBuilderbuilder=new();
72
72
varmyAssembly=builder
73
73
.UseRandomDomain()
74
-
.UseSmartMode() //启用智能模式
74
+
.UseSmartMode() //Enable smart mode
75
75
.Add("public class A{ }")
76
76
.GetAssembly();
77
77
```
78
78
79
-
智能模式将合并 共享域与当前域的 元数据以及 Using, 并启用语义检查.
80
-
智能模式的 API 逻辑为:
79
+
Smart mode will merge metadata and 'Using' code from shared domain and current domain, and enable semantic checks.
This example uses AssemblyName to determine the assembly name and version. The following code excludes the reference files of the dapper with major version 12;
0 commit comments