diff --git a/src/Sentry/Internal/DebugStackTrace.cs b/src/Sentry/Internal/DebugStackTrace.cs index ee253c614a..82609f8282 100644 --- a/src/Sentry/Internal/DebugStackTrace.cs +++ b/src/Sentry/Internal/DebugStackTrace.cs @@ -497,13 +497,13 @@ private static void DemangleLambdaReturnType(SentryStackFrame frame) [UnconditionalSuppressMessage("SingleFile", "IL3002:Avoid calling members marked with 'RequiresAssemblyFilesAttribute' when publishing as a single-file", Justification = AotHelper.SuppressionJustification)] private static PEReader? TryReadAssemblyFromDisk(Module module, SentryOptions options, out string? assemblyName) { +#pragma warning disable 0162 // Unreachable code on old .NET frameworks if (AotHelper.IsNativeAot) { - #pragma warning disable 0162 // Unreachable code on old .NET frameworks assemblyName = null; return null; - #pragma warning restore 0162 } +#pragma warning restore 0162 assemblyName = module.FullyQualifiedName; if (options.AssemblyReader is { } reader) diff --git a/src/Sentry/Internal/StackFrame.cs b/src/Sentry/Internal/StackFrame.cs index 2ce23b1344..3b5f64312a 100644 --- a/src/Sentry/Internal/StackFrame.cs +++ b/src/Sentry/Internal/StackFrame.cs @@ -112,10 +112,15 @@ public RealStackFrame(StackFrame frame) public int GetILOffset() => _frame.GetILOffset(); - [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = AotHelper.SuppressionJustification)] - public MethodBase? GetMethod() => AotHelper.IsNativeAot - ? null - : _frame.GetMethod(); + [UnconditionalSuppressMessage("Trimming", + "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", + Justification = AotHelper.SuppressionJustification)] + public MethodBase? GetMethod() + { +#pragma warning disable 0162 // Unreachable code on old .NET frameworks + return AotHelper.IsNativeAot ? null : _frame.GetMethod(); +#pragma warning restore 0162 + } #if NET5_0_OR_GREATER public nint GetNativeImageBase() => _frame.GetNativeImageBase();