Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8848123

Browse files
authored
Add note about IlcScanReflection to the native aot docs (#90765)
Fixes #90171
1 parent f3fe768 commit 8848123

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ The .NET Foundation licenses this file to you under the MIT license.
248248
<IlcArg Include="@(RuntimeHostConfigurationOption->'--runtimeknob:%(Identity)=%(Value)')" />
249249
<IlcArg Include="--runtimeknob:RUNTIME_IDENTIFIER=$(RuntimeIdentifier)" />
250250
<IlcArg Condition="$(ServerGarbageCollection) == 'true'" Include="--runtimeopt:gcServer=1" />
251-
<IlcArg Condition="$(IlcGenerateCompleteTypeMetadata) == 'true' and $(IlcDisableReflection) != 'true'" Include="--completetypemetadata" />
251+
<IlcArg Condition="$(IlcGenerateCompleteTypeMetadata) == 'true'" Include="--completetypemetadata" />
252252
<IlcArg Condition="$(StackTraceSupport) != 'false'" Include="--stacktracedata" />
253253
<IlcArg Condition="$(IlcScanReflection) != 'false' and $(IlcDisableReflection) != 'true'" Include="--scanreflection" />
254254
<IlcArg Condition="$(IlcFoldIdenticalMethodBodies) == 'true'" Include="--methodbodyfolding" />

src/coreclr/nativeaot/docs/reflection-free-mode.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Reflection-free mode
22

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:
44

55
* 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_.
66
* 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
1616
</PropertyGroup>
1717
```
1818

19-
(More switches are documented in the [Optimizing NativeAOT](optimizing.md) document.)
20-
2119
## What's different at compile time with reflection disabled
2220

2321
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
7472

7573
And here for CustomAttributes (will return an empty array):
7674

77-
7875
```xml
7976
<ItemGroup>
8077
<RuntimeHostConfigurationOption Include="Switch.System.Reflection.Disabled.DoNotThrowForAttributes" Value="true" />
8178
</ItemGroup>
8279
```
8380

84-
Note:
85-
86-
To make ``NativeLibrary`` API, and on the same occasion``Socket``, to work, you'll need:
81+
## Internal implementation
8782

88-
```xml
89-
<ItemGroup>
90-
<RuntimeHostConfigurationOption Include="Switch.System.Reflection.Disabled.DoNotThrowForAssembly" Value="true" />
91-
<RuntimeHostConfigurationOption Include="Switch.System.Reflection.Disabled.DoNotThrowForAttributes" Value="true" />
92-
</ItemGroup>
93-
```
83+
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.
9487

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

Comments
 (0)