Skip to content

Commit

Permalink
net8
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragath authored and Ragath committed Aug 18, 2024
1 parent 89e9bf9 commit 9de2ba8
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 55 deletions.
10 changes: 5 additions & 5 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions TiledLib.Pipeline/TiledLib.Pipeline.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -24,10 +24,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MonoGame.Framework.Content.Pipeline" Version="3.8.1.303">
<PackageReference Include="MonoGame.Framework.Content.Pipeline" Version="3.8.2.1105">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303">
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
13 changes: 8 additions & 5 deletions TiledLib.Tests/TiledLib.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions TiledLib.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@

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
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TiledLib.Pipeline", "TiledLib.Pipeline\TiledLib.Pipeline.csproj", "{8F4869B1-35A2-4EC7-86C5-D60143E3FC05}"
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
Expand Down
2 changes: 1 addition & 1 deletion TiledLib/Layer/BaseLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ public abstract class BaseLayer

[JsonPropertyName("properties")]
[JsonConverter(typeof(PropertiesConverter))]
public Dictionary<string, string> Properties { get; init; } = new Dictionary<string, string>();
public Dictionary<string, string> Properties { get; init; } = [];
}
8 changes: 3 additions & 5 deletions TiledLib/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -67,7 +65,7 @@ public class Map : IXmlSerializable

[JsonPropertyName("properties")]
[JsonConverter(typeof(PropertiesConverter))]
public Dictionary<string, string> Properties { get; init; } = new Dictionary<string, string>();
public Dictionary<string, string> Properties { get; init; } = [];

/// <summary>
/// Parses map from JSON stream
Expand Down
2 changes: 1 addition & 1 deletion TiledLib/Objects/BaseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class BaseObject

[JsonPropertyName("properties")]
[JsonConverter(typeof(PropertiesConverter))]
public Dictionary<string, string> Properties { get; init; } = new Dictionary<string, string>();
public Dictionary<string, string> Properties { get; init; } = [];

public BaseObject(Dictionary<string, string> properties) { Properties = properties; }
}
2 changes: 1 addition & 1 deletion TiledLib/Objects/EllipseObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace TiledLib.Objects;
public class EllipseObject : BaseObject, IXmlSerializable
{
public EllipseObject(Dictionary<string, string> properties) : base(properties) { }
public EllipseObject() : base(new Dictionary<string, string>()) { }
public EllipseObject() : base([]) { }

[JsonPropertyName("ellipse")]
public bool IsEllipse { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion TiledLib/Objects/PointObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
public class PointObject : BaseObject
{
internal PointObject(Dictionary<string, string> properties) : base(properties) { }
public PointObject() : base(new Dictionary<string, string>()) { }
public PointObject() : base([]) { }
}
2 changes: 1 addition & 1 deletion TiledLib/Objects/PolyLineObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class PolyLineObject : BaseObject
{
internal PolyLineObject(Dictionary<string, string> properties) : base(properties) { }
public PolyLineObject() : base(new Dictionary<string, string>()) { }
public PolyLineObject() : base([]) { }

public Position[] Polyline { get; set; }
}
2 changes: 1 addition & 1 deletion TiledLib/Objects/PolygonObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class PolygonObject : BaseObject
{
internal PolygonObject(Dictionary<string, string> properties) : base(properties) { }
public PolygonObject() : base(new Dictionary<string, string>()) { }
public PolygonObject() : base([]) { }

public Position[] Polygon { get; set; }
}
2 changes: 1 addition & 1 deletion TiledLib/Objects/RectangleObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
public class RectangleObject : BaseObject
{
internal RectangleObject(Dictionary<string, string> properties) : base(properties) { }
public RectangleObject() : base(new Dictionary<string, string>()) { }
public RectangleObject() : base([]) { }
}
2 changes: 1 addition & 1 deletion TiledLib/Objects/TileObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class TileObject : BaseObject
{
internal TileObject(Dictionary<string, string> properties) : base(properties) { }
public TileObject() : base(new Dictionary<string, string>()) { }
public TileObject() : base([]) { }

[JsonPropertyName("gid")]
public int Gid { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion TiledLib/TiledLib.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions TiledLib/Tileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public class Tileset : ITileset, IXmlSerializable

[JsonPropertyName("properties")]
[JsonConverter(typeof(PropertiesConverter))]
public Dictionary<string, string> Properties { get; init; } = new Dictionary<string, string>();
public Dictionary<string, string> Properties { get; init; } = [];
[JsonPropertyName("tileproperties")]
public Dictionary<int, Dictionary<string, string>> TileProperties { get; init; } = new Dictionary<int, Dictionary<string, string>>();
public Dictionary<int, Dictionary<string, string>> TileProperties { get; init; } = [];



[JsonIgnore] //TODO: Add json support
public Dictionary<int, Frame[]> TileAnimations { get; init; } = new Dictionary<int, Frame[]>();
public Dictionary<int, Frame[]> TileAnimations { get; init; } = [];

public Tile this[uint gid]
{
Expand Down
32 changes: 12 additions & 20 deletions TiledLib/TmxMisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static void ReadTile(this XmlReader reader, Dictionary<int, Dictionary<string, s

var id = int.Parse(reader["id"]);
if (!tileProperties.TryGetValue(id, out var properties) || properties == null)
properties = tileProperties[id] = new Dictionary<string, string>();
properties = tileProperties[id] = [];

if (reader.IsEmptyElement)
{
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 9de2ba8

Please sign in to comment.