Skip to content

fix: Source context for class libraries when running on Android in Release mode #4294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d97b4cb
fix: Source context for class libraries when running on Android in Re…
jamescrosswell Jun 19, 2025
99ecda7
Update CHANGELOG.md
jamescrosswell Jun 19, 2025
eaf4382
Merge branch 'main' into multi-project-maui
jamescrosswell Jun 19, 2025
77a3836
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 8, 2025
0fae5db
Update CHANGELOG.md
jamescrosswell Jul 8, 2025
d6366f6
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 8, 2025
68674b6
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 8, 2025
be7ea6e
Update AndroidAssemblyStoreReaderV2.cs
jamescrosswell Jul 8, 2025
057489f
Update AndroidAssemblyStoreReaderV2.cs
jamescrosswell Jul 8, 2025
19f22ec
Update CachingTransportTests.cs
jamescrosswell Jul 9, 2025
50ab8f4
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 12, 2025
e322bef
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 13, 2025
544b354
Update Sentry.Maui.Device.TestApp.csproj
jamescrosswell Jul 13, 2025
6dd5218
Update device-tests-android.yml
jamescrosswell Jul 14, 2025
ce0a859
Exclude SentryMauiOptionsTests (testing)
jamescrosswell Jul 17, 2025
76ae028
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 17, 2025
a33c654
Update CHANGELOG.md
jamescrosswell Jul 17, 2025
2b15fda
Try FakeReliableNetworkStatusListener in SentryMauiOptionsTests
jamescrosswell Jul 17, 2025
982ffe4
Disable all but one SentryMauiOptionsTests
jamescrosswell Jul 17, 2025
d68676c
Update SentryMauiOptionsTests.cs
jamescrosswell Jul 18, 2025
3a36d99
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 18, 2025
849d704
Try skipping event binders
jamescrosswell Jul 18, 2025
7bd5069
Update CachingTransportTests.cs
jamescrosswell Jul 18, 2025
a527401
Try removing callbacks
jamescrosswell Jul 20, 2025
882e6cc
Merge branch 'main' into multi-project-maui
jamescrosswell Jul 20, 2025
2d2e1b2
Moved default event binders into SentryMauiAppBuilderExtensions
jamescrosswell Jul 21, 2025
c58d2d9
Uncomment the other device tests again
jamescrosswell Jul 21, 2025
6686e9e
Renamed InjectedEventBinders to IntegrationEventBinders
jamescrosswell Jul 21, 2025
11f09e4
Update SentryMauiAppBuilderExtensions.cs
jamescrosswell Jul 21, 2025
8689ce3
Try commenting out MauiCommunityToolkitMvvmEventsBinderTests
jamescrosswell Jul 21, 2025
bc87f3e
Update Startup.cs
jamescrosswell Jul 21, 2025
88daf10
Back to just the SentrySdkTests
jamescrosswell Jul 21, 2025
eed38d9
Added LogLevelExtensionsTests & AndroidAssemblyReaderTests
jamescrosswell Jul 21, 2025
053831f
Added SentryMauiOptionsTests back again
jamescrosswell Jul 21, 2025
ba8e335
No SentryMauiOptionsTests but MauiCommunityToolkitMvvmEventsBinderTests
jamescrosswell Jul 21, 2025
b3fea09
Include half the Sentry.Maui.Tests
jamescrosswell Jul 21, 2025
00ff1f2
Disable the other half
jamescrosswell Jul 21, 2025
ac86208
Just api and options tests
jamescrosswell Jul 21, 2025
e8375ab
Update Sentry.Maui.Tests.csproj
jamescrosswell Jul 21, 2025
1a080dd
Include logcat and screenshot tests
jamescrosswell Jul 22, 2025
2d954bc
Add SentryMauiAppBuilderExtensionsTests
jamescrosswell Jul 22, 2025
f0d9a3c
Added MauiNetworkStatusListenerTests and BreadcrumbEventTests
jamescrosswell Jul 22, 2025
1dde8f7
Added back MauiEventsBinderTests
jamescrosswell Jul 22, 2025
acc5518
Reintroduce button binders
jamescrosswell Jul 22, 2025
614b33e
Reintroduce MauiGestureRecognizerEventsBinderTests
jamescrosswell Jul 22, 2025
da061fc
Reintroduce MauiVisualElementEventsBinderTests
jamescrosswell Jul 22, 2025
527e09e
Reintroduce SentryMauiLogcatsTests
jamescrosswell Jul 23, 2025
ce94206
Reintroduce CaptureException_RemoveScreenshot_NotContainsScreenshotAt…
jamescrosswell Jul 23, 2025
9346258
Reintroduce CaptureException_BeforeCaptureScreenshot_DisableCaptureAsync
jamescrosswell Jul 23, 2025
cb19808
Update MauiImageButtonEventsBinder.cs
jamescrosswell Jul 23, 2025
4e12078
Reintroduce/tweak CaptureException_AttachScreenshot_Threadsafe
jamescrosswell Jul 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Sentry now decompresses Request bodies in ASP.NET Core when RequestDecompression middleware is enabled ([#4315](https://github.com/getsentry/sentry-dotnet/pull/4315))
- Custom ISentryEventProcessors are now run for native iOS events ([#4318](https://github.com/getsentry/sentry-dotnet/pull/4318))
- Crontab validation when capturing checkins ([#4314](https://github.com/getsentry/sentry-dotnet/pull/4314))
- Source context for class libraries when running on Android in Release mode ([#4294](https://github.com/getsentry/sentry-dotnet/pull/4294))
- Native AOT: link to static `lzma` on Linux/MUSL ([#4326](https://github.com/getsentry/sentry-dotnet/pull/4326))
- AppDomain.CurrentDomain.ProcessExit hook is now removed on shutdown ([#4323](https://github.com/getsentry/sentry-dotnet/pull/4323))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,19 @@ public static bool TryReadStore(string inputFile, IList<string> supportedAbis, D
return assembly;
}

// If the assembly name ends with .dll or .exe, try to find it without the extension.
if ((IsFileType(".dll") || IsFileType(".exe")) && FindBestAssembly(name[..^4], out assembly))
{
return assembly;
}

// Conversely, if there is no extension, try with the dll extension (sometimes required for class libraries).
// See: https://github.com/getsentry/sentry-dotnet/issues/4278#issuecomment-2986009125
if (!IsFileType(".dll") && !IsFileType(".exe") && FindBestAssembly(name + ".dll", out assembly))
{
return assembly;
}

return null;

bool IsFileType(string extension)
Expand All @@ -119,10 +127,12 @@ private bool FindBestAssembly(string name, out ExplorerStoreItem? explorerAssemb
{
if (explorer.AssembliesByName?.TryGetValue(name, out var assembly) is true)
{
_logger?.Invoke("Found best assembly {0} in APK AssemblyStore for target arch {1}", name, explorer.TargetArch);
explorerAssembly = new(explorer, assembly);
return true;
}
}
_logger?.Invoke("No best assembly for {0} in APK AssemblyStore", name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we have one logger but shouldn't this be a level Error log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to refactor the AssemblyReader classes that we vendored in fomr MS in order to be able to do that (they use a different pattern for logging).

Probably the easiest would be to replace DebugLogger with our own IDiagnosticLogger... would involve quite a few changes, but then we've made so many changes to these already that the only way to merge in changes from new code is by hand. So a few more changes wouldn't hurt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bruno-garcia one remaining question on this PR is whether we want to refactor all the vendored in code to use our IDiagnosticLogger instead of the DebugLogger delegate that is used currently:

public delegate void DebugLogger(string message, params object?[] args);

The existing delegate doesn't have any notion of "log levels" (so doesn't support what you suggested above).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't add that as a requirement to unblock this. But it's not unreasonable to add if it'll help us debug this better going forward

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, I'll track that in a separate issue as I think we should get this fix out ASAP:

explorerAssembly = null;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private AssemblyStoreExplorer(Stream storeStream, string path, DebugLogger? logg
{
foreach (var item in Assemblies)
{
logger?.Invoke("Assembly {0} indexed from AssemblyStore {1}", item.Name, path);
dict.Add(item.Name, item);
}
}
Expand Down
Loading
Loading