Skip to content
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

Address Trim warnings and prevent future regressions #3841

Merged
merged 41 commits into from
Dec 18, 2024
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f0c2233
Add Trim test app
jamescrosswell Dec 11, 2024
1fcfee5
Update CHANGELOG.md
jamescrosswell Dec 11, 2024
4e8c7d0
Update build.yml
jamescrosswell Dec 11, 2024
88d70bc
Format code
getsentry-bot Dec 11, 2024
04bc9ec
Update Sentry.TrimTest.csproj
jamescrosswell Dec 12, 2024
2117208
Merge branch 'trim-warnings' of github.com:getsentry/sentry-dotnet in…
jamescrosswell Dec 12, 2024
b3f71a5
Update solution filters
jamescrosswell Dec 12, 2024
55ea8c0
Address trim warnings in Sentry core package
jamescrosswell Dec 12, 2024
81f2994
Update generate-solution-filters-config.yaml
jamescrosswell Dec 12, 2024
e371e7e
Removed extraneous project
jamescrosswell Dec 12, 2024
af59166
Fix naming
jamescrosswell Dec 12, 2024
94370ad
Removed misleading AotHelper.IsNativeAot property
jamescrosswell Dec 12, 2024
cd1aafb
Update AotHelper.cs
jamescrosswell Dec 12, 2024
4128643
Addressed trim warnings for Sentry.Maui
jamescrosswell Dec 12, 2024
a49791c
Update PageNavigationExtensions.cs
jamescrosswell Dec 12, 2024
a9de355
Addressed OpenTelemetry trim warnings
jamescrosswell Dec 12, 2024
6102abb
Format code
getsentry-bot Dec 12, 2024
6952ada
Addressed trim warnings in Sentry.Google.Cloud.Functions
jamescrosswell Dec 13, 2024
b520842
Merge branch 'trim-warnings' of github.com:getsentry/sentry-dotnet in…
jamescrosswell Dec 13, 2024
2aee802
Addressed Sentry.AspNetCore.Grpc trim warnings
jamescrosswell Dec 13, 2024
fce29a9
Addressed trim warnings in Sentry.Azure.Functions.Worker
jamescrosswell Dec 13, 2024
daa1b71
Added MAUI trim test app to ensure trimming works on ios and android
jamescrosswell Dec 16, 2024
d86dee2
Update solution filters
jamescrosswell Dec 16, 2024
531de39
Update build.yml
jamescrosswell Dec 16, 2024
0a3e014
Format code
getsentry-bot Dec 16, 2024
0a44a1c
Update build.yml
jamescrosswell Dec 16, 2024
a4a025c
Format code
getsentry-bot Dec 16, 2024
f67bd14
Update MainPage.xaml.cs
jamescrosswell Dec 16, 2024
fbad609
Format code
getsentry-bot Dec 16, 2024
bb9efa5
Added PublishAot to trim test apps to get extra anlyser warnings
jamescrosswell Dec 17, 2024
13caecc
Fixed IL3050 warnings in Sentry.AsoNetCore.Grpc
jamescrosswell Dec 17, 2024
5597967
Exclude Sentry.NLog from trim testing (does not support trimming)
jamescrosswell Dec 17, 2024
634a616
Update README.md
jamescrosswell Dec 17, 2024
9af1b39
Removed Sentry.NLog from trim test app (not trim compatible)
jamescrosswell Dec 17, 2024
7188b44
Disable AOT compilation in MauiTrimTest app (bug in System.Text.Json)
jamescrosswell Dec 17, 2024
98173c5
Update Sentry.NLog.csproj
jamescrosswell Dec 17, 2024
1621887
Merge branch 'main' into trim-warnings
jamescrosswell Dec 17, 2024
587c3cb
Update Sentry.MauiTrimTest.csproj
jamescrosswell Dec 17, 2024
46712a0
Merge branch 'main' into pr/3841
jamescrosswell Dec 17, 2024
9e40b76
Merge branch 'main' into trim-warnings
jamescrosswell Dec 18, 2024
d1a92b7
Update build.yml
jamescrosswell Dec 18, 2024
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
14 changes: 14 additions & 0 deletions .generated.NoMobile.sln
Original file line number Diff line number Diff line change
@@ -193,6 +193,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Analyzers.Tests", "t
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Samples.Console.HeapDump", "samples\Sentry.Samples.Console.HeapDump\Sentry.Samples.Console.HeapDump.csproj", "{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.TrimTest", "test\Sentry.TrimTest\Sentry.TrimTest.csproj", "{6030B748-0000-43B5-B8A8-399AA42F5229}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.MauiTrimTest", "test\Sentry.MauiTrimTest\Sentry.MauiTrimTest.csproj", "{DF92E098-822C-4B94-B96B-56BFB91FBB54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -520,6 +524,14 @@ Global
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}.Release|Any CPU.Build.0 = Release|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Release|Any CPU.Build.0 = Release|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -605,5 +617,7 @@ Global
{E36C8DCA-464E-41CB-B189-F58553AAA8D4} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
{5A17FEF9-07BB-47B8-9883-9C2CC93F09E8} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821} = {21B42F60-5802-404E-90F0-AEBCC56760C0}
{6030B748-0000-43B5-B8A8-399AA42F5229} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{DF92E098-822C-4B94-B96B-56BFB91FBB54} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion .github/actions/environment/action.yml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ runs:
- name: Pin the Xcode Version
if: runner.os == 'macOS'
shell: bash
run: sudo xcode-select --switch /Applications/Xcode_16.0.app
run: sudo xcode-select --switch /Applications/Xcode_16.2.app

# Needed for Android SDK setup step
- uses: actions/setup-java@v3
52 changes: 49 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
os: [ubuntu-latest, windows-latest, macos-15]

steps:
@@ -53,7 +53,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
os: [ubuntu-latest, windows-latest, macos-15]

steps:
@@ -154,7 +154,7 @@ jobs:
strategy:
fail-fast: false
matrix:
# Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
os: [ubuntu-latest, windows-latest, macos-15]

steps:
@@ -187,6 +187,52 @@ jobs:
with:
path: integration-test


trim-analysis:
name: Trim analysis
runs-on: macos-15
Copy link
Member

Choose a reason for hiding this comment

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

can this be latest or we need to pin?

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 pin to get the correct version of Xcode. As of about a month ago, the GitHub macos runners are associated with specific major versions of Xcode.

  • macos-14 has Xcode 15.x installed
  • macos-15 has Xcode 16.x installed

I've basically started trying to pin everything (specific runner version, .NET workload versions via the ios18.0 or android35.0 monkiers etc.) since it gets us closer to deterministic builds. If we don't do this, too much changes arbitrarily between different runs against the same commit and CI fails arbitrarily.


steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 2 # default is 1 and codecov needs > 1

# We use macOS for the final publishing build so we get all the iOS/macCatalyst targets in the packages
- name: Set Environment Variables
run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV

- name: Download sentry-native (macOS)
uses: actions/cache/restore@v4
with:
path: src/Sentry/Platforms/Native/sentry-native
key: sentry-native-macOS-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
fail-on-cache-miss: true

- name: Setup Environment
uses: ./.github/actions/environment

- name: Build Native Dependencies
uses: ./.github/actions/buildnative

- name: Install Android SDKs
if: runner.os == 'macOS'
run: |
dotnet build src/Sentry/Sentry.csproj -t:InstallAndroidDependencies -f:net8.0-android34.0 -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/"
Copy link
Member

Choose a reason for hiding this comment

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

do we need to set the specific android version here? I imagine it might go out of sync when we bump .NET for example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What we're passing here is the target framework net8.0-android34.0. That has to match one of the target frameworks in the csproj file and we pin android34.0 as the oldest possible set of APIs that can be used with net8.0 (for net9.0 it's net9.0-android35.0).

The main reason we're doing this is to ensure the android34.0 SDK gets installed as this is missing from the new GitHub runners. If we remove this, the build fails later on in the workflow.


- name: Publish Test app (macOS)
run: dotnet publish test/Sentry.TrimTest/Sentry.TrimTest.csproj -c Release -r osx-arm64

- name: Publish Test app (Android)
run: dotnet publish test/Sentry.MauiTrimTest/Sentry.MauiTrimTest.csproj -c Release -f net9.0-android35.0 -r android-arm64
Copy link
Member

Choose a reason for hiding this comment

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

we use Android 35 here and 34 above. Is that by default? We could set this as vars at the top of the workflow at least?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

34.0 is used abote with the t:InstallAndroidDependencies parameter to install some missing dependencies. For the trim tests, I've used net9.0 as there are some new analysers in net9.0 (i.e. it picks up more issues).

So yeah, unfortunately we want to use two separate target frameworks for the two different build steps.


# We can't publish iOS applications on CI yet. We'd need a valid bundle identifier and to install the relevant
# certificates/profiles on CI (presumably certs associated with the Sentry org).
# See https://youtrack.jetbrains.com/issue/RIDER-17115/Could-not-find-any-available-provisioning-profiles-for-iOS
# - name: Publish Test app (iOS)
# run: dotnet publish test/Sentry.MauiTrimTest/Sentry.MauiTrimTest.csproj -c Release -f net9.0-ios18.0 -r ios-arm64

test-solution-filters:
runs-on: ubuntu-latest
if: ${{ !startsWith(github.ref_name, 'release/') }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
- Fixed JNI Error when accessing Android device data from multiple threads ([#3802](https://github.com/getsentry/sentry-dotnet/pull/3802))
- Android - fix bug that prevents logcat.log from getting attached to unhandled events (SIGSEGV Segfault) ([#3694](https://github.com/getsentry/sentry-dotnet/pull/3694))
- Fix "System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'idData')" error propagating OpenTelemetry span ids ([#3850](https://github.com/getsentry/sentry-dotnet/pull/3850))
- Address Trim warnings so that MAUI applications can be compiled AOT ([#3841](https://github.com/getsentry/sentry-dotnet/pull/3841))

### Dependencies

1 change: 1 addition & 0 deletions Sentry-CI-Build-Linux.slnf
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
"test\\Sentry.AspNetCore.TestUtils\\Sentry.AspNetCore.TestUtils.csproj",
"test\\Sentry.Azure.Functions.Worker.Tests\\Sentry.Azure.Functions.Worker.Tests.csproj",
"test\\Sentry.DiagnosticSource.IntegrationTests\\Sentry.DiagnosticSource.IntegrationTests.csproj",
"test\\Sentry.DiagnosticSource.Tests\\Sentry.DiagnosticSource.Tests.csproj",
14 changes: 14 additions & 0 deletions Sentry.sln
Original file line number Diff line number Diff line change
@@ -193,6 +193,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Analyzers.Tests", "t
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Samples.Console.HeapDump", "samples\Sentry.Samples.Console.HeapDump\Sentry.Samples.Console.HeapDump.csproj", "{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.TrimTest", "test\Sentry.TrimTest\Sentry.TrimTest.csproj", "{6030B748-0000-43B5-B8A8-399AA42F5229}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.MauiTrimTest", "test\Sentry.MauiTrimTest\Sentry.MauiTrimTest.csproj", "{DF92E098-822C-4B94-B96B-56BFB91FBB54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -520,6 +524,14 @@ Global
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821}.Release|Any CPU.Build.0 = Release|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6030B748-0000-43B5-B8A8-399AA42F5229}.Release|Any CPU.Build.0 = Release|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -605,5 +617,7 @@ Global
{E36C8DCA-464E-41CB-B189-F58553AAA8D4} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
{5A17FEF9-07BB-47B8-9883-9C2CC93F09E8} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821} = {21B42F60-5802-404E-90F0-AEBCC56760C0}
{6030B748-0000-43B5-B8A8-399AA42F5229} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
{DF92E098-822C-4B94-B96B-56BFB91FBB54} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
EndGlobalSection
EndGlobal
25 changes: 24 additions & 1 deletion scripts/generate-solution-filters-config.yaml
Original file line number Diff line number Diff line change
@@ -24,6 +24,13 @@ groupConfigs:
windowsOnly:
# .NET Framework projects
- "**/*.AspNet.csproj"
artefacts:
# Any projects in the obj or bin directories
- "**/obj/**/*.csproj"
- "**/bin/**/*.csproj"
trimTests:
- "**/Sentry.TrimTest.csproj"
- "**/Sentry.MauiTrimTest.csproj"

filterConfigs:

@@ -35,12 +42,13 @@ filterConfigs:
groups:
- "macOnly"
- "windowsOnly"
- "artefacts"
- "trimTests"
patterns:
- "**/*AndroidTestApp.csproj"
- "**/*DeviceTests*.csproj"
- "**/*Maui.Device.TestApp.csproj"
- "**/*SourceGen.csproj"
- "**/*TestUtils*.csproj"

- outputPath: Sentry-CI-Build-macOS.slnf
include:
@@ -50,6 +58,9 @@ filterConfigs:
- "modules/perfview/**/TraceEvent.csproj"
- "modules/perfview/**/FastSerialization.csproj"
exclude:
groups:
- "artefacts"
- "trimTests"
patterns:
- "**/*AndroidTestApp.csproj"
- "**/*DeviceTests*.csproj"
@@ -65,6 +76,8 @@ filterConfigs:
exclude:
groups:
- "macOnly"
- "artefacts"
- "trimTests"
patterns:
- "**/*AndroidTestApp.csproj"
- "**/*DeviceTests*.csproj"
@@ -78,6 +91,8 @@ filterConfigs:
groups:
- "allProjects"
exclude:
groups:
- "artefacts"
patterns:
- "**/Sentry.Bindings*.csproj"
- "benchmarks/**/*.csproj"
@@ -115,6 +130,9 @@ filterConfigs:
- "**/Sentry.Testing.CrashableApp.csproj"
- "**/Sentry.Tests.csproj"
- "**/Sentry.Analyzers.Tests.csproj"
exclude:
groups:
- "artefacts"

- outputPath: SentryCore.slnf
solution: .generated.NoMobile.sln
@@ -173,6 +191,9 @@ filterConfigs:
groups:
- "allProjects"
exclude:
groups:
- "artefacts"
- "trimTests"
patterns:
- "**/*Bindings*.csproj"
- "**/*Android*.csproj"
@@ -184,6 +205,8 @@ filterConfigs:
groups:
- "allProjects"
exclude:
groups:
- "trimTests"
patterns:
- "samples/**/*"
- "**/*Bindings*"
2 changes: 1 addition & 1 deletion src/Sentry.AspNetCore.Grpc/Sentry.AspNetCore.Grpc.csproj
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.19.1" />
<PackageReference Include="Google.Protobuf" Version="3.22.5" />
<PackageReference Include="Grpc.AspNetCore.Server" Version="2.40.0" />
</ItemGroup>

3 changes: 3 additions & 0 deletions src/Sentry.AspNetCore/Sentry.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -19,6 +19,9 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="Sentry.AspNetCore.Tests" PublicKey="$(SentryPublicKey)" />
Original file line number Diff line number Diff line change
@@ -81,7 +81,8 @@ public async Task Invoke(FunctionContext context, FunctionExecutionDelegate next
}
}

[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = AotHelper.SuppressionJustification)]
[UnconditionalSuppressMessage("Trimming", "IL2026: RequiresUnreferencedCode", Justification = AotHelper.AvoidAtRuntime)]
[UnconditionalSuppressMessage("Trimming", "IL2075: DynamicallyAccessedMembers", Justification = AotHelper.AvoidAtRuntime)]
private async Task<TransactionContext> StartOrContinueTraceAsync(FunctionContext context)
{
var transactionName = context.FunctionDefinition.Name;
@@ -101,7 +102,7 @@ private async Task<TransactionContext> StartOrContinueTraceAsync(FunctionContext
// attribute. In that case the route name will always be /api/<FUNCTION_NAME>
// If this is ever a problem for customers, we can potentially see if there are alternate ways to get this info
// from route tables or something. We're not even sure if anyone will use this functionality for now though.
if (!AotHelper.IsNativeAot && !TransactionNameCache.TryGetValue(transactionNameKey, out transactionName))
if (!AotHelper.IsTrimmed && !TransactionNameCache.TryGetValue(transactionNameKey, out transactionName))
{
// Find the HTTP Trigger attribute via reflection
var assembly = Assembly.LoadFrom(context.FunctionDefinition.PathToAssembly);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ namespace Sentry.Internal.DiagnosticSource;
/// </remarks>
internal static class ReflectionHelper
{
[UnconditionalSuppressMessage("TrimAnalyzer", "IL2075", Justification = AotHelper.SuppressionJustification)]
[UnconditionalSuppressMessage("TrimAnalyzer", "IL2075: DynamicallyAccessedMembers", Justification = AotHelper.AvoidAtRuntime)]
public static object? GetProperty(this object obj, string name, IDiagnosticLogger? logger = null)
{
if (AotHelper.IsTrimmed)
Original file line number Diff line number Diff line change
@@ -6,9 +6,15 @@
<Description>Official Google Cloud Functions integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.</Description>
</PropertyGroup>

<PropertyGroup Condition="'$(EnableAot)' == 'true'">
<IsAotCompatible>true</IsAotCompatible>
<EnableConfigurationBindingGenerator>true</EnableConfigurationBindingGenerator>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
<PackageReference Include="Google.Cloud.Functions.Hosting" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion src/Sentry.Google.Cloud.Functions/SentryStartup.cs
Original file line number Diff line number Diff line change
@@ -29,7 +29,9 @@ public override void ConfigureLogging(WebHostBuilderContext context, ILoggingBui

// TODO: refactor this with SentryWebHostBuilderExtensions
var section = context.Configuration.GetSection("Sentry");
logging.Services.Configure<SentryAspNetCoreOptions>(section);
logging.Services.AddSingleton<IConfigureOptions<SentryAspNetCoreOptions>>(
_ => new SentryAspNetCoreOptionsSetup(section)
);

logging.Services.Configure<SentryAspNetCoreOptions>(options =>
{
2 changes: 2 additions & 0 deletions src/Sentry.Hangfire/Sentry.Hangfire.csproj
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
</PropertyGroup>

<PropertyGroup Condition="'$(EnableAot)' == 'true'">
<!-- Although Sentry.Hangfire is trim compatible, Hangfire.Core produces trim warnings so ultimately neither
Hangfire nor Sentry.Hangfire should be used in applications built using Trimming or AOT compilation -->
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

28 changes: 24 additions & 4 deletions src/Sentry.Maui/Internal/PageNavigationExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
using Sentry.Internal;

namespace Sentry.Maui.Internal;

internal static class PageNavigationExtensions
{
private static readonly PropertyInfo? DestinationPageProperty =
typeof(NavigatedFromEventArgs).GetProperty("DestinationPage", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly PropertyInfo? DestinationPageProperty;
private static readonly PropertyInfo? PreviousPageProperty;

private static readonly PropertyInfo? PreviousPageProperty =
typeof(NavigatedToEventArgs).GetProperty("PreviousPage", BindingFlags.Instance | BindingFlags.NonPublic);
[UnconditionalSuppressMessage("Trimming", "IL2075: DynamicallyAccessedMembers", Justification = AotHelper.AvoidAtRuntime)]
static PageNavigationExtensions()
{
if (AotHelper.IsTrimmed)
{
return;
}
DestinationPageProperty = typeof(NavigatedFromEventArgs)
.GetProperty("DestinationPage", BindingFlags.Instance | BindingFlags.NonPublic);
PreviousPageProperty = typeof(NavigatedToEventArgs)
.GetProperty("PreviousPage", BindingFlags.Instance | BindingFlags.NonPublic);
}

/// <summary>
/// Reads the (internal) NavigatedFromEventArgs.DestinationPage property via reflection.
/// Note that this will return null if trimming is enabled.
/// </summary>
public static Page? GetDestinationPage(this NavigatedFromEventArgs eventArgs) =>
DestinationPageProperty?.GetValue(eventArgs) as Page;

/// <summary>
/// Reads the (internal) NavigatedFromEventArgs.PreviousPage property via reflection.
/// Note that this will return null if trimming is enabled.
/// </summary>
public static Page? GetPreviousPage(this NavigatedToEventArgs eventArgs) =>
PreviousPageProperty?.GetValue(eventArgs) as Page;
}
3 changes: 2 additions & 1 deletion src/Sentry.OpenTelemetry/Sentry.OpenTelemetry.csproj
Original file line number Diff line number Diff line change
@@ -16,7 +16,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenTelemetry" Version="1.5.0" />
<!-- Version 1.6.0 is the minimum version that does not have trim warnings -->
<PackageReference Include="OpenTelemetry" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
Loading
Loading