diff --git a/MLEM.Data/DynamicEnum.cs b/MLEM.Data/DynamicEnum.cs
index ff8e8dc..5f368f2 100644
--- a/MLEM.Data/DynamicEnum.cs
+++ b/MLEM.Data/DynamicEnum.cs
@@ -13,9 +13,6 @@ namespace MLEM.Data {
/// A dynamic enum uses as its underlying type, allowing for an arbitrary number of enum values to be created, even when a -like structure is used that would only allow for up to 64 values in a regular enum.
/// All enum operations including , , and are supported and can be implemented in derived classes using operator overloads.
/// To create a custom dynamic enum, simply create a class that extends . New values can then be added using , or .
- ///
- /// This class, and its entire concept, are extremely terrible. If you intend on using this, there's probably at least one better solution available.
- /// Though if, for some weird reason, you need a way to have more than 64 distinct flags, this is a pretty good solution.
///
///
/// To include enum-like operator overloads in a dynamic enum named MyEnum, the following code can be used:
diff --git a/MLEM.Ui/Parsers/UiParser.cs b/MLEM.Ui/Parsers/UiParser.cs
index f7024fb..85325aa 100644
--- a/MLEM.Ui/Parsers/UiParser.cs
+++ b/MLEM.Ui/Parsers/UiParser.cs
@@ -11,6 +11,7 @@ using MLEM.Ui.Style;
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
using System.Net.Http;
+
#else
using System.Net;
#endif
diff --git a/Sandbox/Sandbox.csproj b/Sandbox/Sandbox.csproj
index 896bff7..d179e28 100644
--- a/Sandbox/Sandbox.csproj
+++ b/Sandbox/Sandbox.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/Tests/CameraTests.cs b/Tests/CameraTests.cs
index 4d63bca..f1eddc0 100644
--- a/Tests/CameraTests.cs
+++ b/Tests/CameraTests.cs
@@ -2,29 +2,29 @@
using MLEM.Cameras;
using NUnit.Framework;
-namespace Tests {
- public class CameraTests {
+namespace Tests;
- private TestGame game;
+public class CameraTests {
- [SetUp]
- public void SetUp() {
- this.game = TestGame.Create();
- }
-
- [TearDown]
- public void TearDown() {
- this.game?.Dispose();
- }
-
- [Test]
- public void TestConversions([Range(-4, 4, 4F)] float x, [Range(-4, 4, 4F)] float y) {
- var camera = new Camera(this.game.GraphicsDevice);
- var pos = new Vector2(x, y);
- var cam = camera.ToCameraPos(pos);
- var ret = camera.ToWorldPos(cam);
- Assert.AreEqual(pos, ret);
- }
+ private TestGame game;
+ [SetUp]
+ public void SetUp() {
+ this.game = TestGame.Create();
}
+
+ [TearDown]
+ public void TearDown() {
+ this.game?.Dispose();
+ }
+
+ [Test]
+ public void TestConversions([Range(-4, 4, 4F)] float x, [Range(-4, 4, 4F)] float y) {
+ var camera = new Camera(this.game.GraphicsDevice);
+ var pos = new Vector2(x, y);
+ var cam = camera.ToCameraPos(pos);
+ var ret = camera.ToWorldPos(cam);
+ Assert.AreEqual(pos, ret);
+ }
+
}
diff --git a/Tests/CollectionTests.cs b/Tests/CollectionTests.cs
index 4b19198..86752a2 100644
--- a/Tests/CollectionTests.cs
+++ b/Tests/CollectionTests.cs
@@ -1,31 +1,31 @@
using MLEM.Extensions;
using NUnit.Framework;
-namespace Tests {
- public class CollectionTests {
+namespace Tests;
- [Test]
- public void TestCombinations() {
- var things = new[] {
- new[] {'1', '2', '3'},
- new[] {'A', 'B'},
- new[] {'+', '-'}
- };
+public class CollectionTests {
- var expected = new[] {
- new[] {'1', 'A', '+'}, new[] {'1', 'A', '-'}, new[] {'1', 'B', '+'}, new[] {'1', 'B', '-'},
- new[] {'2', 'A', '+'}, new[] {'2', 'A', '-'}, new[] {'2', 'B', '+'}, new[] {'2', 'B', '-'},
- new[] {'3', 'A', '+'}, new[] {'3', 'A', '-'}, new[] {'3', 'B', '+'}, new[] {'3', 'B', '-'}
- };
- Assert.AreEqual(things.Combinations(), expected);
+ [Test]
+ public void TestCombinations() {
+ var things = new[] {
+ new[] {'1', '2', '3'},
+ new[] {'A', 'B'},
+ new[] {'+', '-'}
+ };
- var indices = new[] {
- new[] {0, 0, 0}, new[] {0, 0, 1}, new[] {0, 1, 0}, new[] {0, 1, 1},
- new[] {1, 0, 0}, new[] {1, 0, 1}, new[] {1, 1, 0}, new[] {1, 1, 1},
- new[] {2, 0, 0}, new[] {2, 0, 1}, new[] {2, 1, 0}, new[] {2, 1, 1}
- };
- Assert.AreEqual(things.IndexCombinations(), indices);
- }
+ var expected = new[] {
+ new[] {'1', 'A', '+'}, new[] {'1', 'A', '-'}, new[] {'1', 'B', '+'}, new[] {'1', 'B', '-'},
+ new[] {'2', 'A', '+'}, new[] {'2', 'A', '-'}, new[] {'2', 'B', '+'}, new[] {'2', 'B', '-'},
+ new[] {'3', 'A', '+'}, new[] {'3', 'A', '-'}, new[] {'3', 'B', '+'}, new[] {'3', 'B', '-'}
+ };
+ Assert.AreEqual(things.Combinations(), expected);
+ var indices = new[] {
+ new[] {0, 0, 0}, new[] {0, 0, 1}, new[] {0, 1, 0}, new[] {0, 1, 1},
+ new[] {1, 0, 0}, new[] {1, 0, 1}, new[] {1, 1, 0}, new[] {1, 1, 1},
+ new[] {2, 0, 0}, new[] {2, 0, 1}, new[] {2, 1, 0}, new[] {2, 1, 1}
+ };
+ Assert.AreEqual(things.IndexCombinations(), indices);
}
+
}
diff --git a/Tests/DataTests.cs b/Tests/DataTests.cs
index d106d4c..b8fdc95 100644
--- a/Tests/DataTests.cs
+++ b/Tests/DataTests.cs
@@ -9,78 +9,78 @@ using Newtonsoft.Json;
using NUnit.Framework;
using Vector2 = Microsoft.Xna.Framework.Vector2;
-namespace Tests {
- public class DataTests {
+namespace Tests;
- private readonly TestObject testObject = new() {
- Vec = new Vector2(10, 20),
- Point = new Point(20, 30),
- Dir = Direction2.Left,
- OtherTest = new TestObject {
- Vec = new Vector2(70, 30),
- Dir = Direction2.Right
- }
- };
+public class DataTests {
- [Test]
- public void TestJsonSerializers() {
- var serializer = JsonConverters.AddAll(new JsonSerializer());
+ private readonly TestObject testObject = new() {
+ Vec = new Vector2(10, 20),
+ Point = new Point(20, 30),
+ Dir = Direction2.Left,
+ OtherTest = new TestObject {
+ Vec = new Vector2(70, 30),
+ Dir = Direction2.Right
+ }
+ };
- var writer = new StringWriter();
- serializer.Serialize(writer, this.testObject);
- var ret = writer.ToString();
+ [Test]
+ public void TestJsonSerializers() {
+ var serializer = JsonConverters.AddAll(new JsonSerializer());
- Assert.AreEqual(ret, "{\"Vec\":\"10 20\",\"Point\":\"20 30\",\"OtherTest\":{\"Vec\":\"70 30\",\"Point\":\"0 0\",\"OtherTest\":null,\"Dir\":\"Right\"},\"Dir\":\"Left\"}");
+ var writer = new StringWriter();
+ serializer.Serialize(writer, this.testObject);
+ var ret = writer.ToString();
- var read = serializer.Deserialize(new JsonTextReader(new StringReader(ret)));
- Assert.AreEqual(this.testObject, read);
+ Assert.AreEqual(ret, "{\"Vec\":\"10 20\",\"Point\":\"20 30\",\"OtherTest\":{\"Vec\":\"70 30\",\"Point\":\"0 0\",\"OtherTest\":null,\"Dir\":\"Right\"},\"Dir\":\"Left\"}");
+
+ var read = serializer.Deserialize(new JsonTextReader(new StringReader(ret)));
+ Assert.AreEqual(this.testObject, read);
+ }
+
+ [Test]
+ public void TestJsonTypeSafety() {
+ var serializer = new JsonSerializer {TypeNameHandling = TypeNameHandling.Auto};
+
+ // normal generic data holder should crush the time span down to a string due to its custom serializer
+ var data = new GenericDataHolder();
+ data.SetData("Time", TimeSpan.FromMinutes(5));
+ var read = DataTests.SerializeAndDeserialize(serializer, data);
+ Assert.IsNotInstanceOf(read.GetData