From d2c435815082ccc4b578479a73d8697f3eb68166 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 19 Nov 2025 15:24:14 +1300 Subject: [PATCH 01/17] .net10 tests for Android --- .github/workflows/device-tests-android.yml | 13 ++++++------- Sentry.sln | 1 + integration-test/android.Tests.ps1 | 19 +++++++++++++++---- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/device-tests-android.yml b/.github/workflows/device-tests-android.yml index 5e079053a3..2f3162f99d 100644 --- a/.github/workflows/device-tests-android.yml +++ b/.github/workflows/device-tests-android.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - tfm: [net9.0] + tfm: [net9.0, net10.0] env: DOTNET_CLI_TELEMETRY_OPTOUT: 1 DOTNET_NOLOGO: 1 @@ -40,13 +40,12 @@ jobs: - name: Build Android Test App run: pwsh ./scripts/device-test.ps1 android -Build -Tfm ${{ matrix.tfm }} - - name: Upload Android Test App (net9.0) - if: matrix.tfm == 'net9.0' + - name: Upload Android Test App (${{ matrix.tfm }}) uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: - name: device-test-android-net9.0 + name: device-test-android-${{ matrix.tfm }} if-no-files-found: error - path: test/Sentry.Maui.Device.TestApp/bin/Release/net9.0-android/android-x64/io.sentry.dotnet.maui.device.testapp-Signed.apk + path: test/Sentry.Maui.Device.TestApp/bin/Release/${{ matrix.tfm }}-android/android-x64/io.sentry.dotnet.maui.device.testapp-Signed.apk android: needs: [build] @@ -58,7 +57,7 @@ jobs: strategy: fail-fast: false matrix: - tfm: [net9.0] + tfm: [net9.0, net10.0] # Must be 34+ for new apps and app updates as of August 31, 2024. # See https://apilevels.com/ api-level: [34, 36] @@ -147,7 +146,7 @@ jobs: disk-size: ${{ env.ANDROID_EMULATOR_DISK_SIZE }} emulator-options: ${{ env.ANDROID_EMULATOR_OPTIONS }} disable-animations: false - script: pwsh integration-test/android.Tests.ps1 + script: pwsh integration-test/android.Tests.ps1 -dotnet_version ${{ matrix.tfm }} - name: Retry Integration Tests (if previous failed to run) if: steps.first-integration-test-run.outcome == 'failure' diff --git a/Sentry.sln b/Sentry.sln index cf1c80a04f..6934a3c845 100644 --- a/Sentry.sln +++ b/Sentry.sln @@ -271,6 +271,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integration-test", "integra integration-test\pester.ps1 = integration-test\pester.ps1 integration-test\ios.Tests.ps1 = integration-test\ios.Tests.ps1 integration-test\msbuild.Tests.ps1 = integration-test\msbuild.Tests.ps1 + integration-test\android.Tests.ps1 = integration-test\android.Tests.ps1 EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net4-console", "net4-console", "{33793113-C7B5-434D-B5C1-6CA1A9587842}" diff --git a/integration-test/android.Tests.ps1 b/integration-test/android.Tests.ps1 index f7910a5af3..ef463b9362 100644 --- a/integration-test/android.Tests.ps1 +++ b/integration-test/android.Tests.ps1 @@ -1,3 +1,7 @@ +param( + [string] $dotnet_version = "net9.0" +) + # This file contains test cases for https://pester.dev/ Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' @@ -12,11 +16,18 @@ BeforeDiscovery { $script:emulator = Get-AndroidEmulatorId } -Describe 'MAUI app (, )' -ForEach @( - @{ tfm = "net9.0-android35.0"; configuration = "Release" } - @{ tfm = "net9.0-android35.0"; configuration = "Debug" } -) -Skip:(-not $script:emulator) { +$cases = @( + @{ Configuration = 'Release' } + @{ Configuration = 'Debug' } +) +Describe 'MAUI app (, )' -ForEach $cases -Skip:(-not $script:emulator) { BeforeAll { + if ($dotnet_version -eq 'net9.0') { + $tfm = 'net9.0-android35.0' + } else { + $tfm = 'net10.0-android36.0' + } + Remove-Item -Path "$PSScriptRoot/mobile-app" -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot/net9-maui" -Destination "$PSScriptRoot/mobile-app" -Recurse -Force Push-Location $PSScriptRoot/mobile-app From 5e9fdcb38c8f9e5605fc1f4d05b0d274e34ee6b5 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 20 Nov 2025 12:37:14 +1300 Subject: [PATCH 02/17] . --- .../Sentry.Maui.Device.TestApp.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj b/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj index b04676ed72..0187f7878c 100644 --- a/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj +++ b/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj @@ -1,8 +1,8 @@  - $(TargetFrameworks);net9.0-android - $(TargetFrameworks);net9.0-ios + $(TargetFrameworks);net9.0-android;net10.0-android + $(TargetFrameworks);net9.0-ios;net10.0-ios $(DefineConstants);VISUAL_RUNNER From f99a7119085e16930165e8f8862f28ab4a50a6c6 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 20 Nov 2025 14:58:23 +1300 Subject: [PATCH 03/17] . --- .../Sentry.Maui.Device.TestApp.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj b/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj index 0187f7878c..1a24ba8bab 100644 --- a/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj +++ b/test/Sentry.Maui.Device.TestApp/Sentry.Maui.Device.TestApp.csproj @@ -73,7 +73,9 @@ + + From 5b7fbc3382c26af9c7618c7227cf02dfe5e8e233 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 20 Nov 2025 16:30:28 +1300 Subject: [PATCH 04/17] . --- integration-test/android.Tests.ps1 | 2 +- .../net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-test/android.Tests.ps1 b/integration-test/android.Tests.ps1 index ef463b9362..dcc2d7292a 100644 --- a/integration-test/android.Tests.ps1 +++ b/integration-test/android.Tests.ps1 @@ -1,5 +1,5 @@ param( - [string] $dotnet_version = "net9.0" + [string] $dotnet_version = "net10.0" ) # This file contains test cases for https://pester.dev/ diff --git a/integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj b/integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj index ed6ab044f6..c998217f68 100644 --- a/integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj +++ b/integration-test/net9-maui/Sentry.Maui.Device.IntegrationTestApp.csproj @@ -1,7 +1,7 @@ - $(TargetFrameworks);net9.0-android35.0 + $(TargetFrameworks);net9.0-android35.0;net10.0-android36.0 $(TargetFrameworks);net9.0-ios18.0 Exe From d40c0304c940d30b3054dc9cea21c640bf551950 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 26 Nov 2025 13:07:51 +1300 Subject: [PATCH 05/17] Testing a theory... --- integration-test/net9-maui/MauiProgram.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/integration-test/net9-maui/MauiProgram.cs b/integration-test/net9-maui/MauiProgram.cs index e1c619cdb5..92aa8cfc5a 100644 --- a/integration-test/net9-maui/MauiProgram.cs +++ b/integration-test/net9-maui/MauiProgram.cs @@ -21,11 +21,16 @@ public static MauiApp CreateMauiApp() options.SendClientReports = false; options.AutoSessionTracking = false; - options.SetBeforeBreadcrumb((breadcrumb, hint) => + // Only check breadcrumbs for non-crash tests... + var testArg = System.Environment.GetEnvironmentVariable("SENTRY_TEST_ARG"); + if (!Enum.TryParse(testArg, ignoreCase: true, out var crashType)) { - App.ReceiveSystemBreadcrumb(breadcrumb); - return breadcrumb; - }); + options.SetBeforeBreadcrumb((breadcrumb, hint) => + { + App.ReceiveSystemBreadcrumb(breadcrumb); + return breadcrumb; + }); + } }) .ConfigureFonts(fonts => { From 344c80a0323712fbd4df9cc124967ee235180e2a Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 27 Nov 2025 14:03:58 +1300 Subject: [PATCH 06/17] Try to prevent double crash --- integration-test/net9-maui/App.xaml.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/integration-test/net9-maui/App.xaml.cs b/integration-test/net9-maui/App.xaml.cs index c187a5ad66..ce3f1ae083 100644 --- a/integration-test/net9-maui/App.xaml.cs +++ b/integration-test/net9-maui/App.xaml.cs @@ -70,6 +70,7 @@ public static void OnAppearing() { SentrySdk.CauseCrash(crashType); } + else #pragma warning restore CS0618 if (HasTestArg("NullReferenceException")) From b8d6c02c31359c710b6bfc004e360b42756d7b20 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 27 Nov 2025 14:06:03 +1300 Subject: [PATCH 07/17] Revert "Try to prevent double crash" This reverts commit 344c80a0323712fbd4df9cc124967ee235180e2a. --- integration-test/net9-maui/App.xaml.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/integration-test/net9-maui/App.xaml.cs b/integration-test/net9-maui/App.xaml.cs index ce3f1ae083..c187a5ad66 100644 --- a/integration-test/net9-maui/App.xaml.cs +++ b/integration-test/net9-maui/App.xaml.cs @@ -70,7 +70,6 @@ public static void OnAppearing() { SentrySdk.CauseCrash(crashType); } - else #pragma warning restore CS0618 if (HasTestArg("NullReferenceException")) From 241a908d925baca7b1a9c6906b1dd3c2051e4d42 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 27 Nov 2025 14:40:01 +1300 Subject: [PATCH 08/17] Ensure JavaSDK is shutdown when closing the Hub --- src/Sentry/Internal/Hub.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs index f44a288b33..6b57ff50aa 100644 --- a/src/Sentry/Internal/Hub.cs +++ b/src/Sentry/Internal/Hub.cs @@ -871,7 +871,7 @@ public void Dispose() #if __IOS__ // TODO #elif ANDROID - // TODO + JavaSdk.Sentry.Close(); #elif NET8_0_OR_GREATER if (SentryNative.IsAvailable) { From 278c04c7de03431ca5ff076bee4fe9ccd33042bf Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 27 Nov 2025 16:34:18 +1300 Subject: [PATCH 09/17] Remove todo from previously failing test --- integration-test/android.Tests.ps1 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/integration-test/android.Tests.ps1 b/integration-test/android.Tests.ps1 index dcc2d7292a..fc691b333d 100644 --- a/integration-test/android.Tests.ps1 +++ b/integration-test/android.Tests.ps1 @@ -180,13 +180,8 @@ Describe 'MAUI app (, )' -ForEach $cases -Skip:(- Dump-ServerErrors -Result $result $result.HasErrors() | Should -BeFalse $result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`"" - # TODO: fix redundant SIGSEGV in Release (#3954) - if ($configuration -eq "Release") { - { $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw - } else { - $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" - $result.Envelopes() | Should -HaveCount 1 - } + $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" + $result.Envelopes() | Should -HaveCount 1 } It 'Delivers battery breadcrumbs in main thread ()' { From ad9c67196382f441a803aad10ac4bec66b001c7a Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Fri, 28 Nov 2025 12:58:16 +1300 Subject: [PATCH 10/17] Try System.Environment.Exit(0) instead of process.kill --- integration-test/net9-maui/App.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-test/net9-maui/App.xaml.cs b/integration-test/net9-maui/App.xaml.cs index c187a5ad66..3009ce1a0c 100644 --- a/integration-test/net9-maui/App.xaml.cs +++ b/integration-test/net9-maui/App.xaml.cs @@ -72,7 +72,7 @@ public static void OnAppearing() } #pragma warning restore CS0618 - if (HasTestArg("NullReferenceException")) + else if (HasTestArg("NullReferenceException")) { try { @@ -104,7 +104,7 @@ public static void Kill() #if ANDROID // prevent auto-restart Platform.CurrentActivity?.FinishAffinity(); - Process.KillProcess(Process.MyPid()); + System.Environment.Exit(0); #elif IOS System.Environment.Exit(0); #endif From 429801b1668b7ae3b500c496d4be24b57ff82f1e Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Fri, 28 Nov 2025 15:21:27 +1300 Subject: [PATCH 11/17] roll back unrelated change --- integration-test/net9-maui/MauiProgram.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/integration-test/net9-maui/MauiProgram.cs b/integration-test/net9-maui/MauiProgram.cs index 92aa8cfc5a..5fe652d372 100644 --- a/integration-test/net9-maui/MauiProgram.cs +++ b/integration-test/net9-maui/MauiProgram.cs @@ -21,17 +21,11 @@ public static MauiApp CreateMauiApp() options.SendClientReports = false; options.AutoSessionTracking = false; - // Only check breadcrumbs for non-crash tests... - var testArg = System.Environment.GetEnvironmentVariable("SENTRY_TEST_ARG"); - if (!Enum.TryParse(testArg, ignoreCase: true, out var crashType)) + options.SetBeforeBreadcrumb((breadcrumb, hint) => { - options.SetBeforeBreadcrumb((breadcrumb, hint) => - { - App.ReceiveSystemBreadcrumb(breadcrumb); - return breadcrumb; - }); - } - }) + App.ReceiveSystemBreadcrumb(breadcrumb); + return breadcrumb; + }); }) .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); From cf16076a992a10ffa591e511b5107b452bd360b0 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Fri, 28 Nov 2025 15:22:04 +1300 Subject: [PATCH 12/17] reinstate null reference workaround for net9 tfm --- integration-test/android.Tests.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/integration-test/android.Tests.ps1 b/integration-test/android.Tests.ps1 index fc691b333d..b969f55027 100644 --- a/integration-test/android.Tests.ps1 +++ b/integration-test/android.Tests.ps1 @@ -180,8 +180,13 @@ Describe 'MAUI app (, )' -ForEach $cases -Skip:(- Dump-ServerErrors -Result $result $result.HasErrors() | Should -BeFalse $result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`"" - $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" - $result.Envelopes() | Should -HaveCount 1 + # TODO: fix redundant SIGSEGV in Release (#3954) + if ($configuration -eq "Release" -and $dotnet_version -eq 'net9.0') { + { $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw + } else { + $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" + $result.Envelopes() | Should -HaveCount 1 + } } It 'Delivers battery breadcrumbs in main thread ()' { From 08897351f59e36ac3dc0dc0e358c017d8823a557 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Fri, 28 Nov 2025 15:44:40 +1300 Subject: [PATCH 13/17] Revert change from kill to System.Environment.Exit --- integration-test/net9-maui/App.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/net9-maui/App.xaml.cs b/integration-test/net9-maui/App.xaml.cs index 3009ce1a0c..de8bcf17d5 100644 --- a/integration-test/net9-maui/App.xaml.cs +++ b/integration-test/net9-maui/App.xaml.cs @@ -104,7 +104,7 @@ public static void Kill() #if ANDROID // prevent auto-restart Platform.CurrentActivity?.FinishAffinity(); - System.Environment.Exit(0); + Process.KillProcess(Process.MyPid()); #elif IOS System.Environment.Exit(0); #endif From c1b3e7c1583562449bcb03a26b499aa1dacd6093 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Fri, 28 Nov 2025 15:49:15 +1300 Subject: [PATCH 14/17] Skip the Native Crash integration test on net10 --- integration-test/android.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-test/android.Tests.ps1 b/integration-test/android.Tests.ps1 index b969f55027..d24ec1acaa 100644 --- a/integration-test/android.Tests.ps1 +++ b/integration-test/android.Tests.ps1 @@ -156,7 +156,8 @@ Describe 'MAUI app (, )' -ForEach $cases -Skip:(- $result.Envelopes() | Should -HaveCount 1 } - It 'Native crash ()' { + # Skipping on .NET 10.0 for the time being - see https://github.com/getsentry/sentry-dotnet/pull/4750#issuecomment-3583814252 + It 'Native crash ()' -Skip:($dotnet_version -eq 'net10.0') { $result = Invoke-SentryServer { param([string]$url) RunAndroidApp -Dsn $url -TestArg "Native" From 0adaddb7ad91d0b41a2c38aacc64727ce54b2a3b Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Mon, 1 Dec 2025 11:46:30 +1300 Subject: [PATCH 15/17] . --- integration-test/android.Tests.ps1 | 9 ++------- integration-test/net9-maui/MauiProgram.cs | 3 ++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/integration-test/android.Tests.ps1 b/integration-test/android.Tests.ps1 index d24ec1acaa..1d941aa7a7 100644 --- a/integration-test/android.Tests.ps1 +++ b/integration-test/android.Tests.ps1 @@ -181,13 +181,8 @@ Describe 'MAUI app (, )' -ForEach $cases -Skip:(- Dump-ServerErrors -Result $result $result.HasErrors() | Should -BeFalse $result.Envelopes() | Should -AnyElementMatch "`"type`":`"System.NullReferenceException`"" - # TODO: fix redundant SIGSEGV in Release (#3954) - if ($configuration -eq "Release" -and $dotnet_version -eq 'net9.0') { - { $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" } | Should -Throw - } else { - $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" - $result.Envelopes() | Should -HaveCount 1 - } + $result.Envelopes() | Should -Not -AnyElementMatch "`"type`":`"SIGSEGV`"" + $result.Envelopes() | Should -HaveCount 1 } It 'Delivers battery breadcrumbs in main thread ()' { diff --git a/integration-test/net9-maui/MauiProgram.cs b/integration-test/net9-maui/MauiProgram.cs index 5fe652d372..e1c619cdb5 100644 --- a/integration-test/net9-maui/MauiProgram.cs +++ b/integration-test/net9-maui/MauiProgram.cs @@ -25,7 +25,8 @@ public static MauiApp CreateMauiApp() { App.ReceiveSystemBreadcrumb(breadcrumb); return breadcrumb; - }); }) + }); + }) .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); From 1361614ebbf035bd083a5896c197ed568d28c208 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Mon, 1 Dec 2025 14:44:24 +1300 Subject: [PATCH 16/17] Revert fix to close Java SDK until we can work out why it breaks unit tests --- src/Sentry/Internal/Hub.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs index 6b57ff50aa..c378c3dc2d 100644 --- a/src/Sentry/Internal/Hub.cs +++ b/src/Sentry/Internal/Hub.cs @@ -871,7 +871,9 @@ public void Dispose() #if __IOS__ // TODO #elif ANDROID - JavaSdk.Sentry.Close(); + // TODO: For some reason the integration tests on Android fail if we Close on the Java SDK... + // https://github.com/getsentry/sentry-dotnet/blob/0adaddb7ad91d0b41a2c38aacc64727ce54b2a3b/integration-test/android.Tests.ps1#L154 + // JavaSdk.Sentry.Close(); #elif NET8_0_OR_GREATER if (SentryNative.IsAvailable) { From ed8b558969e7cb0a31bcd8fce0bea2b95a146d37 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Mon, 1 Dec 2025 20:53:25 +1300 Subject: [PATCH 17/17] . --- integration-test/net9-maui/App.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/net9-maui/App.xaml.cs b/integration-test/net9-maui/App.xaml.cs index de8bcf17d5..c187a5ad66 100644 --- a/integration-test/net9-maui/App.xaml.cs +++ b/integration-test/net9-maui/App.xaml.cs @@ -72,7 +72,7 @@ public static void OnAppearing() } #pragma warning restore CS0618 - else if (HasTestArg("NullReferenceException")) + if (HasTestArg("NullReferenceException")) { try {