File tree Expand file tree Collapse file tree 6 files changed +194
-4
lines changed
i18n/zh-Hans/docusaurus-plugin-content-docs/current/compile Expand file tree Collapse file tree 6 files changed +194
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,31 @@ title: "2.1 智能编译模式 - 实现程序集"
13
13
3 . 智能编译。
14
14
15
15
## 预热案例
16
+ ## 链式预热
17
+
18
+ 从 V9 版本起,Natasha 支持链式预热:
19
+
20
+ ``` cs
21
+ NatashaManagement
22
+ // 获取链式构造器
23
+ .GetInitializer ()
24
+ // 使用引用程序集中的命名空间
25
+ .WithRefUsing ()
26
+ // 使用引用程序集中的元数据
27
+ .WithRefReference ()
28
+ // 使用内存中的命名空间
29
+ .WithMemoryUsing ()
30
+ // 使用内存中的元数据
31
+ .WithMemoryReference ()
32
+ // 使用文件来持久化缓存 命名空间
33
+ .WithFileUsingCache ()
34
+ // 过滤哪些元数据是不能用的,被排除的
35
+ .WithExcludeReferences ((asm , asmStr ) => { return false ; })
36
+ // 注册域构造器
37
+ .Preheating <NatashaDomainCreator >();
38
+ ```
39
+
40
+ 如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
16
41
17
42
### 普通预热
18
43
1 . 泛型预热方法将自动创建 编译域创建者 单例。
@@ -22,13 +47,35 @@ title: "2.1 智能编译模式 - 实现程序集"
22
47
``` cs
23
48
// 注册编译域并预热方法
24
49
NatashaManagement .Preheating <NatashaDomainCreator >(true , true );
50
+ // 或者 V9 版本
51
+ NatashaManagement
52
+ // 获取链式构造器
53
+ .GetInitializer ()
54
+ // 使用引用程序集中的命名空间
55
+ .WithMemoryUsing ()
56
+ // 使用内存中的元数据
57
+ .WithMemoryReference ()
58
+ // 注册域构造器
59
+ .Preheating <NatashaDomainCreator >();
25
60
```
26
61
27
62
### Using缓存预热
28
- 第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
63
+ 指定第三个参数, 第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
29
64
``` cs
30
65
// 注册编译域并预热方法
31
66
NatashaManagement .Preheating <NatashaDomainCreator >(true , true ,true );
67
+ // 或者 V9 版本
68
+ NatashaManagement
69
+ // 获取链式构造器
70
+ .GetInitializer ()
71
+ // 使用引用程序集中的命名空间
72
+ .WithMemoryUsing ()
73
+ // 使用内存中的元数据
74
+ .WithMemoryReference ()
75
+ // 使用文件来持久化缓存 命名空间
76
+ .WithFileUsingCache ()
77
+ // 注册域构造器
78
+ .Preheating <NatashaDomainCreator >();
32
79
```
33
80
34
81
### 分开预热
Original file line number Diff line number Diff line change @@ -16,6 +16,32 @@ title: "2.2 智能编译模式 - 引用程序集"
16
16
17
17
## 预热案例
18
18
19
+ ### 链式预热
20
+
21
+ 从 V9 版本起,Natasha 支持链式预热:
22
+
23
+ ``` cs
24
+ NatashaManagement
25
+ // 获取链式构造器
26
+ .GetInitializer ()
27
+ // 使用引用程序集中的命名空间
28
+ .WithRefUsing ()
29
+ // 使用引用程序集中的元数据
30
+ .WithRefReference ()
31
+ // 使用内存中的命名空间
32
+ .WithMemoryUsing ()
33
+ // 使用内存中的元数据
34
+ .WithMemoryReference ()
35
+ // 使用文件来持久化缓存 命名空间
36
+ .WithFileUsingCache ()
37
+ // 过滤哪些元数据是不能用的,被排除的
38
+ .WithExcludeReferences ((asm , asmStr ) => { return false ; })
39
+ // 注册域构造器
40
+ .Preheating <NatashaDomainCreator >();
41
+ ```
42
+
43
+ 如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
44
+
19
45
### 普通预热
20
46
1 . 泛型预热方法将自动创建 编译域创建者 单例。
21
47
2 . 传入 false 参数以达到禁用运行时程序集的作用,Natasha 将会选择引用程序集预热。
@@ -24,13 +50,35 @@ title: "2.2 智能编译模式 - 引用程序集"
24
50
``` cs
25
51
// 注册编译域并预热方法
26
52
NatashaManagement .Preheating <NatashaDomainCreator >(false , false );
53
+ // 或 V9 版本
54
+ NatashaManagement
55
+ // 获取链式构造器
56
+ .GetInitializer ()
57
+ // 使用引用程序集中的命名空间
58
+ .WithRefUsing ()
59
+ // 使用引用程序集中的元数据
60
+ .WithRefReference ()
61
+ // 注册域构造器
62
+ .Preheating <NatashaDomainCreator >();
27
63
```
28
64
29
65
### Using缓存预热
30
66
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
31
67
``` cs
32
68
// 注册编译域并预热方法
33
69
NatashaManagement .Preheating <NatashaDomainCreator >(false , false ,true );
70
+ // 或 V9 版本
71
+ NatashaManagement
72
+ // 获取链式构造器
73
+ .GetInitializer ()
74
+ // 使用引用程序集中的命名空间
75
+ .WithRefUsing ()
76
+ // 使用引用程序集中的元数据
77
+ .WithRefReference ()
78
+ // 使用文件来持久化缓存 命名空间
79
+ .WithFileUsingCache ()
80
+ // 注册域构造器
81
+ .Preheating <NatashaDomainCreator >();
34
82
```
35
83
36
84
### 分开预热
Original file line number Diff line number Diff line change @@ -123,5 +123,5 @@ builder.WithoutPrivateMembers();
123
123
builder
124
124
.OutputAsRefAssembly ();
125
125
.WithFileOutput ()
126
- .WithoutInjectToDomain ();
126
+ .CompileWithoutAssembly ();
127
127
```
Original file line number Diff line number Diff line change @@ -13,6 +13,31 @@ title: "2.1 智能编译模式 - 实现程序集"
13
13
3 . 智能编译。
14
14
15
15
## 预热案例
16
+ ## 链式预热
17
+
18
+ 从 V9 版本起,Natasha 支持链式预热:
19
+
20
+ ``` cs
21
+ NatashaManagement
22
+ // 获取链式构造器
23
+ .GetInitializer ()
24
+ // 使用引用程序集中的命名空间
25
+ .WithRefUsing ()
26
+ // 使用引用程序集中的元数据
27
+ .WithRefReference ()
28
+ // 使用内存中的命名空间
29
+ .WithMemoryUsing ()
30
+ // 使用内存中的元数据
31
+ .WithMemoryReference ()
32
+ // 使用文件来持久化缓存 命名空间
33
+ .WithFileUsingCache ()
34
+ // 过滤哪些元数据是不能用的,被排除的
35
+ .WithExcludeReferences ((asm , asmStr ) => { return false ; })
36
+ // 注册域构造器
37
+ .Preheating <NatashaDomainCreator >();
38
+ ```
39
+
40
+ 如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
16
41
17
42
### 普通预热
18
43
1 . 泛型预热方法将自动创建 编译域创建者 单例。
@@ -22,13 +47,35 @@ title: "2.1 智能编译模式 - 实现程序集"
22
47
``` cs
23
48
// 注册编译域并预热方法
24
49
NatashaManagement .Preheating <NatashaDomainCreator >(true , true );
50
+ // 或者 V9 版本
51
+ NatashaManagement
52
+ // 获取链式构造器
53
+ .GetInitializer ()
54
+ // 使用引用程序集中的命名空间
55
+ .WithMemoryUsing ()
56
+ // 使用内存中的元数据
57
+ .WithMemoryReference ()
58
+ // 注册域构造器
59
+ .Preheating <NatashaDomainCreator >();
25
60
```
26
61
27
62
### Using缓存预热
28
- 第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
63
+ 指定第三个参数, 第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
29
64
``` cs
30
65
// 注册编译域并预热方法
31
66
NatashaManagement .Preheating <NatashaDomainCreator >(true , true ,true );
67
+ // 或者 V9 版本
68
+ NatashaManagement
69
+ // 获取链式构造器
70
+ .GetInitializer ()
71
+ // 使用引用程序集中的命名空间
72
+ .WithMemoryUsing ()
73
+ // 使用内存中的元数据
74
+ .WithMemoryReference ()
75
+ // 使用文件来持久化缓存 命名空间
76
+ .WithFileUsingCache ()
77
+ // 注册域构造器
78
+ .Preheating <NatashaDomainCreator >();
32
79
```
33
80
34
81
### 分开预热
Original file line number Diff line number Diff line change @@ -16,6 +16,32 @@ title: "2.2 智能编译模式 - 引用程序集"
16
16
17
17
## 预热案例
18
18
19
+ ### 链式预热
20
+
21
+ 从 V9 版本起,Natasha 支持链式预热:
22
+
23
+ ``` cs
24
+ NatashaManagement
25
+ // 获取链式构造器
26
+ .GetInitializer ()
27
+ // 使用引用程序集中的命名空间
28
+ .WithRefUsing ()
29
+ // 使用引用程序集中的元数据
30
+ .WithRefReference ()
31
+ // 使用内存中的命名空间
32
+ .WithMemoryUsing ()
33
+ // 使用内存中的元数据
34
+ .WithMemoryReference ()
35
+ // 使用文件来持久化缓存 命名空间
36
+ .WithFileUsingCache ()
37
+ // 过滤哪些元数据是不能用的,被排除的
38
+ .WithExcludeReferences ((asm , asmStr ) => { return false ; })
39
+ // 注册域构造器
40
+ .Preheating <NatashaDomainCreator >();
41
+ ```
42
+
43
+ 如果不指定相关 API ,预热将跳过此行为,例如只写 WithXXXReference 不写 using 相关的 API, 那么 Natasha 预热时将只对元数据进行操作,不会缓存 using code. 这样做的好处是实现了高度定制化,按需预热。
44
+
19
45
### 普通预热
20
46
1 . 泛型预热方法将自动创建 编译域创建者 单例。
21
47
2 . 传入 false 参数以达到禁用运行时程序集的作用,Natasha 将会选择引用程序集预热。
@@ -24,13 +50,35 @@ title: "2.2 智能编译模式 - 引用程序集"
24
50
``` cs
25
51
// 注册编译域并预热方法
26
52
NatashaManagement .Preheating <NatashaDomainCreator >(false , false );
53
+ // 或 V9 版本
54
+ NatashaManagement
55
+ // 获取链式构造器
56
+ .GetInitializer ()
57
+ // 使用引用程序集中的命名空间
58
+ .WithRefUsing ()
59
+ // 使用引用程序集中的元数据
60
+ .WithRefReference ()
61
+ // 注册域构造器
62
+ .Preheating <NatashaDomainCreator >();
27
63
```
28
64
29
65
### Using缓存预热
30
66
第一次生成将 Using Code 写入缓存文件 Natasha.Namespace.cache 中,后续重启会自动从文件中加载。
31
67
``` cs
32
68
// 注册编译域并预热方法
33
69
NatashaManagement .Preheating <NatashaDomainCreator >(false , false ,true );
70
+ // 或 V9 版本
71
+ NatashaManagement
72
+ // 获取链式构造器
73
+ .GetInitializer ()
74
+ // 使用引用程序集中的命名空间
75
+ .WithRefUsing ()
76
+ // 使用引用程序集中的元数据
77
+ .WithRefReference ()
78
+ // 使用文件来持久化缓存 命名空间
79
+ .WithFileUsingCache ()
80
+ // 注册域构造器
81
+ .Preheating <NatashaDomainCreator >();
34
82
```
35
83
36
84
### 分开预热
Original file line number Diff line number Diff line change @@ -123,5 +123,5 @@ builder.WithoutPrivateMembers();
123
123
builder
124
124
.OutputAsRefAssembly ();
125
125
.WithFileOutput ()
126
- .WithoutInjectToDomain ();
126
+ .CompileWithoutAssembly ();
127
127
```
You can’t perform that action at this time.
0 commit comments