Skip to content

Commit f99864a

Browse files
committed
2 parents a6e573d + 8707aa0 commit f99864a

39 files changed

+1980
-1130
lines changed

.github/workflows/azure-static-web-apps-delightful-sky-087ceb100.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
name: Build and Deploy Job
1717
steps:
18-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
18+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
1919
with:
2020
submodules: true
2121
- uses: actions/setup-node@v4

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Build docusaurus Site
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
17+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
1818
- uses: actions/setup-node@v4
1919
with:
2020
node-version: "18"

.github/workflows/compress-images.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
github.event.pull_request.head.repo.full_name == github.repository)
3636
steps:
3737
- name: Checkout Branch
38-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
38+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
3939
- name: Compress Images
4040
id: calibre
4141
uses: calibreapp/image-actions@main
@@ -48,7 +48,7 @@ jobs:
4848
if: |
4949
github.event_name != 'pull_request' &&
5050
steps.calibre.outputs.markdown != ''
51-
uses: peter-evans/create-pull-request@v5
51+
uses: peter-evans/create-pull-request@v6
5252
with:
5353
token: ${{ secrets.GITHUB_TOKEN }}
5454
title: Auto Compress Images

.github/workflows/crowdin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212

1313
steps:
1414
- name: Checkout
15-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
15+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
1616

1717
- name: crowdin action
18-
uses: crowdin/github-action@v1.16.0
18+
uses: crowdin/github-action@v2.0.0
1919
with:
2020
upload_sources: true
2121
upload_translations: false

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
2121

2222
# Drafts your next Release notes as Pull Requests are merged into "master"
23-
- uses: release-drafter/release-drafter@v5
23+
- uses: release-drafter/release-drafter@v6
2424
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
2525
# with:
2626
# config-name: my-config.yml
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
---
2-
title: 1.域的概念与使用
2+
title: 1. Concept and Usage of Domain
33
---
44

55
## Getting started
66

7-
引用包 `DotNetCore.Natasha.Domain` `DotNetCore.Natasha.CSharp.Compiler.Domain`;
7+
Refer to the package `DotNetCore.Natasha.Domain` or `DotNetCore.Natasha.CSharp.Compiler.Domain`
88

9-
`DotNetCore.Natasha.Domain` 为 域 的实现包。
10-
`DotNetCore.Natasha.CSharp.Compiler.Domain` Natasha 编译单元与 域的粘合包。
9+
`DotNetCore.Natasha.Domain` is the implementation package for Domain.
10+
`DotNetCore.Natasha.CSharp.Compiler.Domain` is the package that binds the Natasha compilation unit and Domain together.
1111

12-
## 创建域
12+
## Creating a Domain
1313

1414
```cs
15-
//如果你想将主域转化为 NatashaDomain,请使用不带参数的初始化方法,并创建后将实例保存起来,不要重复创建。
15+
//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.
1616
var domain = new NatashaDomain();
17-
//如果你想创建非主域
17+
//If you want to create a non-main domain
1818
var domain = new NatashaDomain(key);
1919
```
2020

21-
## 加载插件
21+
## Loading plugins
2222

23-
#### 在这之前我不得不说,一个插件如何输出完整依赖,如何屏蔽引用接口,请参照[微软文档](https://learn.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support#simple-plugin-with-no-dependencies)
23+
#### 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)
2424

25-
### 插件加载
25+
### Plugin loading
2626

27-
`LoadPlugin` 方法允许用户传入插件文件路径,返回程序集。
27+
The `LoadPlugin` method allows users to pass in the plugin file path and returns the assembly.
2828

29-
### 程序集比较器
29+
### Assembly comparer
3030

31-
Natasha.Domain 自实现了程序集比较逻辑,通过 SetAssemblyLoadBehavior(AssemblyCompareInfomation loadBehavior) 方法来指定程序集依赖加载行为,例如 "AssemblyCompareInfomation.UseHighVersion" 枚举传入,将导致插件加载过程中,插件所依赖的程序集与共享域已存在的程序集进行比较,如果程序集名相同,则加载版本较高的程序集。
31+
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.
3232

33-
### 封装 API
33+
### Encapsulated API
3434

35-
Natasha.Domain 合并了插件加载方法和程序集比较器产生了 4 个 API 方法,`LoadPluginWithHighDependency` / `LoadPluginWithLowDependency` / `LoadPluginUseDefaultDependency` / `LoadPluginWithAllDependency`.
36-
就拿第一个 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.
3736

38-
### 注意事项
37+
### Notes
3938

40-
ALC 不允许加载引用程序集,因为引用程序集不可执行。
39+
ALC does not allow loading of reference assemblies because reference assemblies are not executable.
Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
---
2-
title: 2.1 智能编译模式 - 实现程序集
2+
title: 2.1 Smart Compilation Mode - Implementing Assemblies
33
---
44

5-
## 为何使用实现程序集
5+
## Why Use Implementing Assemblies
66

7-
实现程序集包括逻辑的具体实现和私有字段,预热内存涨幅较少,但实现程序集具有敏感的依赖关系,需要小心使用。
7+
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.
88

99
## Prerequisite
1010

11-
1. 引入 `DotNetCore.Natasha.CSharp.Compiler.Domain` Core 版本的编译域包。
12-
2. 使用预热方法为智能编译做准备。
13-
3. 智能编译。
11+
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.
1414

15-
## 预热案例
15+
## Preheating Examples
1616

17-
### 普通预热
17+
### Ordinary Preheating
1818

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.
2323

2424
```cs
25-
//注册编译域并预热方法
25+
//Register the compilation domain and preheat method
2626
NatashaManagement.Preheating<NatashaDomainCreator>(true, true);
2727
```
2828

29-
### Using缓存预热
29+
### Using Cache Preheating
3030

31-
第一次生成将 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.
3232

3333
```cs
34-
//注册编译域并预热方法
35-
NatashaManagement.Preheating<NatashaDomainCreator>(true, truetrue);
34+
//Register the compilation domain and preheat method
35+
NatashaManagement.Preheating<NatashaDomainCreator>(true, true, true);
3636
```
3737

38-
### 分开预热
38+
### Separate Preheating
3939

4040
```cs
41-
//注册编译域
41+
//Register the compilation domain
4242
NatashaManagement.RegistDomainCreator<NatashaDomainCreator>();
43-
//预热方法
43+
//Preheat method
4444
NatashaManagement.Preheating(true, true);
4545
```
4646

47-
### 过滤预热
47+
### Filter Preheating
4848

4949
```cs
50-
//如果存在 Dapper 主版本高于 12 的程序集,则不要将它加入缓存。
51-
//传入排除方法
50+
//Exclude the assembly if there is a Dapper assembly with a major version greater than 12.
51+
//Pass the exclusion method
5252
NatashaManagement.Preheating<NatashaDomainCreator>((asmName, name) => {
5353
if (asmName.Name != null)
5454
{
@@ -58,26 +58,26 @@ NatashaManagement.Preheating<NatashaDomainCreator>((asmName, name) => {
5858
}
5959
}
6060
return false;
61-
},true, truetrue);
61+
}, true, true, true);
6262
```
6363

64-
> 也许您的环境过于复杂,从而遇到一些意外,请您精简代码之后,确保异常能够重现,提交 issue Natasha
64+
> 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.
6565
66-
## 智能编译
66+
## Intelligent Compilation
6767

68-
在预热后请参考以下代码
68+
Please refer to the following code after preheating
6969

7070
```cs
7171
AssemblyCSharpBuilder builder = new();
7272
var myAssembly = builder
7373
.UseRandomDomain()
74-
.UseSmartMode() //启用智能模式
74+
.UseSmartMode() //Enable smart mode
7575
.Add("public class A{ }")
7676
.GetAssembly();
7777
```
7878

79-
智能模式将合并 共享域与当前域的 元数据以及 Using, 并启用语义检查.
80-
智能模式的 API 逻辑为:
79+
Smart mode will merge metadata and 'Using' code from shared domain and current domain, and enable semantic checks.
80+
The API logic for smart mode is as follows:
8181

8282
```cs
8383
.WithCombineReferences(item => item.UseAllReferences())
@@ -86,12 +86,12 @@ var myAssembly = builder
8686
.WithSemanticCheck();
8787
```
8888

89-
可以参考[元数据管理与微调] 对 元数据 的合并行为进行微调。
90-
可以参考[微调Using覆盖] 对 UsingCode 的合并行为进行微调。
89+
You can refer to [Metadata management and fine-tuning] to fine-tune the merging behavior of metadata.
90+
You can refer to [Fine-tuning Using override] to fine-tune the merging behavior of UsingCode.
9191

92-
## 其他案例
92+
## Other cases
9393

94-
#### 批量排除程序集
94+
#### Batch exclude assemblies
9595

9696
```cs
9797
NatashaInitializer.Preheating((asmName, name) => {
@@ -118,29 +118,29 @@ NatashaInitializer.Preheating((asmName, name) => {
118118
name.Contains("ComponentModel")
119119
)
120120
{
121-
//排除
121+
//Exclude
122122
return true;
123123
}
124124
return false;
125125
}
126126
if (name.Contains("Natasha"))
127127
{
128-
//加载
128+
//Load
129129
return false;
130130
}
131131
if (name.Contains("ConsoleApp3"))
132132
{
133-
//加载
133+
//Load
134134
return false;
135135
}
136136
}
137137
return true;
138-
}true, true);
138+
}, true, true);
139139
```
140140

141-
#### 根据版本排除程序集
141+
#### Exclude assemblies based on versions
142142

143-
该示例使用 AssemblyName 进行判断程序集名称及版本, 以下代码排除了 dapper 主版本号为 12 的程序集引用文件;
143+
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;
144144

145145
```cs
146146
NatashaInitializer.Preheating((asmName, name) => {
@@ -155,4 +155,4 @@ NatashaInitializer.Preheating((asmName, name) => {
155155
});
156156
```
157157

158-
> 减少程序集引用文件的加载,可以有效的控制内存涨幅.
158+
> Reducing the loading of assembly reference files can effectively control memory consumption.

0 commit comments

Comments
 (0)