From 8e516d17cc27776568a25eb85aed53f92d96703d Mon Sep 17 00:00:00 2001 From: Leslie Young Date: Sun, 12 May 2024 13:46:49 +0200 Subject: [PATCH] Fixed warnings thrown when AOT enabled There are two warnings thrown when using TargetFramework Net8.0 and setting PublishAOT=true. This change should fix it for non-DEBUG builds. For debug builds you would not normally enable AOT. --- addons/GDTask/Internal/DiagnosticsExtensions.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/GDTask/Internal/DiagnosticsExtensions.cs b/addons/GDTask/Internal/DiagnosticsExtensions.cs index 609a668..248a78e 100644 --- a/addons/GDTask/Internal/DiagnosticsExtensions.cs +++ b/addons/GDTask/Internal/DiagnosticsExtensions.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; @@ -43,7 +44,8 @@ internal static class DiagnosticsExtensions { typeof(GDTaskVoid), "GDTaskVoid" } }; - public static string CleanupAsyncStackTrace(this StackTrace stackTrace) + [RequiresUnreferencedCode("Calls System.Diagnostics.StackFrame.GetMethod()")] + public static string CleanupAsyncStackTrace(this StackTrace stackTrace) { if (stackTrace == null) return ""; @@ -120,15 +122,15 @@ public static string CleanupAsyncStackTrace(this StackTrace stackTrace) return sb.ToString(); } - static bool IsAsync(MethodBase methodInfo) { var declareType = methodInfo.DeclaringType; return typeof(IAsyncStateMachine).IsAssignableFrom(declareType); } - // code from Ben.Demystifier/EnhancedStackTrace.Frame.cs - static bool TryResolveStateMachineMethod(ref MethodBase method, out Type declaringType) + // code from Ben.Demystifier/EnhancedStackTrace.Frame.cs + [RequiresUnreferencedCode("Calls System.Type.GetMethods()")] + static bool TryResolveStateMachineMethod(ref MethodBase method, out Type declaringType) { declaringType = method.DeclaringType;