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
Copy file name to clipboardExpand all lines: src/coreclr/nativeaot/docs/reflection-free-mode.md
+7-13Lines changed: 7 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Reflection-free mode
2
2
3
-
Reflection-free mode is a mode of the NativeAOT compiler and runtime that greatly reduces the functionality of the reflection APIs and brings a couple interesting benefits as a result. The benefits of this mode are:
3
+
Reflection-free mode is a highly experimental mode of the NativeAOT compiler and runtime that greatly reduces the functionality of the reflection APIs and brings a couple interesting benefits as a result. The benefits of this mode are:
4
4
5
5
* Greatly reduced size of self contained deployments - a fully self-contained "Hello world" style app compiles to a 1 MB file (on x64) with _no dependencies_.
6
6
* Reduced working set and better code locality - parts of the program are more tightly packed together.
@@ -16,8 +16,6 @@ To enable reflection-free mode in a project that is already using NativeAOT, add
16
16
</PropertyGroup>
17
17
```
18
18
19
-
(More switches are documented in the [Optimizing NativeAOT](optimizing.md) document.)
20
-
21
19
## What's different at compile time with reflection disabled
22
20
23
21
When reflection is disabled, the AOT compiler stops emitting data structures that are required to make reflection work at runtime and stops enforcing policies that makes the code more reflection friendly.
@@ -74,21 +72,17 @@ To achieve similar result for when querying for ``Assembly`` (will instead give
74
72
75
73
And here for CustomAttributes (will return an empty array):
The reflection-free mode is implemented as a collection of features that can be controlled individually via the AOT compiler command line options for experiments and troubleshooting, including:
84
+
-`--scanreflection` (also exposed as `IlcScanReflection` build property): Infer reflection usage by code analysis. This feature is disabled for reflection-free mode.
85
+
-`--reflectiondata:none`: Disables generation of reflection data.
86
+
-`--feature:System.Collections.Generic.DefaultComparers=false`: Disables `EqualityComparer<T>.Default` and `Comparer<T>.Default` optimizations that are based on reflection.
94
87
88
+
The complete set of individual features that the reflection-free mode is composed from currently can be found by looking for `IlcDisableReflection` in [Microsoft.NETCore.Native.targets](../BuildIntegration/Microsoft.NETCore.Native.targets).
0 commit comments