File tree 7 files changed +62
-3
lines changed
System.Private.CoreLib/src/ILLink
nativeaot/System.Private.CoreLib/src
tools/aot/ILCompiler/repro
libraries/System.Private.CoreLib/src/ILLink
tests/nativeaot/StartupHook 7 files changed +62
-3
lines changed Original file line number Diff line number Diff line change 8
8
<method signature =" System.Boolean get_IsDynamicCodeCompiled()" body =" stub" value =" false" />
9
9
<method signature =" System.Boolean get_IsDynamicCodeSupported()" body =" stub" value =" false" />
10
10
</type >
11
- <type fullname =" System.StartupHookProvider" feature =" System.StartupHookProvider.IsSupported" featurevalue =" false" >
12
- <method signature =" System.Boolean get_IsSupported()" body =" stub" value =" false" />
13
- </type >
14
11
</assembly >
15
12
</linker >
Original file line number Diff line number Diff line change 221
221
<Compile Include =" System\String.Intern.cs" />
222
222
<Compile Include =" System\Array.NativeAot.cs" />
223
223
<Compile Include =" System\Delegate.cs" />
224
+ <Compile Include =" System\StartupHookProvider.NativeAot.cs" />
224
225
<Compile Include =" System\RuntimeTypeHandle.cs" />
225
226
<Compile Include =" System\Exception.NativeAot.cs" />
226
227
<Compile Include =" System\RuntimeExceptionHelpers.cs" />
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ using System . Runtime . CompilerServices ;
5
+
6
+ namespace System
7
+ {
8
+ internal static partial class StartupHookProvider
9
+ {
10
+ #pragma warning disable CA2255
11
+ [ ModuleInitializer ]
12
+ #pragma warning restore CA2255
13
+ internal static void Initialize ( )
14
+ {
15
+ if ( IsSupported )
16
+ ProcessStartupHooks ( Environment . GetEnvironmentVariable ( "DOTNET_STARTUP_HOOKS" ) ) ;
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change 41
41
<ReproResponseLines Include =" --feature:System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported=false" />
42
42
<ReproResponseLines Include =" --feature:System.Globalization.Invariant=true" />
43
43
<ReproResponseLines Include =" --feature:System.Diagnostics.Debugger.IsSupported=false" />
44
+ <ReproResponseLines Include =" --feature:System.StartupHookProvider.IsSupported=false" />
44
45
</ItemGroup >
45
46
46
47
<WriteLinesToFile File =" $(OutputPath)\compile-with-$(LibrariesConfiguration)-libs.rsp"
Original file line number Diff line number Diff line change 37
37
<type fullname =" Internal.Runtime.InteropServices.ComponentActivator" feature =" System.Runtime.InteropServices.EnableConsumingManagedCodeFromNativeHosting" featurevalue =" false" >
38
38
<method signature =" System.Boolean get_IsSupported()" body =" stub" value =" false" />
39
39
</type >
40
+ <type fullname =" System.StartupHookProvider" feature =" System.StartupHookProvider.IsSupported" featurevalue =" false" >
41
+ <method signature =" System.Boolean get_IsSupported()" body =" stub" value =" false" />
42
+ </type >
40
43
</assembly >
41
44
</linker >
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+
4
+ using System ;
5
+ using System . Diagnostics . CodeAnalysis ;
6
+
7
+ class Program
8
+ {
9
+ internal static int s_return ;
10
+
11
+ [ DynamicDependency ( nameof ( StartupHook . Initialize ) , typeof ( StartupHook ) ) ]
12
+ static int Main ( ) => s_return ;
13
+ }
14
+
15
+ class StartupHook
16
+ {
17
+ public static void Initialize ( )
18
+ {
19
+ Console . WriteLine ( "Running startup hook" ) ;
20
+ Program . s_return = 100 ;
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ <Project Sdk =" Microsoft.NET.Sdk" >
2
+ <PropertyGroup >
3
+ <OutputType >Exe</OutputType >
4
+ <CLRTestPriority >0</CLRTestPriority >
5
+ <AllowUnsafeBlocks >true</AllowUnsafeBlocks >
6
+ <StartupHookSupport >true</StartupHookSupport >
7
+ <NoWarn >$(NoWarn);IL2026</NoWarn >
8
+ </PropertyGroup >
9
+ <ItemGroup >
10
+ <Compile Include =" StartupHook.cs" />
11
+ </ItemGroup >
12
+
13
+ <ItemGroup >
14
+ <CLRTestEnvironmentVariable Include =" DOTNET_STARTUP_HOOKS" Value =" StartupHook" />
15
+ </ItemGroup >
16
+ </Project >
You can’t perform that action at this time.
0 commit comments