File tree Expand file tree Collapse file tree 5 files changed +25
-7
lines changed
src/Mono.Android/Android.Runtime
tests/Mono.Android-Tests/Mono.Android-Tests Expand file tree Collapse file tree 5 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -204,9 +204,11 @@ static void RunStartupHooks ()
204204 return ;
205205 }
206206
207- // Pass empty string for diagnosticStartupHooks parameter
208- // The method will read STARTUP_HOOKS from AppContext internally
209- method . Invoke ( null , [ "" ] ) ;
207+ // ProcessStartupHooks accepts startup hooks directly via parameter.
208+ // It will also read STARTUP_HOOKS from AppContext internally.
209+ // Pass DOTNET_STARTUP_HOOKS env var value so it works without needing AppContext setup.
210+ string ? startupHooks = Environment . GetEnvironmentVariable ( "DOTNET_STARTUP_HOOKS" ) ;
211+ method . Invoke ( null , [ startupHooks ?? "" ] ) ;
210212 }
211213
212214 static void SetSynchronizationContext ( ) =>
Original file line number Diff line number Diff line change 5252 <StartupHookSupport >true</StartupHookSupport >
5353 </PropertyGroup >
5454
55- <ItemGroup Condition = " '$(Configuration)' == 'Debug' " >
55+ <ItemGroup >
5656 <!-- trying to track:
5757 JNI ERROR (app bug): accessed deleted Global 0x3056
5858 -->
59- <AndroidEnvironment Include =" env.txt" />
59+ <AndroidEnvironment Include =" env.txt" Condition =" '$(Configuration)' == 'Debug' " />
60+ <AndroidEnvironment Include =" hotreload.env" />
6061 </ItemGroup >
6162
6263 <ItemGroup >
231232 <RuntimeHostConfigurationOption Include =" test_bool" Value =" true" />
232233 <RuntimeHostConfigurationOption Include =" test_integer" Value =" 42" />
233234 <RuntimeHostConfigurationOption Include =" test_string" Value =" foo" />
234- <RuntimeHostConfigurationOption Include =" STARTUP_HOOKS" Value =" StartupHook" />
235+ <!-- Set STARTUP_HOOKS via RuntimeHostConfigurationOption for MonoVM (read via AppContext.GetData) -->
236+ <RuntimeHostConfigurationOption Include =" STARTUP_HOOKS" Value =" StartupHook" Condition =" '$(UseMonoRuntime)' == 'true' " />
235237 </ItemGroup >
236238
237239 <ItemGroup Condition =" '$(AndroidPackageFormat)' != 'aab' " >
Original file line number Diff line number Diff line change @@ -7,6 +7,20 @@ namespace SystemTests
77 [ TestFixture ]
88 public class StartupHookTest
99 {
10+ [ Test ]
11+ public void FeatureFlagIsEnabled ( )
12+ {
13+ // NOTE: this is set to true in tests\Mono.Android-Tests\Mono.Android-Tests\Mono.Android.NET-Tests.csproj
14+ Assert . IsTrue ( Microsoft . Android . Runtime . RuntimeFeature . StartupHookSupport , "RuntimeFeature.StartupHookSupport should be true" ) ;
15+ }
16+
17+ [ Test ]
18+ public void EnvironmentVariableIsSet ( )
19+ {
20+ var value = Environment . GetEnvironmentVariable ( "DOTNET_STARTUP_HOOKS" ) ;
21+ Assert . AreEqual ( "StartupHook" , value , "DOTNET_STARTUP_HOOKS should be set to 'StartupHook'" ) ;
22+ }
23+
1024 [ Test ]
1125 public void IsInitialized ( )
1226 {
Original file line number Diff line number Diff line change 11# Environment Variables and system properties
22# debug.mono.log=gref,default
33debug.mono.debug=1
4- DOTNET_STARTUP_HOOKS=StartupHook
Original file line number Diff line number Diff line change 1+ DOTNET_STARTUP_HOOKS = StartupHook
You can’t perform that action at this time.
0 commit comments