-
-
Notifications
You must be signed in to change notification settings - Fork 221
fix: BuildProperty-Generator and AOT compilation detection #4333
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
Conversation
A couple of the integration tests are failing since they're erroneously detecting the the app has been compiled AOT when this is not the case. I believe it's due to this: sentry-dotnet/integration-test/runtime.Tests.ps1 Lines 94 to 105 in 24ab509
The test itself is valid. The sentry-dotnet/src/Sentry/Internal/AotHelper.cs Lines 20 to 28 in 0514bfe
A couple of things would need to change in that logic then:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refines the build‐property source generator to only emit code for executable outputs, renames and enhances the generated initializer, expands AOT detection, and updates related tests and MSBuild targets.
- Generator now uses
OutputKindExtensions.IsExe()
and dynamic tool/version metadata to emitSentry.Generated.BuildPropertyInitializer.g.cs
. AotHelper
gains_IsPublishing
&PublishSelfContained
checks with diagnostic logging; called early inSentrySdk.InitHub
.- MSBuild
.targets
add the_IsPublishing
andPublishSelfContained
properties; tests and verified baselines updated.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
test/VerifySettingsInitializer.cs | Adds scrubber initializer to normalize version in snapshots. |
test/BuildPropertySourceGeneratorTests.cs | Refactors driver setup to use OutputKind , updates hint name, and adds new scenarios. |
src/Sentry/buildTransitive/Sentry.targets | Includes _IsPublishing and PublishSelfContained properties. |
src/Sentry/buildTransitive/Sentry.SourceGenerators.targets | Mirrors the new MSBuild properties for the source‐generator. |
src/Sentry/SentrySdk.cs | Invokes AotHelper.CheckIsTrimmed with logger. |
src/Sentry/Internal/AotHelper.cs | Enhances trimmed detection with _IsPublishing and PublishSelfContained , adds logging. |
src/Sentry.SourceGenerators/OutputKindExtensions.cs | New helper to test executable outputs. |
src/Sentry.SourceGenerators/GeneratedCodeText.cs | Introduces dynamic tool/version values for generation. |
src/Sentry.SourceGenerators/BuildPropertySourceGenerator.cs | Sealed class, raw string literal, indentation constant, renamed output, and metadata injection. |
CHANGELOG.md | Notes fix for build‐setting detection in AOT contexts. |
Comments suppressed due to low confidence (2)
test/Sentry.SourceGenerators.Tests/BuildPropertySourceGeneratorTests.cs:52
- There’s no test covering the new
PublishSelfContained
path inAotHelper.CheckIsTrimmed
. Add a test scenario where_IsPublishing = true
andPublishSelfContained = true
to verify trimmed detection behaves as expected.
[SkippableFact]
test/Sentry.SourceGenerators.Tests/VerifySettingsInitializer.cs:1
- The scrubber method uses StringBuilder but there's no
using System.Text;
directive. Add it to ensure the code compiles.
using System.CodeDom.Compiler;
only "Sentry.targets" is picked up by a "PackageReference" and this file was never imported either
So we had a working PR back on commit 8fbade9... then the iOS device tests started failing. Nothing in the new commits looks suspicious (essentially just tidying up around the edges). To test whether the new commits were potentially related, I forked this PR back on 8fbade9 and pushed it up in a new branch as #4335... and indeed, the iOS device tests are failing there as well. Possibly the iOS device tests are flaky, and this is only apparent now that the source generators (and the AOT compilation detection) is now working? |
The logs in the broken CI runs are showing: Failed to install the application
Cleaning up the failed installation from 'iPhone Xs (iOS 18.5) - created by XHarness'
Uninstalling the application 'io.sentry.dotnet.maui.device.testapp' from 'iPhone Xs (iOS 18.5) - created by XHarness'
Failed to uninstall the app bundle! Check logs for more details!
XHarness exit code: 78 (PACKAGE_INSTALLATION_FAILURE) About the only reference I can find to this error is here: |
Resolves #4331:
Proposing a bunch of changes to the Generated-code, considering the Generator so far never emitted any sources to the consuming compilation
<CompilerVisibleProperty Include="OutputType" />
in packedSentry.targets
, so the Generator never emitted any sourcesCompilation.Options.OutputKind
new Dictionary<string, string>
tonew Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
#if NET8_0_OR_GREATER
to#if NET5_0_OR_GREATER
net5.0
net5.0
#nullable enable
net5.0
has a defaultLangVersion
of9.0
<Nullable>enable</Nullable>
#nullable enable
individuallyinternal
[ModuleInitializer]
must be accessible from the containing modulepublic
orinternal
in a non-file
-local-type in a non-local-functionSystem.Runtime.CompilerServices.CompilerGeneratedAttribute
withSystem.CodeDom.Compiler.GeneratedCodeAttribute
CompilerGeneratedAttribute
attribute is reserved for Compiler usage onlyrecord
-typesGeneratedCodeAttribute
is intended for Tools and Roslyn-Generator authorsBuildVariableInitializer
toBuildPropertyInitializer
__BuildProperties.g.cs
toSentry.Generated.BuildPropertyInitializer.g.cs
Additionally, proposing changes to the Generator itself and our MSBuild / Packaging
Sentry.SourceGenerators.targets
Sentry.targets
is automatically picked up from Sentry's NuGet-PackageSentry.SourceGenerators.targets
was neverImport
ed in any shipped Build-filesBuildPropertySourceGenerator
Not-InheritableTests
GeneratedCodeAttribute
to the string"Version"
for test stability between releases