diff --git a/.editorconfig b/.editorconfig index 30b58f9..6deb0c2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -87,8 +87,9 @@ resharper_indent_nested_for_stmt = true resharper_indent_nested_lock_stmt = true resharper_indent_nested_usings_stmt = true resharper_indent_nested_while_stmt = true -resharper_indent_preprocessor_if = usual_indent -resharper_indent_preprocessor_other = usual_indent +resharper_indent_preprocessor_if = no_indent +resharper_indent_preprocessor_other = no_indent +resharper_indent_preprocessor_region = no_indent resharper_keep_existing_declaration_parens_arrangement = false resharper_keep_existing_embedded_arrangement = false resharper_keep_existing_expr_member_arrangement = false diff --git a/Demos.DesktopGL/Program.cs b/Demos.DesktopGL/Program.cs index 1108945..567e8f1 100644 --- a/Demos.DesktopGL/Program.cs +++ b/Demos.DesktopGL/Program.cs @@ -10,11 +10,11 @@ namespace Demos.DesktopGL; public static class Program { public static void Main() { - #if FNA +#if FNA MlemPlatform.Current = new MlemPlatform.DesktopFna(a => TextInputEXT.TextInput += a); - #else +#else MlemPlatform.Current = new MlemPlatform.DesktopGl((w, c) => w.TextInput += c); - #endif +#endif using var game = new GameImpl(); game.Run(); } diff --git a/MLEM.Data/Content/RawContentManager.cs b/MLEM.Data/Content/RawContentManager.cs index a4c2723..34bb8ab 100644 --- a/MLEM.Data/Content/RawContentManager.cs +++ b/MLEM.Data/Content/RawContentManager.cs @@ -23,9 +23,9 @@ namespace MLEM.Data.Content { private readonly List disposableAssets = new List(); private readonly List readers; - #if FNA +#if FNA private Dictionary LoadedAssets { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - #endif +#endif /// /// Creates a new content manager with an optionally specified root directory. @@ -33,9 +33,9 @@ namespace MLEM.Data.Content { /// /// The service provider of your game /// The root directory. Defaults to "Content" - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [RequiresUnreferencedCode("Automatically gathered RawContentReader types might be removed, use other constructor to add readers manually")] - #endif +#endif public RawContentManager(IServiceProvider serviceProvider, string rootDirectory = "Content") : this(serviceProvider, RawContentManager.CollectContentReaders(), rootDirectory) {} @@ -73,9 +73,9 @@ namespace MLEM.Data.Content { /// The current asset instance. /// The asset's type. protected - #if !FNA +#if !FNA override - #endif +#endif void ReloadAsset(string originalAssetName, T currentAsset) { this.Read(originalAssetName, currentAsset); } @@ -121,9 +121,9 @@ namespace MLEM.Data.Content { /// public void Initialize() {} - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [RequiresUnreferencedCode("Automatically gathered RawContentReader types might be removed, use other constructor to add readers manually")] - #endif +#endif private static List CollectContentReaders() { var ret = new List(); var assemblyExceptions = new List(); diff --git a/MLEM.Data/Content/Texture2DReader.cs b/MLEM.Data/Content/Texture2DReader.cs index 7e38746..57f47fe 100644 --- a/MLEM.Data/Content/Texture2DReader.cs +++ b/MLEM.Data/Content/Texture2DReader.cs @@ -9,12 +9,12 @@ namespace MLEM.Data.Content { /// protected override Texture2D Read(RawContentManager manager, string assetPath, Stream stream, Texture2D existing) { - #if !FNA +#if !FNA if (existing != null) { existing.Reload(stream); return existing; } - #endif +#endif // premultiply the texture's color to be in line with the pipeline's texture reader using (var texture = Texture2D.FromStream(manager.GraphicsDevice, stream)) { diff --git a/MLEM.Data/Content/XmlReader.cs b/MLEM.Data/Content/XmlReader.cs index 3892e18..ffaf0b0 100644 --- a/MLEM.Data/Content/XmlReader.cs +++ b/MLEM.Data/Content/XmlReader.cs @@ -12,10 +12,10 @@ namespace MLEM.Data.Content { } /// - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "RawContentManager does not support XmlReader in a trimmed or AOT context, so this method is not expected to be called.")] - #endif +#endif public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) { return new XmlSerializer(t).Deserialize(stream); } diff --git a/MLEM.Data/CopyExtensions.cs b/MLEM.Data/CopyExtensions.cs index 8dcdf8e..a4faf83 100644 --- a/MLEM.Data/CopyExtensions.cs +++ b/MLEM.Data/CopyExtensions.cs @@ -12,9 +12,9 @@ namespace MLEM.Data { /// A set of extensions for dealing with copying objects. /// [Obsolete("CopyExtensions has major flaws and insufficient speed compared to other libraries specifically designed for copying objects.")] - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [UnconditionalSuppressMessage("Aot", "IL3050"), UnconditionalSuppressMessage("Aot", "IL2070"), UnconditionalSuppressMessage("Aot", "IL2090")] - #endif +#endif public static class CopyExtensions { private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; diff --git a/MLEM.Data/DynamicEnum.cs b/MLEM.Data/DynamicEnum.cs index f2469a3..f8c6c41 100644 --- a/MLEM.Data/DynamicEnum.cs +++ b/MLEM.Data/DynamicEnum.cs @@ -26,9 +26,9 @@ namespace MLEM.Data { /// /// [Obsolete("DynamicEnum has been moved into the DynamicEnums library: https://www.nuget.org/packages/DynamicEnums"), JsonConverter(typeof(DynamicEnumConverter))] - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Aot", "IL2067")] - #endif +#endif public abstract class DynamicEnum { private static readonly Dictionary Storages = new Dictionary(); diff --git a/MLEM.Data/Json/JsonConverters.cs b/MLEM.Data/Json/JsonConverters.cs index 35805f1..f6fdace 100644 --- a/MLEM.Data/Json/JsonConverters.cs +++ b/MLEM.Data/Json/JsonConverters.cs @@ -13,9 +13,9 @@ namespace MLEM.Data.Json { /// public static readonly JsonConverter[] Converters = { new Direction2Converter(), - #pragma warning disable CS0618 +#pragma warning disable CS0618 new DynamicEnumConverter(), - #pragma warning restore CS0618 +#pragma warning restore CS0618 new PointConverter(), new RectangleConverter(), new RectangleFConverter(), diff --git a/MLEM.Data/Json/JsonTypeSafeGenericDataHolder.cs b/MLEM.Data/Json/JsonTypeSafeGenericDataHolder.cs index ffea51a..ebc1ae9 100644 --- a/MLEM.Data/Json/JsonTypeSafeGenericDataHolder.cs +++ b/MLEM.Data/Json/JsonTypeSafeGenericDataHolder.cs @@ -9,9 +9,9 @@ namespace MLEM.Data.Json { /// This class uses for each object stored to ensure that objects with a custom get deserialized as an instance of their original type if is not set to . /// Note that, using , adding instances directly is also possible. /// - #if NET7_0_OR_GREATER +#if NET7_0_OR_GREATER [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for instantiation of JsonTypeSafeWrapper instances might not be available at runtime.")] - #endif +#endif public class JsonTypeSafeGenericDataHolder : IGenericDataHolder { private static readonly string[] EmptyStrings = new string[0]; diff --git a/MLEM.Data/Json/JsonTypeSafeWrapper.cs b/MLEM.Data/Json/JsonTypeSafeWrapper.cs index cb06154..e57f2f2 100644 --- a/MLEM.Data/Json/JsonTypeSafeWrapper.cs +++ b/MLEM.Data/Json/JsonTypeSafeWrapper.cs @@ -34,9 +34,9 @@ namespace MLEM.Data.Json { /// /// The value to wrap /// A with a type matching the type of - #if NET7_0_OR_GREATER +#if NET7_0_OR_GREATER [System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for this instantiation might not be available at runtime if the value's type is a subtype of T.")] - #endif +#endif public static JsonTypeSafeWrapper Of(T value) { if (value.GetType() == typeof(T)) { return new JsonTypeSafeWrapper(value); diff --git a/MLEM.Data/Json/StaticJsonConverter.cs b/MLEM.Data/Json/StaticJsonConverter.cs index c433ed7..e0cecd9 100644 --- a/MLEM.Data/Json/StaticJsonConverter.cs +++ b/MLEM.Data/Json/StaticJsonConverter.cs @@ -34,9 +34,9 @@ namespace MLEM.Data.Json { /// The type that the dictionary is declared in /// The name of the dictionary itself public StaticJsonConverter( - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] - #endif +#endif Type type, string memberName) : this(StaticJsonConverter.GetEntries(type, memberName)) {} /// Writes the JSON representation of the object. @@ -65,9 +65,9 @@ namespace MLEM.Data.Json { } private static Dictionary GetEntries( - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] - #endif +#endif Type type, string memberName) { const BindingFlags flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; var value = type.GetProperty(memberName, flags)?.GetValue(null) ?? type.GetField(memberName, flags)?.GetValue(null); diff --git a/MLEM.Data/NetBufferSerializer.cs b/MLEM.Data/NetBufferSerializer.cs index 44ff973..c06deb0 100644 --- a/MLEM.Data/NetBufferSerializer.cs +++ b/MLEM.Data/NetBufferSerializer.cs @@ -11,9 +11,9 @@ namespace MLEM.Data { /// Before serializing and deserializing an object, each of the object's fields has to have a handler. New handlers can be added using or . /// [Obsolete("Lidgren.Network support is deprecated. Consider using LiteNetLib or a custom implementation instead.")] - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER [System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessage("Aot", "IL2070")] - #endif +#endif public class NetBufferSerializer { private readonly Dictionary> writeFunctions = new Dictionary>(); diff --git a/MLEM.Startup/MlemGame.cs b/MLEM.Startup/MlemGame.cs index 2d7445d..c40e99b 100644 --- a/MLEM.Startup/MlemGame.cs +++ b/MLEM.Startup/MlemGame.cs @@ -69,9 +69,9 @@ namespace MLEM.Startup { this.GraphicsDeviceManager = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = windowWidth, PreferredBackBufferHeight = windowHeight, - #if !FNA +#if !FNA HardwareModeSwitch = false - #endif +#endif }; this.Window.AllowUserResizing = true; this.Content.RootDirectory = "Content"; @@ -116,9 +116,9 @@ namespace MLEM.Startup { this.PreDraw?.Invoke(this, gameTime); CoroutineHandler.RaiseEvent(CoroutineEvents.PreDraw); - #pragma warning disable CS0618 +#pragma warning disable CS0618 this.UiSystem.DrawEarly(gameTime, this.SpriteBatch); - #pragma warning restore CS0618 +#pragma warning restore CS0618 this.DoDraw(gameTime); this.UiSystem.Draw(gameTime, this.SpriteBatch); diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index a48e0d9..22a6550 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -206,10 +206,10 @@ namespace MLEM.Ui.Elements { /// The call that this element should make to to begin drawing. /// Note that, when this is non-null, a new SpriteBatch.Begin call is used for this element. /// - #pragma warning disable CS0618 +#pragma warning disable CS0618 [Obsolete("BeginImpl is deprecated. You can create a custom element class and override Draw instead.")] public BeginDelegate BeginImpl; - #pragma warning restore CS0618 +#pragma warning restore CS0618 /// /// Set this field to false to disallow the element from being selected. /// An unselectable element is skipped by automatic navigation and its callback will never be called. @@ -983,7 +983,7 @@ namespace MLEM.Ui.Elements { /// The alpha to draw this element and its children with /// The sprite batch context to use for drawing public void DrawTransformed(GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context) { - #pragma warning disable CS0618 +#pragma warning disable CS0618 var customDraw = this.BeginImpl != null || this.Transform != Matrix.Identity; var transformed = context; transformed.TransformMatrix = this.Transform * transformed.TransformMatrix; @@ -994,12 +994,12 @@ namespace MLEM.Ui.Elements { // begin our own draw call batch.Begin(transformed); } - #pragma warning restore CS0618 +#pragma warning restore CS0618 // draw content in custom begin call - #pragma warning disable CS0618 +#pragma warning disable CS0618 this.Draw(time, batch, alpha, transformed.BlendState, transformed.SamplerState, transformed.DepthStencilState, transformed.Effect, transformed.TransformMatrix); - #pragma warning restore CS0618 +#pragma warning restore CS0618 if (this.System != null) this.System.Metrics.Draws++; @@ -1043,9 +1043,9 @@ namespace MLEM.Ui.Elements { foreach (var child in this.GetRelevantChildren()) { if (!child.IsHidden) { - #pragma warning disable CS0618 +#pragma warning disable CS0618 child.DrawTransformed(time, batch, alpha * child.DrawAlpha, context.BlendState, context.SamplerState, context.DepthStencilState, context.Effect, context.TransformMatrix); - #pragma warning restore CS0618 +#pragma warning restore CS0618 } } } diff --git a/MLEM.Ui/Elements/TextField.cs b/MLEM.Ui/Elements/TextField.cs index 7b39c6f..a8ab9e6 100644 --- a/MLEM.Ui/Elements/TextField.cs +++ b/MLEM.Ui/Elements/TextField.cs @@ -112,11 +112,11 @@ namespace MLEM.Ui.Elements { set => this.textInput.Multiline = value; } - #if FNA +#if FNA /// // we need to make sure that the enter press doesn't get consumed by our press function so that it still works in TextInput public override bool CanBePressed => base.CanBePressed && !this.IsSelected; - #endif +#endif /// /// The text that displays in this text field if is empty @@ -146,9 +146,9 @@ namespace MLEM.Ui.Elements { /// Whether the text field should support multi-line editing public TextField(Anchor anchor, Vector2 size, Rule rule = null, GenericFont font = null, string text = null, bool multiline = false) : base(anchor, size) { this.textInput = new TextInput(null, Vector2.Zero, 1 - #if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER , null, ClipboardService.SetText, ClipboardService.GetText - #endif +#endif ) { OnTextChange = (i, s) => this.OnTextChange?.Invoke(this, s), InputRule = (i, s) => this.InputRule.Invoke(this, s) diff --git a/MLEM.Ui/Elements/Tooltip.cs b/MLEM.Ui/Elements/Tooltip.cs index 704d8a5..35ec98d 100644 --- a/MLEM.Ui/Elements/Tooltip.cs +++ b/MLEM.Ui/Elements/Tooltip.cs @@ -100,9 +100,9 @@ namespace MLEM.Ui.Elements { public Tooltip(string text = null, Element elementToHover = null) : base(Anchor.TopLeft, Vector2.One, Vector2.Zero) { if (text != null) { - #pragma warning disable CS0618 +#pragma warning disable CS0618 this.Paragraph = this.AddParagraph(text); - #pragma warning restore CS0618 +#pragma warning restore CS0618 } this.Init(elementToHover); } @@ -114,9 +114,9 @@ namespace MLEM.Ui.Elements { /// The element that should automatically cause the tooltip to appear and disappear when hovered and not hovered, respectively public Tooltip(Paragraph.TextCallback textCallback, Element elementToHover = null) : base(Anchor.TopLeft, Vector2.One, Vector2.Zero) { - #pragma warning disable CS0618 +#pragma warning disable CS0618 this.Paragraph = this.AddParagraph(textCallback); - #pragma warning restore CS0618 +#pragma warning restore CS0618 this.Init(elementToHover); } @@ -298,11 +298,11 @@ namespace MLEM.Ui.Elements { foreach (var paragraph in this.Paragraphs) this.UpdateParagraphStyle(paragraph); - #pragma warning disable CS0618 +#pragma warning disable CS0618 // still set style here in case someone changed the paragraph field manually if (this.Paragraph != null) this.UpdateParagraphStyle(this.Paragraph); - #pragma warning restore CS0618 +#pragma warning restore CS0618 } private void UpdateParagraphStyle(Paragraph paragraph) { diff --git a/MLEM.Ui/Parsers/UiParser.cs b/MLEM.Ui/Parsers/UiParser.cs index a76e454..e787fed 100644 --- a/MLEM.Ui/Parsers/UiParser.cs +++ b/MLEM.Ui/Parsers/UiParser.cs @@ -10,6 +10,7 @@ using MLEM.Ui.Style; #if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER using System.Net.Http; + #else using System.Net; #endif @@ -25,11 +26,11 @@ namespace MLEM.Ui.Parsers { /// An array containing all of the enum values. /// public static readonly ElementType[] ElementTypes = - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER Enum.GetValues(); - #else +#else (ElementType[]) Enum.GetValues(typeof(ElementType)); - #endif +#endif /// /// The base path for images, which is prepended to the image link. @@ -164,13 +165,13 @@ namespace MLEM.Ui.Parsers { Texture2D tex; if (path.StartsWith("http")) { byte[] src; - #if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER using (var client = new HttpClient()) src = await client.GetByteArrayAsync(path); - #else +#else using (var client = new WebClient()) src = await client.DownloadDataTaskAsync(path); - #endif +#endif using (var memory = new MemoryStream(src)) tex = Texture2D.FromStream(this.GraphicsDevice, memory); } else { diff --git a/MLEM.Ui/Style/StyleProp.cs b/MLEM.Ui/Style/StyleProp.cs index 0767959..d657ea2 100644 --- a/MLEM.Ui/Style/StyleProp.cs +++ b/MLEM.Ui/Style/StyleProp.cs @@ -84,7 +84,7 @@ namespace MLEM.Ui.Style { /// The object to compare with the current instance. /// true if obj and this instance are the same type and represent the same value; otherwise, false. [Obsolete("StyleProp equality is ambiguous as it is not clear whether priority is taken into account. Compare Values instead.")] - #pragma warning disable CS0809 +#pragma warning disable CS0809 public override bool Equals(object obj) { return obj is StyleProp other && this.Equals(other); } @@ -95,7 +95,7 @@ namespace MLEM.Ui.Style { public override int GetHashCode() { return EqualityComparer.Default.GetHashCode(this.Value); } - #pragma warning restore CS0809 +#pragma warning restore CS0809 /// Returns the fully qualified type name of this instance. /// The fully qualified type name. diff --git a/MLEM.Ui/UiSystem.cs b/MLEM.Ui/UiSystem.cs index 1f0454e..b99caba 100644 --- a/MLEM.Ui/UiSystem.cs +++ b/MLEM.Ui/UiSystem.cs @@ -309,7 +309,7 @@ namespace MLEM.Ui { var context = this.SpriteBatchContext; context.TransformMatrix = root.Transform * context.TransformMatrix; - #pragma warning disable CS0618 +#pragma warning disable CS0618 if (this.BlendState != null) context.BlendState = this.BlendState; if (this.SamplerState != null) @@ -318,12 +318,12 @@ namespace MLEM.Ui { context.DepthStencilState = this.DepthStencilState; if (this.Effect != null) context.Effect = this.Effect; - #pragma warning restore CS0618 +#pragma warning restore CS0618 batch.Begin(context); - #pragma warning disable CS0618 +#pragma warning disable CS0618 root.Element.DrawTransformed(time, batch, this.DrawAlpha * root.Element.DrawAlpha, context.BlendState, context.SamplerState, context.DepthStencilState, context.Effect, context.TransformMatrix); - #pragma warning restore CS0618 +#pragma warning restore CS0618 batch.End(); } diff --git a/MLEM/Extensions/CollectionExtensions.cs b/MLEM/Extensions/CollectionExtensions.cs index f983751..8f1991f 100644 --- a/MLEM/Extensions/CollectionExtensions.cs +++ b/MLEM/Extensions/CollectionExtensions.cs @@ -51,7 +51,7 @@ namespace MLEM.Extensions { return combos; } - #if NET452 +#if NET452 /// Appends a value to the end of the sequence. /// A sequence of values. /// The value to append to . @@ -73,7 +73,7 @@ namespace MLEM.Extensions { foreach (var src in source) yield return src; } - #endif +#endif } } diff --git a/MLEM/Extensions/GraphicsExtensions.cs b/MLEM/Extensions/GraphicsExtensions.cs index 85aeac3..4c1b230 100644 --- a/MLEM/Extensions/GraphicsExtensions.cs +++ b/MLEM/Extensions/GraphicsExtensions.cs @@ -90,12 +90,12 @@ namespace MLEM.Extensions { /// The target to apply public TargetContext(GraphicsDevice device, RenderTarget2D target) { this.device = device; - #if FNA +#if FNA // RenderTargetCount doesn't exist in FNA but we still want the optimization in MG this.lastTargets = device.GetRenderTargets(); - #else +#else this.lastTargets = device.RenderTargetCount <= 0 ? null : device.GetRenderTargets(); - #endif +#endif device.SetRenderTarget(target); } diff --git a/MLEM/Extensions/NumberExtensions.cs b/MLEM/Extensions/NumberExtensions.cs index ca13bcd..381f1dd 100644 --- a/MLEM/Extensions/NumberExtensions.cs +++ b/MLEM/Extensions/NumberExtensions.cs @@ -288,7 +288,7 @@ namespace MLEM.Extensions { return false; } - #if FNA +#if FNA /// /// Gets a representation for this object. /// @@ -339,7 +339,7 @@ namespace MLEM.Extensions { y = vector.Y; z = vector.Z; } - #endif +#endif } } diff --git a/MLEM/Font/GenericFont.cs b/MLEM/Font/GenericFont.cs index 18b210a..4fb7197 100644 --- a/MLEM/Font/GenericFont.cs +++ b/MLEM/Font/GenericFont.cs @@ -360,7 +360,7 @@ namespace MLEM.Font { var total = new StringBuilder(); var extraWidth = 0F; var endReached = false; - foreach (var part in (fromBack ? text.Reverse() : text)) { + foreach (var part in fromBack ? text.Reverse() : text) { var curr = new StringBuilder(); // if we reached the end previously, all the other parts should just be empty if (!endReached) { diff --git a/MLEM/Font/GenericSpriteFont.cs b/MLEM/Font/GenericSpriteFont.cs index 178a289..9dee912 100644 --- a/MLEM/Font/GenericSpriteFont.cs +++ b/MLEM/Font/GenericSpriteFont.cs @@ -44,10 +44,10 @@ namespace MLEM.Font { } private static SpriteFont SetDefaults(SpriteFont font) { - #if FNA +#if FNA // none of the copying is available with FNA return font; - #else +#else // we copy the font here to set the default character to a space return new SpriteFont( font.Texture, @@ -58,7 +58,7 @@ namespace MLEM.Font { font.Spacing, font.Glyphs.Select(g => new Vector3(g.LeftSideBearing, g.Width, g.RightSideBearing)).ToList(), ' '); - #endif +#endif } } diff --git a/MLEM/Formatting/TextFormatter.cs b/MLEM/Formatting/TextFormatter.cs index 9190e8a..d4589fa 100644 --- a/MLEM/Formatting/TextFormatter.cs +++ b/MLEM/Formatting/TextFormatter.cs @@ -143,9 +143,9 @@ namespace MLEM.Formatting { private static string StripFormatting(GenericFont font, string s, IEnumerable codes) { foreach (var code in codes) { - #pragma warning disable CS0618 +#pragma warning disable CS0618 s = code.Regex.Replace(s, code.GetReplacementString(font)); - #pragma warning restore CS0618 +#pragma warning restore CS0618 } return s; } diff --git a/MLEM/Graphics/StaticSpriteBatch.cs b/MLEM/Graphics/StaticSpriteBatch.cs index 4879427..20bc5b6 100644 --- a/MLEM/Graphics/StaticSpriteBatch.cs +++ b/MLEM/Graphics/StaticSpriteBatch.cs @@ -461,11 +461,11 @@ namespace MLEM.Graphics { } private void DrawPrimitives(int vertices) { - #if FNA +#if FNA this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices, 0, vertices / 4 * 2); - #else +#else this.graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices / 4 * 2); - #endif +#endif } private void AddItemToSet(Item item) { @@ -560,7 +560,7 @@ namespace MLEM.Graphics { } - #if FNA +#if FNA private class SpriteEffect : Effect { private EffectParameter matrixParam; @@ -611,7 +611,7 @@ namespace MLEM.Graphics { } } - #endif +#endif } } diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs index d32c305..6aff097 100644 --- a/MLEM/Input/InputHandler.cs +++ b/MLEM/Input/InputHandler.cs @@ -18,26 +18,26 @@ namespace MLEM.Input { /// All values of the enum. /// public static readonly Buttons[] AllButtons = - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER Enum.GetValues(); - #else +#else (Buttons[]) Enum.GetValues(typeof(Buttons)); - #endif +#endif /// /// All values of the enum. /// public static readonly Keys[] AllKeys = - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER Enum.GetValues(); - #else +#else (Keys[]) Enum.GetValues(typeof(Keys)); - #endif +#endif - #if FNA +#if FNA private const int MaximumGamePadCount = 4; - #else +#else private static readonly int MaximumGamePadCount = GamePad.MaximumGamePadCount; - #endif +#endif private static readonly TouchLocation[] EmptyTouchLocations = new TouchLocation[0]; private static readonly GenericInput[] EmptyGenericInputs = new GenericInput[0]; @@ -258,11 +258,11 @@ namespace MLEM.Input { } } else { // mouse position and scroll wheel value should be preserved when the mouse is out of bounds - #if FNA +#if FNA this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0); - #else +#else this.MouseState = new MouseState(state.X, state.Y, state.ScrollWheelValue, 0, 0, 0, 0, 0, state.HorizontalScrollWheelValue); - #endif +#endif } } else { this.MouseState = default; diff --git a/MLEM/Input/TextInput.cs b/MLEM/Input/TextInput.cs index 443c230..0b010d2 100644 --- a/MLEM/Input/TextInput.cs +++ b/MLEM/Input/TextInput.cs @@ -246,7 +246,7 @@ namespace MLEM.Input { /// Whether text was successfully input. public bool OnTextInput(Keys key, char character) { // FNA's text input event doesn't supply keys, so we handle this in Update - #if !FNA +#if !FNA if (key == Keys.Back) { if (this.CaretPos > 0) { this.CaretPos--; @@ -261,9 +261,9 @@ namespace MLEM.Input { return this.InsertText(character); } return false; - #else +#else return this.InsertText(character); - #endif +#endif } /// @@ -274,8 +274,8 @@ namespace MLEM.Input { public void Update(GameTime time, InputHandler input) { this.UpdateTextDataIfDirty(); +#if FNA // FNA's text input event doesn't supply keys, so we handle this here - #if FNA if (this.CaretPos > 0 && input.TryConsumePressed(Keys.Back)) { this.CaretPos--; this.RemoveText(this.CaretPos, 1); @@ -284,7 +284,7 @@ namespace MLEM.Input { } else if (this.Multiline && input.TryConsumePressed(Keys.Enter)) { this.InsertText('\n'); } else - #endif +#endif if (this.CaretPos > 0 && input.TryConsumePressed(Keys.Left)) { this.CaretPos--; } else if (this.CaretPos < this.text.Length && input.TryConsumePressed(Keys.Right)) { diff --git a/MLEM/Misc/EnumHelper.cs b/MLEM/Misc/EnumHelper.cs index 69c0dcd..2b10348 100644 --- a/MLEM/Misc/EnumHelper.cs +++ b/MLEM/Misc/EnumHelper.cs @@ -27,11 +27,11 @@ namespace MLEM.Misc { /// The type whose enum to get /// An enumerable of the values of the enum, in declaration order. public static T[] GetValues() where T : struct, Enum { - #if NET6_0_OR_GREATER +#if NET6_0_OR_GREATER return Enum.GetValues(); - #else +#else return (T[]) Enum.GetValues(typeof(T)); - #endif +#endif } /// diff --git a/Sandbox/GameImpl.cs b/Sandbox/GameImpl.cs index 962fd9b..c746e4d 100644 --- a/Sandbox/GameImpl.cs +++ b/Sandbox/GameImpl.cs @@ -399,7 +399,7 @@ public class GameImpl : MlemGame { Console.WriteLine("Down: " + string.Join(", ", Input.InputsDown));*/ if (MlemGame.Input.InputsPressed.Length > 0) Console.WriteLine("Pressed: " + string.Join(", ", MlemGame.Input.InputsPressed)); - MlemGame.Input.HandleKeyboardRepeats = false;/* + MlemGame.Input.HandleKeyboardRepeats = false; /* Console.WriteLine("Down time: " + MlemGame.Input.GetDownTime(Keys.A)); Console.WriteLine("Time since press: " + MlemGame.Input.GetTimeSincePress(Keys.A));*/ Console.WriteLine("Up time: " + MlemGame.Input.GetUpTime(Keys.A)); diff --git a/Tests/CameraTests.cs b/Tests/CameraTests.cs index f1eddc0..1e81ad9 100644 --- a/Tests/CameraTests.cs +++ b/Tests/CameraTests.cs @@ -2,7 +2,7 @@ using MLEM.Cameras; using NUnit.Framework; -namespace Tests; +namespace Tests; public class CameraTests { diff --git a/Tests/CollectionTests.cs b/Tests/CollectionTests.cs index 86752a2..67b08d5 100644 --- a/Tests/CollectionTests.cs +++ b/Tests/CollectionTests.cs @@ -1,7 +1,7 @@ using MLEM.Extensions; using NUnit.Framework; -namespace Tests; +namespace Tests; public class CollectionTests { diff --git a/Tests/DataTextureAtlasTests.cs b/Tests/DataTextureAtlasTests.cs index b9488f5..9a6437c 100644 --- a/Tests/DataTextureAtlasTests.cs +++ b/Tests/DataTextureAtlasTests.cs @@ -5,7 +5,7 @@ using MLEM.Data; using MLEM.Textures; using NUnit.Framework; -namespace Tests; +namespace Tests; public class TestDataTextureAtlas { diff --git a/Tests/DirectionTests.cs b/Tests/DirectionTests.cs index 37a5043..43f8ffc 100644 --- a/Tests/DirectionTests.cs +++ b/Tests/DirectionTests.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework; using MLEM.Misc; using NUnit.Framework; -namespace Tests; +namespace Tests; public class DirectionTests { diff --git a/Tests/KeybindTests.cs b/Tests/KeybindTests.cs index aa7731b..4585897 100644 --- a/Tests/KeybindTests.cs +++ b/Tests/KeybindTests.cs @@ -2,7 +2,7 @@ using MLEM.Input; using NUnit.Framework; -namespace Tests; +namespace Tests; public class KeybindTests { diff --git a/Tests/NumberTests.cs b/Tests/NumberTests.cs index 8251e1f..8a9cb42 100644 --- a/Tests/NumberTests.cs +++ b/Tests/NumberTests.cs @@ -73,7 +73,7 @@ public class NumberTests { Assert.AreEqual(penetration, 0); } - #if !FNA +#if !FNA [Test] public void TestRangePercentage() { Assert.AreEqual(0.5F, new Range(1, 7).GetPercentage(4)); @@ -95,6 +95,6 @@ public class NumberTests { Assert.AreEqual(11, new Range(8, 10).FromPercentage(1.5F)); Assert.AreEqual(7, new Range(8, 10).FromPercentage(-0.5F)); } - #endif +#endif } diff --git a/Tests/PathfindingTests.cs b/Tests/PathfindingTests.cs index ffc74d6..436d1e4 100644 --- a/Tests/PathfindingTests.cs +++ b/Tests/PathfindingTests.cs @@ -4,7 +4,7 @@ using Microsoft.Xna.Framework; using MLEM.Pathfinding; using NUnit.Framework; -namespace Tests; +namespace Tests; public class PathfindingTests { diff --git a/Tests/TestGame.cs b/Tests/TestGame.cs index fb6e13c..cf68c60 100644 --- a/Tests/TestGame.cs +++ b/Tests/TestGame.cs @@ -3,7 +3,7 @@ using MLEM.Data.Content; using MLEM.Font; using MLEM.Startup; -namespace Tests; +namespace Tests; public class TestGame : MlemGame { diff --git a/Tests/TexturePackerTests.cs b/Tests/TexturePackerTests.cs index db7139c..75a59c3 100644 --- a/Tests/TexturePackerTests.cs +++ b/Tests/TexturePackerTests.cs @@ -4,7 +4,7 @@ using MLEM.Data; using MLEM.Textures; using NUnit.Framework; -namespace Tests; +namespace Tests; public class TexturePackerTests { diff --git a/Tests/UiTests.cs b/Tests/UiTests.cs index 03564c6..12af85c 100644 --- a/Tests/UiTests.cs +++ b/Tests/UiTests.cs @@ -8,7 +8,7 @@ using MLEM.Ui.Elements; using MLEM.Ui.Style; using NUnit.Framework; -namespace Tests; +namespace Tests; public class UiTests {