diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index efabe22..84ff03d 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,31 +3,31 @@ "isRoot": true, "tools": { "dotnet-mgcb": { - "version": "3.8.1.303", + "version": "3.8.2.1105", "commands": [ "mgcb" ] }, "dotnet-mgcb-editor": { - "version": "3.8.1.303", + "version": "3.8.2.1105", "commands": [ "mgcb-editor" ] }, "dotnet-mgcb-editor-linux": { - "version": "3.8.1.303", + "version": "3.8.2.1105", "commands": [ "mgcb-editor-linux" ] }, "dotnet-mgcb-editor-windows": { - "version": "3.8.1.303", + "version": "3.8.2.1105", "commands": [ "mgcb-editor-windows" ] }, "dotnet-mgcb-editor-mac": { - "version": "3.8.1.303", + "version": "3.8.2.1105", "commands": [ "mgcb-editor-mac" ] diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3d286e8..7c0ee54 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -34,13 +34,13 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Build - run: dotnet build -p:Version=$GITVERSION_NUGETVERSION + run: dotnet build --configuration Release -p:Version=$GITVERSION_NUGETVERSION - name: Test - run: dotnet test --no-build --verbosity normal + run: dotnet test --configuration Release --no-build --verbosity normal - name: Pack run: dotnet pack --no-build -o ./ -p:Version=$GITVERSION_NUGETVERSION diff --git a/TiledLib.Pipeline/TiledLib.Pipeline.csproj b/TiledLib.Pipeline/TiledLib.Pipeline.csproj index d6449da..8b18de5 100644 --- a/TiledLib.Pipeline/TiledLib.Pipeline.csproj +++ b/TiledLib.Pipeline/TiledLib.Pipeline.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 @@ -24,10 +24,10 @@ - + All - + All diff --git a/TiledLib.Tests/TiledLib.Tests.csproj b/TiledLib.Tests/TiledLib.Tests.csproj index b045b15..6dd0eaf 100644 --- a/TiledLib.Tests/TiledLib.Tests.csproj +++ b/TiledLib.Tests/TiledLib.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable enable @@ -9,10 +9,13 @@ - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/TiledLib.sln b/TiledLib.sln index f37452e..94368df 100644 --- a/TiledLib.sln +++ b/TiledLib.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29009.5 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.34928.147 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TiledLib", "TiledLib\TiledLib.csproj", "{39334840-001D-48E5-A13C-4A9CA6BAB142}" EndProject @@ -9,6 +9,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TiledLib.Pipeline", "TiledL EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TiledLib.Tests", "TiledLib.Tests\TiledLib.Tests.csproj", "{13A3D034-B392-4027-ADEE-8BE3AF17FEC5}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AF61C04A-6F22-49BE-B73C-C55CFC207962}" + ProjectSection(SolutionItems) = preProject + .config\dotnet-tools.json = .config\dotnet-tools.json + .github\workflows\dotnet.yml = .github\workflows\dotnet.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/TiledLib/Layer/BaseLayer.cs b/TiledLib/Layer/BaseLayer.cs index e6a4143..c944951 100644 --- a/TiledLib/Layer/BaseLayer.cs +++ b/TiledLib/Layer/BaseLayer.cs @@ -42,5 +42,5 @@ public abstract class BaseLayer [JsonPropertyName("properties")] [JsonConverter(typeof(PropertiesConverter))] - public Dictionary Properties { get; init; } = new Dictionary(); + public Dictionary Properties { get; init; } = []; } diff --git a/TiledLib/Map.cs b/TiledLib/Map.cs index 4daf7fa..a977bbe 100644 --- a/TiledLib/Map.cs +++ b/TiledLib/Map.cs @@ -9,17 +9,15 @@ namespace TiledLib; [XmlRoot("map")] public class Map : IXmlSerializable { - [Required] [JsonPropertyName("version")] [JsonConverter(typeof(VersionConverter))] - public string Version { get; set; } = "1.0"; + public required string Version { get; set; } = "1.0"; [JsonPropertyName("tiledversion")] public string TiledVersion { get; set; } - [Required] [JsonPropertyName("orientation")] - public Orientation Orientation { get; set; } + public required Orientation Orientation { get; set; } [JsonPropertyName("renderorder")] public RenderOrder RenderOrder { get; set; } @@ -67,7 +65,7 @@ public class Map : IXmlSerializable [JsonPropertyName("properties")] [JsonConverter(typeof(PropertiesConverter))] - public Dictionary Properties { get; init; } = new Dictionary(); + public Dictionary Properties { get; init; } = []; /// /// Parses map from JSON stream diff --git a/TiledLib/Objects/BaseObject.cs b/TiledLib/Objects/BaseObject.cs index 54667d5..9aa9080 100644 --- a/TiledLib/Objects/BaseObject.cs +++ b/TiledLib/Objects/BaseObject.cs @@ -27,7 +27,7 @@ public abstract class BaseObject [JsonPropertyName("properties")] [JsonConverter(typeof(PropertiesConverter))] - public Dictionary Properties { get; init; } = new Dictionary(); + public Dictionary Properties { get; init; } = []; public BaseObject(Dictionary properties) { Properties = properties; } } diff --git a/TiledLib/Objects/EllipseObject.cs b/TiledLib/Objects/EllipseObject.cs index 86f483a..c10d4ee 100644 --- a/TiledLib/Objects/EllipseObject.cs +++ b/TiledLib/Objects/EllipseObject.cs @@ -7,7 +7,7 @@ namespace TiledLib.Objects; public class EllipseObject : BaseObject, IXmlSerializable { public EllipseObject(Dictionary properties) : base(properties) { } - public EllipseObject() : base(new Dictionary()) { } + public EllipseObject() : base([]) { } [JsonPropertyName("ellipse")] public bool IsEllipse { get; set; } diff --git a/TiledLib/Objects/PointObject.cs b/TiledLib/Objects/PointObject.cs index 932d063..40638eb 100644 --- a/TiledLib/Objects/PointObject.cs +++ b/TiledLib/Objects/PointObject.cs @@ -3,5 +3,5 @@ public class PointObject : BaseObject { internal PointObject(Dictionary properties) : base(properties) { } - public PointObject() : base(new Dictionary()) { } + public PointObject() : base([]) { } } diff --git a/TiledLib/Objects/PolyLineObject.cs b/TiledLib/Objects/PolyLineObject.cs index 27168ca..5fe9459 100644 --- a/TiledLib/Objects/PolyLineObject.cs +++ b/TiledLib/Objects/PolyLineObject.cs @@ -3,7 +3,7 @@ public class PolyLineObject : BaseObject { internal PolyLineObject(Dictionary properties) : base(properties) { } - public PolyLineObject() : base(new Dictionary()) { } + public PolyLineObject() : base([]) { } public Position[] Polyline { get; set; } } diff --git a/TiledLib/Objects/PolygonObject.cs b/TiledLib/Objects/PolygonObject.cs index a9ce4cf..07f47d1 100644 --- a/TiledLib/Objects/PolygonObject.cs +++ b/TiledLib/Objects/PolygonObject.cs @@ -3,7 +3,7 @@ public class PolygonObject : BaseObject { internal PolygonObject(Dictionary properties) : base(properties) { } - public PolygonObject() : base(new Dictionary()) { } + public PolygonObject() : base([]) { } public Position[] Polygon { get; set; } } diff --git a/TiledLib/Objects/RectangleObject.cs b/TiledLib/Objects/RectangleObject.cs index e3b16bd..abe8ad2 100644 --- a/TiledLib/Objects/RectangleObject.cs +++ b/TiledLib/Objects/RectangleObject.cs @@ -3,5 +3,5 @@ public class RectangleObject : BaseObject { internal RectangleObject(Dictionary properties) : base(properties) { } - public RectangleObject() : base(new Dictionary()) { } + public RectangleObject() : base([]) { } } diff --git a/TiledLib/Objects/TileObject.cs b/TiledLib/Objects/TileObject.cs index dd188d1..f78d7ed 100644 --- a/TiledLib/Objects/TileObject.cs +++ b/TiledLib/Objects/TileObject.cs @@ -3,7 +3,7 @@ public class TileObject : BaseObject { internal TileObject(Dictionary properties) : base(properties) { } - public TileObject() : base(new Dictionary()) { } + public TileObject() : base([]) { } [JsonPropertyName("gid")] public int Gid { get; set; } diff --git a/TiledLib/TiledLib.csproj b/TiledLib/TiledLib.csproj index 47f1d65..a05f116 100644 --- a/TiledLib/TiledLib.csproj +++ b/TiledLib/TiledLib.csproj @@ -1,7 +1,7 @@  - net6.0;net7.0 + net8.0 diff --git a/TiledLib/Tileset.cs b/TiledLib/Tileset.cs index c2b3460..16a2150 100644 --- a/TiledLib/Tileset.cs +++ b/TiledLib/Tileset.cs @@ -37,14 +37,14 @@ public class Tileset : ITileset, IXmlSerializable [JsonPropertyName("properties")] [JsonConverter(typeof(PropertiesConverter))] - public Dictionary Properties { get; init; } = new Dictionary(); + public Dictionary Properties { get; init; } = []; [JsonPropertyName("tileproperties")] - public Dictionary> TileProperties { get; init; } = new Dictionary>(); + public Dictionary> TileProperties { get; init; } = []; [JsonIgnore] //TODO: Add json support - public Dictionary TileAnimations { get; init; } = new Dictionary(); + public Dictionary TileAnimations { get; init; } = []; public Tile this[uint gid] { diff --git a/TiledLib/TmxMisc.cs b/TiledLib/TmxMisc.cs index 5eae337..2fd8686 100644 --- a/TiledLib/TmxMisc.cs +++ b/TiledLib/TmxMisc.cs @@ -94,7 +94,7 @@ static void ReadTile(this XmlReader reader, Dictionary(); + properties = tileProperties[id] = []; if (reader.IsEmptyElement) { @@ -186,25 +186,18 @@ public static uint[] ReadData(this XmlReader reader, int count, out string encod encoding = reader["encoding"]; compression = reader["compression"]; - switch (encoding) + return encoding switch { - case "csv": - return reader.ReadCSV(count); - case "base64": - switch (compression) - { - case null: - return reader.ReadBase64(count); - case "gzip": - return reader.ReadBase64Decompress((stream, mode) => new Zlib.GZipStream(stream, mode), count); - case "zlib": - return reader.ReadBase64Decompress((stream, mode) => new Zlib.ZlibStream(stream, mode), count); - default: - throw new XmlException(compression); - } - default: - throw new NotImplementedException($"Encoding: {encoding}"); - } + "csv" => reader.ReadCSV(count), + "base64" => compression switch + { + null => reader.ReadBase64(count), + "gzip" => reader.ReadBase64Decompress((stream, mode) => new Zlib.GZipStream(stream, mode), count), + "zlib" => reader.ReadBase64Decompress((stream, mode) => new Zlib.ZlibStream(stream, mode), count), + _ => throw new XmlException(compression), + }, + _ => throw new NotImplementedException($"Encoding: {encoding}"), + }; } public static void WriteAttribute(this XmlWriter writer, string localName, int? value) @@ -214,7 +207,6 @@ public static void WriteAttribute(this XmlWriter writer, string localName, int? writer.WriteAttribute(localName, value.Value); } - public static void WriteAttribute(this XmlWriter writer, string localName, Orientation value) { switch (value)