From 7647de7679d7e11ed9df65554b2eea76f636463a Mon Sep 17 00:00:00 2001 From: BDisp Date: Thu, 4 Jul 2024 23:12:04 +0100 Subject: [PATCH] Fix compile warnings. --- Terminal.Gui/Application/Application.cs | 12 +- .../Configuration/ConfigurationManager.cs | 15 +++ .../Configuration/KeyCodeJsonConverter.cs | 2 +- .../Configuration/ScopeJsonConverter.cs | 8 +- Terminal.Gui/Configuration/SettingsScope.cs | 9 ++ Terminal.Gui/Configuration/ThemeManager.cs | 125 +++++++++++++++++- .../CursesDriver/UnmanagedLibrary.cs | 2 + Terminal.Gui/ConsoleDrivers/NetDriver.cs | 3 + Terminal.Gui/FileServices/FileDialogStyle.cs | 4 +- 9 files changed, 170 insertions(+), 10 deletions(-) diff --git a/Terminal.Gui/Application/Application.cs b/Terminal.Gui/Application/Application.cs index 9e501f22c..b8a1be6ad 100644 --- a/Terminal.Gui/Application/Application.cs +++ b/Terminal.Gui/Application/Application.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Reflection; @@ -56,7 +57,7 @@ public static partial class Application string assemblyLocation = AppDomain.CurrentDomain.BaseDirectory; // Find the resource file name of the assembly - var resourceFilename = $"{Path.GetFileNameWithoutExtension (assembly.Location)}.resources.dll"; + var resourceFilename = $"{Path.GetFileNameWithoutExtension (AppContext.BaseDirectory)}.resources.dll"; // Return all culture for which satellite folder found with culture code. return culture.Where ( @@ -192,6 +193,8 @@ public static partial class Application /// to use. If neither or are /// specified the default driver for the platform will be used. /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public static void Init (ConsoleDriver driver = null, string driverName = null) { InternalInit (driver, driverName); } internal static bool _initialized; @@ -206,6 +209,8 @@ public static partial class Application // Unit Tests - To initialize the app with a custom Toplevel, using the FakeDriver. calledViaRunT will be false, causing all state to be reset. // // calledViaRunT: If false (default) all state will be reset. If true the state will not be reset. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] internal static void InternalInit ( ConsoleDriver driver = null, string driverName = null, @@ -318,6 +323,7 @@ public static partial class Application /// Gets of list of types that are available. /// + [RequiresUnreferencedCode ("AOT")] public static List GetDriverTypes () { // use reflection to get the list of drivers @@ -660,6 +666,8 @@ public static partial class Application /// /// /// The created object. The caller is responsible for disposing this object. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public static Toplevel Run (Func errorHandler = null, ConsoleDriver driver = null) { return Run (errorHandler, driver); } /// @@ -683,6 +691,8 @@ public static partial class Application /// if has already been called. /// /// The created T object. The caller is responsible for disposing this object. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public static T Run (Func errorHandler = null, ConsoleDriver driver = null) where T : Toplevel, new() { diff --git a/Terminal.Gui/Configuration/ConfigurationManager.cs b/Terminal.Gui/Configuration/ConfigurationManager.cs index 6bed7a20a..68c8c184c 100644 --- a/Terminal.Gui/Configuration/ConfigurationManager.cs +++ b/Terminal.Gui/Configuration/ConfigurationManager.cs @@ -153,6 +153,8 @@ public static class ConfigurationManager /// public static SettingsScope? Settings { + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] get { if (_settings is null) @@ -184,6 +186,8 @@ public static class ConfigurationManager public static event EventHandler? Applied; /// Applies the configuration settings to the running instance. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public static void Apply () { var settings = false; @@ -238,6 +242,8 @@ public static class ConfigurationManager /// If the state of will be reset to the /// defaults. /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public static void Load (bool reset = false) { Debug.WriteLine ("ConfigurationManager.Load()"); @@ -325,6 +331,8 @@ public static class ConfigurationManager /// . /// /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public static void Reset () { Debug.WriteLine (@"ConfigurationManager.Reset()"); @@ -478,6 +486,8 @@ public static class ConfigurationManager /// make sure you copy the Theme definitions from the existing Terminal.Gui.Resources.config.json file. /// /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] internal static void GetHardCodedDefaults () { if (_allConfigProperties is null) @@ -499,6 +509,7 @@ public static class ConfigurationManager /// Initializes the internal state of ConfigurationManager. Nominally called once as part of application startup /// to initialize global state. Also called from some Unit Tests to ensure correctness (e.g. Reset()). /// + [RequiresUnreferencedCode ("AOT")] internal static void Initialize () { _allConfigProperties = new (); @@ -588,6 +599,8 @@ public static class ConfigurationManager /// Creates a JSON document with the configuration specified. /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] internal static string ToJson () { //Debug.WriteLine ("ConfigurationManager.ToJson()"); @@ -595,6 +608,8 @@ public static class ConfigurationManager return JsonSerializer.Serialize (Settings!, typeof (SettingsScope), _serializerContext); } + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] internal static Stream ToStream () { string json = JsonSerializer.Serialize (Settings!, typeof (SettingsScope), _serializerContext); diff --git a/Terminal.Gui/Configuration/KeyCodeJsonConverter.cs b/Terminal.Gui/Configuration/KeyCodeJsonConverter.cs index c7b705311..9b24c7d0a 100644 --- a/Terminal.Gui/Configuration/KeyCodeJsonConverter.cs +++ b/Terminal.Gui/Configuration/KeyCodeJsonConverter.cs @@ -42,7 +42,7 @@ internal class KeyCodeJsonConverter : JsonConverter } // The enum uses "D0..D9" for the number keys - if (Enum.TryParse (reader.GetString ().TrimStart ('D', 'd'), false, out key)) + if (Enum.TryParse (reader.GetString ()!.TrimStart ('D', 'd'), false, out key)) { break; } diff --git a/Terminal.Gui/Configuration/ScopeJsonConverter.cs b/Terminal.Gui/Configuration/ScopeJsonConverter.cs index 3b41d0976..a23216ea0 100644 --- a/Terminal.Gui/Configuration/ScopeJsonConverter.cs +++ b/Terminal.Gui/Configuration/ScopeJsonConverter.cs @@ -1,5 +1,6 @@ #nullable enable using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; @@ -11,9 +12,12 @@ namespace Terminal.Gui; /// data to/from JSON documents. /// /// -internal class ScopeJsonConverter : JsonConverter where scopeT : Scope +internal class ScopeJsonConverter<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] scopeT> : JsonConverter where scopeT : Scope { + [RequiresDynamicCode ("Calls System.Type.MakeGenericType(params Type[])")] +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. public override scopeT Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. { if (reader.TokenType != JsonTokenType.StartObject) { @@ -223,6 +227,8 @@ internal class ScopeJsonConverter : JsonConverter where scopeT : internal class ReadHelper : ReadHelper { private readonly ReadDelegate _readDelegate; + + [RequiresUnreferencedCode ("Calls System.Delegate.CreateDelegate(Type, Object, String)")] public ReadHelper (object converter) { _readDelegate = (ReadDelegate)Delegate.CreateDelegate (typeof (ReadDelegate), converter, "Read"); } public override object? Read (ref Utf8JsonReader reader, Type type, JsonSerializerOptions options) diff --git a/Terminal.Gui/Configuration/SettingsScope.cs b/Terminal.Gui/Configuration/SettingsScope.cs index 81c934d79..8ce37bbbc 100644 --- a/Terminal.Gui/Configuration/SettingsScope.cs +++ b/Terminal.Gui/Configuration/SettingsScope.cs @@ -1,5 +1,6 @@ #nullable enable using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Text.Json; using System.Text.Json.Serialization; @@ -37,6 +38,8 @@ public class SettingsScope : Scope /// Updates the with the settings in a JSON string. /// Json document to update the settings with. /// The source (filename/resource name) the Json document was read from. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public SettingsScope? Update (Stream stream, string source) { // Update the existing settings with the new settings. @@ -67,6 +70,8 @@ public class SettingsScope : Scope /// Updates the with the settings in a JSON file. /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public SettingsScope? Update (string filePath) { string realPath = filePath.Replace ("~", Environment.GetFolderPath (Environment.SpecialFolder.UserProfile)); @@ -93,6 +98,8 @@ public class SettingsScope : Scope /// Updates the with the settings in a JSON string. /// Json document to update the settings with. /// The source (filename/resource name) the Json document was read from. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public SettingsScope? Update (string json, string source) { var stream = new MemoryStream (); @@ -107,6 +114,8 @@ public class SettingsScope : Scope /// Updates the with the settings from a Json resource. /// /// + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] public SettingsScope? UpdateFromResource (Assembly assembly, string resourceName) { if (resourceName is null || string.IsNullOrEmpty (resourceName)) diff --git a/Terminal.Gui/Configuration/ThemeManager.cs b/Terminal.Gui/Configuration/ThemeManager.cs index 9787daa8d..e6efe32e0 100644 --- a/Terminal.Gui/Configuration/ThemeManager.cs +++ b/Terminal.Gui/Configuration/ThemeManager.cs @@ -1,6 +1,7 @@ #nullable enable using System.Collections; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; namespace Terminal.Gui; @@ -64,6 +65,9 @@ public class ThemeManager : IDictionary public string Theme { get => SelectedTheme; + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] set => SelectedTheme = value; } @@ -73,9 +77,14 @@ public class ThemeManager : IDictionary [SerializableConfigurationProperty (Scope = typeof (SettingsScope), OmitClassName = true)] public static Dictionary? Themes { + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] get => Settings? ["Themes"] ?.PropertyValue as Dictionary; // themes ?? new Dictionary (); + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] set => //if (themes is null || value is null) { @@ -93,6 +102,9 @@ public class ThemeManager : IDictionary internal static string SelectedTheme { get => _theme; + + [RequiresUnreferencedCode ("Calls Terminal.Gui.ConfigurationManager.Settings")] + [RequiresDynamicCode ("Calls Terminal.Gui.ConfigurationManager.Settings")] set { string oldTheme = _theme; @@ -109,6 +121,8 @@ public class ThemeManager : IDictionary /// Event fired he selected theme has changed. application. public event EventHandler? ThemeChanged; + [RequiresUnreferencedCode ("Calls Terminal.Gui.ThemeManager.Themes")] + [RequiresDynamicCode ("Calls Terminal.Gui.ThemeManager.Themes")] internal static void GetHardCodedDefaults () { //Debug.WriteLine ("Themes.GetHardCodedDefaults()"); @@ -129,6 +143,8 @@ public class ThemeManager : IDictionary ThemeChanged?.Invoke (this, new ThemeManagerEventArgs (theme)); } + [RequiresUnreferencedCode ("Calls Terminal.Gui.ThemeManager.Themes")] + [RequiresDynamicCode ("Calls Terminal.Gui.ThemeManager.Themes")] internal static void Reset () { Debug.WriteLine ("Themes.Reset()"); @@ -140,33 +156,130 @@ public class ThemeManager : IDictionary #region IDictionary #pragma warning disable 1591 + [UnconditionalSuppressMessage ("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] public ICollection Keys => ((IDictionary)Themes!).Keys; + + [UnconditionalSuppressMessage ("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] public ICollection Values => ((IDictionary)Themes!).Values; + + [UnconditionalSuppressMessage ("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] public int Count => ((ICollection>)Themes!).Count; + + [UnconditionalSuppressMessage ("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] public bool IsReadOnly => ((ICollection>)Themes!).IsReadOnly; public ThemeScope this [string key] { + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. get => ((IDictionary)Themes!) [key]; +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. set => ((IDictionary)Themes!) [key] = value; +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. } + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. public void Add (string key, ThemeScope value) { ((IDictionary)Themes!).Add (key, value); } - public bool ContainsKey (string key) { return ((IDictionary)Themes!).ContainsKey (key); } - public bool Remove (string key) { return ((IDictionary)Themes!).Remove (key); } - public bool TryGetValue (string key, out ThemeScope value) { return ((IDictionary)Themes!).TryGetValue (key, out value!); } - public void Add (KeyValuePair item) { ((ICollection>)Themes!).Add (item); } - public void Clear () { ((ICollection>)Themes!).Clear (); } - public bool Contains (KeyValuePair item) { return ((ICollection>)Themes!).Contains (item); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. + public bool ContainsKey (string key) { return ((IDictionary)Themes!).ContainsKey (key); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. + public bool Remove (string key) { return ((IDictionary)Themes!).Remove (key); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. + public bool TryGetValue (string key, out ThemeScope value) { return ((IDictionary)Themes!).TryGetValue (key, out value!); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. + public void Add (KeyValuePair item) { ((ICollection>)Themes!).Add (item); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. + public void Clear () { ((ICollection>)Themes!).Clear (); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. + public bool Contains (KeyValuePair item) { return ((ICollection>)Themes!).Contains (item); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. public void CopyTo (KeyValuePair [] array, int arrayIndex) +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. { ((ICollection>)Themes!).CopyTo (array, arrayIndex); } + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. public bool Remove (KeyValuePair item) { return ((ICollection>)Themes!).Remove (item); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("AOT")] + [RequiresDynamicCode ("AOT")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. public IEnumerator> GetEnumerator () { return ((IEnumerable>)Themes!).GetEnumerator (); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. + + [RequiresUnreferencedCode ("Calls Terminal.Gui.ThemeManager.Themes")] + [RequiresDynamicCode ("Calls Terminal.Gui.ThemeManager.Themes")] +#pragma warning disable IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning disable IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. IEnumerator IEnumerable.GetEnumerator () { return ((IEnumerable)Themes!).GetEnumerator (); } +#pragma warning restore IL3051 // 'RequiresDynamicCodeAttribute' annotations must match across all interface implementations or overrides. +#pragma warning restore IL2046 // 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides. #pragma warning restore 1591 #endregion diff --git a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnmanagedLibrary.cs b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnmanagedLibrary.cs index 6aef4230f..7400214ec 100644 --- a/Terminal.Gui/ConsoleDrivers/CursesDriver/UnmanagedLibrary.cs +++ b/Terminal.Gui/ConsoleDrivers/CursesDriver/UnmanagedLibrary.cs @@ -13,6 +13,7 @@ // limitations under the License. #define GUICS +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; namespace Unix.Terminal; @@ -69,6 +70,7 @@ internal class UnmanagedLibrary } } + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] static UnmanagedLibrary () { PlatformID platform = Environment.OSVersion.Platform; diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index 0dd0e9038..86ef13466 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -3,6 +3,7 @@ // using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using static Terminal.Gui.ConsoleDrivers.ConsoleKeyMapping; using static Terminal.Gui.NetEvents; @@ -452,6 +453,7 @@ internal class NetEvents : IDisposable HandleKeyboardEvent (newConsoleKeyInfo); } + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] private MouseButtonState MapMouseFlags (MouseFlags mouseFlags) { MouseButtonState mbs = default; @@ -1249,6 +1251,7 @@ internal class NetDriver : ConsoleDriver #region Color Handling // Cache the list of ConsoleColor values. + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] private static readonly HashSet ConsoleColorValues = new ( Enum.GetValues (typeof (ConsoleColor)) .OfType () diff --git a/Terminal.Gui/FileServices/FileDialogStyle.cs b/Terminal.Gui/FileServices/FileDialogStyle.cs index 83adb448c..9cc6557f1 100644 --- a/Terminal.Gui/FileServices/FileDialogStyle.cs +++ b/Terminal.Gui/FileServices/FileDialogStyle.cs @@ -1,4 +1,5 @@ -using System.Globalization; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; using System.IO.Abstractions; using Terminal.Gui.Resources; using static System.Environment; @@ -143,6 +144,7 @@ public class FileDialogStyle /// public string WrongFileTypeFeedback { get; set; } = Strings.fdWrongFileTypeFeedback; + [UnconditionalSuppressMessage ("AOT", "IL3050:Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.", Justification = "")] private Dictionary DefaultTreeRootGetter () { Dictionary roots = new ();