<_IsApplePlatform Condition="'$(_targetOS)' == 'osx' or '$(_IsiOSLikePlatform)' == 'true'">true</_IsApplePlatform>
</PropertyGroup>
- <!-- Set up the defaults for the compatibility mode -->
- <PropertyGroup>
- <IlcGenerateStackTraceData Condition="$(IlcGenerateStackTraceData) == ''">true</IlcGenerateStackTraceData>
- <IlcScanReflection Condition="$(IlcScanReflection) == ''">true</IlcScanReflection>
- </PropertyGroup>
-
<!-- Set up default feature switches -->
<PropertyGroup>
<UseSystemResourceKeys Condition="$(IlcDisableReflection) == 'true'">true</UseSystemResourceKeys>
<ItemGroup Condition="$(IlcSystemModule) == ''">
<UnmanagedEntryPointsAssembly Include="System.Private.CoreLib" />
<AutoInitializedAssemblies Include="System.Private.CoreLib" />
- <AutoInitializedAssemblies Include="System.Private.StackTraceMetadata" Condition="$(IlcGenerateStackTraceData) == 'true'" />
+ <AutoInitializedAssemblies Include="System.Private.StackTraceMetadata" Condition="$(StackTraceSupport) != 'false'" />
<AutoInitializedAssemblies Include="System.Private.TypeLoader" />
<AutoInitializedAssemblies Include="System.Private.Reflection.Execution" Condition="$(IlcDisableReflection) != 'true'" />
<AutoInitializedAssemblies Include="System.Private.DisabledReflection" Condition="$(IlcDisableReflection) == 'true'" />
<IlcArg Include="--runtimeknob:RUNTIME_IDENTIFIER=$(RuntimeIdentifier)" />
<IlcArg Condition="$(ServerGarbageCollection) == 'true'" Include="--runtimeopt:gcServer=1" />
<IlcArg Condition="$(IlcGenerateCompleteTypeMetadata) == 'true' and $(IlcDisableReflection) != 'true'" Include="--completetypemetadata" />
- <IlcArg Condition="$(IlcGenerateStackTraceData) == 'true'" Include="--stacktracedata" />
- <IlcArg Condition="$(IlcScanReflection) == 'true' and $(IlcDisableReflection) != 'true'" Include="--scanreflection" />
+ <IlcArg Condition="$(StackTraceSupport) != 'false'" Include="--stacktracedata" />
+ <IlcArg Condition="$(IlcScanReflection) != 'false' and $(IlcDisableReflection) != 'true'" Include="--scanreflection" />
<IlcArg Condition="$(IlcFoldIdenticalMethodBodies) == 'true'" Include="--methodbodyfolding" />
<IlcArg Condition="$(Optimize) == 'true' and $(OptimizationPreference) == 'Size'" Include="--Os" />
<IlcArg Condition="$(Optimize) == 'true' and $(OptimizationPreference) == 'Speed'" Include="--Ot" />
Since `PublishTrimmed` is implied to be true with Native AOT, some framework features such as binary serialization are disabled by default.
-## Options related to metadata generation
-
-* `<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>`: this disables generation of stack trace metadata that provides textual names in stack traces. This is for example the text string one gets by calling `Exception.ToString()` on a caught exception. With this option disabled, stack traces will still be generated, but will be based on reflection metadata alone (they might be less complete).
-
## Options related to code generation
* `<OptimizationPreference>Speed</OptimizationPreference>`: when generating optimized code, favor code execution speed.
* `<OptimizationPreference>Size</OptimizationPreference>`: when generating optimized code, favor smaller code size.
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+using System.Runtime.CompilerServices;
+
+class Program
+{
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static int Main()
+ {
+ string stackTrace = Environment.StackTrace;
+
+ Console.WriteLine(stackTrace);
+
+#if STRIPPED
+ const bool expected = false;
+#else
+ const bool expected = true;
+#endif
+ bool actual = stackTrace.Contains(nameof(Main)) && stackTrace.Contains(nameof(Program));
+ return expected == actual ? 100 : 1;
+ }
+
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <InvariantGlobalization>true</InvariantGlobalization>
+ <CLRTestTargetUnsupported Condition="'$(IlcMultiModule)' == 'true'">true</CLRTestTargetUnsupported>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="StackTraceMetadata.cs" />
+ </ItemGroup>
+</Project>
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <CLRTestKind>BuildAndRun</CLRTestKind>
+ <CLRTestPriority>0</CLRTestPriority>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <InvariantGlobalization>true</InvariantGlobalization>
+ <CLRTestTargetUnsupported Condition="'$(IlcMultiModule)' == 'true'">true</CLRTestTargetUnsupported>
+ <DefineConstants>$(DefineConstants);STRIPPED</DefineConstants>
+ <StackTraceSupport>false</StackTraceSupport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="StackTraceMetadata.cs" />
+ </ItemGroup>
+</Project>