From b46eed774a8816f2795c06ee0c2fe08e97c81229 Mon Sep 17 00:00:00 2001 From: Daniel Cronqvist Date: Sat, 24 Aug 2024 22:06:14 +0200 Subject: [PATCH] More property changes --- src/DotTiled.Tests/Serialization/TestData.cs | 16 ++++++++-------- .../map-with-custom-type-props.cs | 2 +- .../Serialization/Tmj/TmjMapReaderTests.cs | 2 +- .../Serialization/Tmx/TmxMapReaderTests.cs | 2 +- src/DotTiled/Model/Properties/ClassProperty.cs | 12 +++++++++++- .../CustomTypes/CustomClassDefinition.cs | 11 ++++++++++- .../CustomTypes/CustomEnumDefinition.cs | 8 +++++++- .../CustomTypes/CustomTypeDefinition.cs | 4 ++-- src/DotTiled/Model/Properties/IHasProperties.cs | 17 +++++++++++++++-- .../Serialization/Tmj/TjTemplateReader.cs | 4 ++-- src/DotTiled/Serialization/Tmj/Tmj.Group.cs | 2 +- .../Serialization/Tmj/Tmj.ImageLayer.cs | 2 +- src/DotTiled/Serialization/Tmj/Tmj.Layer.cs | 2 +- src/DotTiled/Serialization/Tmj/Tmj.Map.cs | 2 +- .../Serialization/Tmj/Tmj.ObjectLayer.cs | 4 ++-- .../Serialization/Tmj/Tmj.Properties.cs | 8 ++++---- src/DotTiled/Serialization/Tmj/Tmj.Template.cs | 2 +- src/DotTiled/Serialization/Tmj/Tmj.TileLayer.cs | 2 +- src/DotTiled/Serialization/Tmj/Tmj.Tileset.cs | 8 ++++---- src/DotTiled/Serialization/Tmj/TmjMapReader.cs | 4 ++-- .../Serialization/Tmj/TsjTilesetReader.cs | 4 ++-- src/DotTiled/Serialization/Tmx/Tmx.Map.cs | 2 +- .../Serialization/Tmx/Tmx.ObjectLayer.cs | 6 +++--- .../Serialization/Tmx/Tmx.Properties.cs | 6 +++--- src/DotTiled/Serialization/Tmx/Tmx.TileLayer.cs | 6 +++--- src/DotTiled/Serialization/Tmx/Tmx.Tileset.cs | 10 +++++----- src/DotTiled/Serialization/Tmx/TmxMapReader.cs | 4 ++-- .../Serialization/Tmx/TsxTilesetReader.cs | 4 ++-- .../Serialization/Tmx/TxTemplateReader.cs | 4 ++-- 29 files changed, 99 insertions(+), 61 deletions(-) diff --git a/src/DotTiled.Tests/Serialization/TestData.cs b/src/DotTiled.Tests/Serialization/TestData.cs index f6e49b5..b007913 100644 --- a/src/DotTiled.Tests/Serialization/TestData.cs +++ b/src/DotTiled.Tests/Serialization/TestData.cs @@ -32,14 +32,14 @@ public static partial class TestData public static IEnumerable MapTests => [ - ["Serialization/TestData/Map/default_map/default-map", (string f) => DefaultMap(), Array.Empty()], - ["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => MapWithCommonProps(), Array.Empty()], + ["Serialization/TestData/Map/default_map/default-map", (string f) => DefaultMap(), Array.Empty()], + ["Serialization/TestData/Map/map_with_common_props/map-with-common-props", (string f) => MapWithCommonProps(), Array.Empty()], ["Serialization/TestData/Map/map_with_custom_type_props/map-with-custom-type-props", (string f) => MapWithCustomTypeProps(), MapWithCustomTypePropsCustomTypeDefinitions()], - ["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => MapWithEmbeddedTileset(), Array.Empty()], - ["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => MapWithExternalTileset(f), Array.Empty()], - ["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => MapWithFlippingFlags(f), Array.Empty()], - ["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => MapExternalTilesetMulti(f), Array.Empty()], - ["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => MapExternalTilesetWangset(f), Array.Empty()], - ["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => MapWithManyLayers(f), Array.Empty()], + ["Serialization/TestData/Map/map_with_embedded_tileset/map-with-embedded-tileset", (string f) => MapWithEmbeddedTileset(), Array.Empty()], + ["Serialization/TestData/Map/map_with_external_tileset/map-with-external-tileset", (string f) => MapWithExternalTileset(f), Array.Empty()], + ["Serialization/TestData/Map/map_with_flippingflags/map-with-flippingflags", (string f) => MapWithFlippingFlags(f), Array.Empty()], + ["Serialization/TestData/Map/map_external_tileset_multi/map-external-tileset-multi", (string f) => MapExternalTilesetMulti(f), Array.Empty()], + ["Serialization/TestData/Map/map_external_tileset_wangset/map-external-tileset-wangset", (string f) => MapExternalTilesetWangset(f), Array.Empty()], + ["Serialization/TestData/Map/map_with_many_layers/map-with-many-layers", (string f) => MapWithManyLayers(f), Array.Empty()], ]; } diff --git a/src/DotTiled.Tests/Serialization/TestData/Map/map-with-custom-type-props/map-with-custom-type-props.cs b/src/DotTiled.Tests/Serialization/TestData/Map/map-with-custom-type-props/map-with-custom-type-props.cs index 2c79478..ea0575e 100644 --- a/src/DotTiled.Tests/Serialization/TestData/Map/map-with-custom-type-props/map-with-custom-type-props.cs +++ b/src/DotTiled.Tests/Serialization/TestData/Map/map-with-custom-type-props/map-with-custom-type-props.cs @@ -74,7 +74,7 @@ public partial class TestData }; // This comes from map-with-custom-type-props/propertytypes.json - public static IReadOnlyCollection MapWithCustomTypePropsCustomTypeDefinitions() => [ + public static IReadOnlyCollection MapWithCustomTypePropsCustomTypeDefinitions() => [ new CustomClassDefinition { Name = "CustomClass", diff --git a/src/DotTiled.Tests/Serialization/Tmj/TmjMapReaderTests.cs b/src/DotTiled.Tests/Serialization/Tmj/TmjMapReaderTests.cs index bdd19e8..3fe6843 100644 --- a/src/DotTiled.Tests/Serialization/Tmj/TmjMapReaderTests.cs +++ b/src/DotTiled.Tests/Serialization/Tmj/TmjMapReaderTests.cs @@ -11,7 +11,7 @@ public partial class TmjMapReaderTests public void TmxMapReaderReadMap_ValidTmjExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected( string testDataFile, Func expectedMap, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Arrange testDataFile += ".tmj"; diff --git a/src/DotTiled.Tests/Serialization/Tmx/TmxMapReaderTests.cs b/src/DotTiled.Tests/Serialization/Tmx/TmxMapReaderTests.cs index ee74718..fb825ed 100644 --- a/src/DotTiled.Tests/Serialization/Tmx/TmxMapReaderTests.cs +++ b/src/DotTiled.Tests/Serialization/Tmx/TmxMapReaderTests.cs @@ -11,7 +11,7 @@ public partial class TmxMapReaderTests public void TmxMapReaderReadMap_ValidXmlExternalTilesetsAndTemplates_ReturnsMapThatEqualsExpected( string testDataFile, Func expectedMap, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Arrange testDataFile += ".tmx"; diff --git a/src/DotTiled/Model/Properties/ClassProperty.cs b/src/DotTiled/Model/Properties/ClassProperty.cs index eb7efce..5c9d6a5 100644 --- a/src/DotTiled/Model/Properties/ClassProperty.cs +++ b/src/DotTiled/Model/Properties/ClassProperty.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -38,7 +39,16 @@ public class ClassProperty : IHasProperties, IProperty> public IList GetProperties() => Value; /// - public T GetProperty(string name) where T : IProperty => throw new System.NotImplementedException(); + public T GetProperty(string name) where T : IProperty + { + var property = Value.FirstOrDefault(_properties => _properties.Name == name) ?? throw new InvalidOperationException($"Property '{name}' not found."); + if (property is T prop) + { + return prop; + } + + throw new InvalidOperationException($"Property '{name}' is not of type '{typeof(T).Name}'."); + } /// public bool TryGetProperty(string name, [NotNullWhen(true)] out T? property) where T : IProperty diff --git a/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs b/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs index b5aa0ec..313081f 100644 --- a/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs +++ b/src/DotTiled/Model/Properties/CustomTypes/CustomClassDefinition.cs @@ -65,8 +65,14 @@ public enum CustomClassUseAs /// Represents a custom class definition in Tiled. Refer to the /// documentation of custom types to understand how they work. /// -public class CustomClassDefinition : CustomTypeDefinition +public class CustomClassDefinition : HasPropertiesBase, ICustomTypeDefinition { + /// + public uint ID { get; set; } + + /// + public required string Name { get; set; } + /// /// The color of the custom class inside the Tiled editor. /// @@ -86,4 +92,7 @@ public class CustomClassDefinition : CustomTypeDefinition /// The members of the custom class, with their names, types and default values. /// public List Members { get; set; } = []; + + /// + public override IList GetProperties() => Members; } diff --git a/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs b/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs index ee40be0..60b7f5b 100644 --- a/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs +++ b/src/DotTiled/Model/Properties/CustomTypes/CustomEnumDefinition.cs @@ -22,8 +22,14 @@ public enum CustomEnumStorageType /// Represents a custom enum definition in Tiled. Refer to the /// documentation of custom types to understand how they work. /// -public class CustomEnumDefinition : CustomTypeDefinition +public class CustomEnumDefinition : ICustomTypeDefinition { + /// + public uint ID { get; set; } + + /// + public required string Name { get; set; } + /// /// The storage type of the custom enum. /// diff --git a/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs b/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs index 3a91b0a..1e595cc 100644 --- a/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs +++ b/src/DotTiled/Model/Properties/CustomTypes/CustomTypeDefinition.cs @@ -3,7 +3,7 @@ namespace DotTiled.Model; /// /// Base class for custom type definitions. /// -public abstract class CustomTypeDefinition +public interface ICustomTypeDefinition { /// /// The ID of the custom type. @@ -13,5 +13,5 @@ public abstract class CustomTypeDefinition /// /// The name of the custom type. /// - public string Name { get; set; } = ""; + public string Name { get; set; } } diff --git a/src/DotTiled/Model/Properties/IHasProperties.cs b/src/DotTiled/Model/Properties/IHasProperties.cs index 28b8532..1b124a9 100644 --- a/src/DotTiled/Model/Properties/IHasProperties.cs +++ b/src/DotTiled/Model/Properties/IHasProperties.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -33,7 +34,7 @@ public interface IHasProperties } /// -/// Base class for objects that have properties attached to them. +/// Interface for objects that have properties attached to them. /// public abstract class HasPropertiesBase : IHasProperties { @@ -41,7 +42,19 @@ public abstract class HasPropertiesBase : IHasProperties public abstract IList GetProperties(); /// - public T GetProperty(string name) where T : IProperty => throw new System.NotImplementedException(); + /// Thrown when a property with the specified name is not found. + /// Thrown when a property with the specified name is not of the specified type. + public T GetProperty(string name) where T : IProperty + { + var properties = GetProperties(); + var property = properties.FirstOrDefault(_properties => _properties.Name == name) ?? throw new KeyNotFoundException($"Property '{name}' not found."); + if (property is T prop) + { + return prop; + } + + throw new InvalidCastException($"Property '{name}' is not of type '{typeof(T).Name}'."); + } /// public bool TryGetProperty(string name, [NotNullWhen(true)] out T? property) where T : IProperty diff --git a/src/DotTiled/Serialization/Tmj/TjTemplateReader.cs b/src/DotTiled/Serialization/Tmj/TjTemplateReader.cs index 3a66f1b..c4ada75 100644 --- a/src/DotTiled/Serialization/Tmj/TjTemplateReader.cs +++ b/src/DotTiled/Serialization/Tmj/TjTemplateReader.cs @@ -16,7 +16,7 @@ public class TjTemplateReader : ITemplateReader private readonly string _jsonString; private bool disposedValue; - private readonly IReadOnlyCollection _customTypeDefinitions; + private readonly IReadOnlyCollection _customTypeDefinitions; /// /// Constructs a new . @@ -30,7 +30,7 @@ public class TjTemplateReader : ITemplateReader string jsonString, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { _jsonString = jsonString ?? throw new ArgumentNullException(nameof(jsonString)); _externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver)); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Group.cs b/src/DotTiled/Serialization/Tmj/Tmj.Group.cs index 0885167..ae44a75 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.Group.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.Group.cs @@ -11,7 +11,7 @@ internal partial class Tmj internal static Group ReadGroup( JsonElement element, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var id = element.GetRequiredProperty("id"); var name = element.GetRequiredProperty("name"); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.ImageLayer.cs b/src/DotTiled/Serialization/Tmj/Tmj.ImageLayer.cs index 794f2b5..bbbb151 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.ImageLayer.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.ImageLayer.cs @@ -9,7 +9,7 @@ internal partial class Tmj { internal static ImageLayer ReadImageLayer( JsonElement element, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var id = element.GetRequiredProperty("id"); var name = element.GetRequiredProperty("name"); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Layer.cs b/src/DotTiled/Serialization/Tmj/Tmj.Layer.cs index b9f8de0..aeef011 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.Layer.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.Layer.cs @@ -10,7 +10,7 @@ internal partial class Tmj internal static BaseLayer ReadLayer( JsonElement element, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var type = element.GetRequiredProperty("type"); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Map.cs b/src/DotTiled/Serialization/Tmj/Tmj.Map.cs index dd1a012..cdde458 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.Map.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.Map.cs @@ -12,7 +12,7 @@ internal partial class Tmj JsonElement element, Func? externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var version = element.GetRequiredProperty("version"); var tiledVersion = element.GetRequiredProperty("tiledversion"); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs b/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs index 6775389..75d5ee0 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.ObjectLayer.cs @@ -12,7 +12,7 @@ internal partial class Tmj internal static ObjectLayer ReadObjectLayer( JsonElement element, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var id = element.GetRequiredProperty("id"); var name = element.GetRequiredProperty("name"); @@ -66,7 +66,7 @@ internal partial class Tmj internal static Model.Object ReadObject( JsonElement element, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { uint? idDefault = null; string nameDefault = ""; diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Properties.cs b/src/DotTiled/Serialization/Tmj/Tmj.Properties.cs index 5b25429..caa5fbe 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.Properties.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.Properties.cs @@ -10,7 +10,7 @@ internal partial class Tmj { internal static Dictionary ReadProperties( JsonElement element, - IReadOnlyCollection customTypeDefinitions) => + IReadOnlyCollection customTypeDefinitions) => element.GetValueAsList(e => { var name = e.GetRequiredProperty("name"); @@ -45,7 +45,7 @@ internal partial class Tmj internal static List ReadPropertiesList( JsonElement element, - IReadOnlyCollection customTypeDefinitions) => + IReadOnlyCollection customTypeDefinitions) => element.GetValueAsList(e => { var name = e.GetRequiredProperty("name"); @@ -80,7 +80,7 @@ internal partial class Tmj internal static ClassProperty ReadClassProperty( JsonElement element, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var name = element.GetRequiredProperty("name"); var propertyType = element.GetRequiredProperty("propertytype"); @@ -108,7 +108,7 @@ internal partial class Tmj internal static List ReadCustomClassProperties( JsonElement element, CustomClassDefinition customClassDefinition, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { List resultingProps = Helpers.CreateInstanceOfCustomClass(customClassDefinition); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Template.cs b/src/DotTiled/Serialization/Tmj/Tmj.Template.cs index 3746b76..71ba1e7 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.Template.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.Template.cs @@ -11,7 +11,7 @@ internal partial class Tmj JsonElement element, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var type = element.GetRequiredProperty("type"); var tileset = element.GetOptionalPropertyCustom("tileset", el => ReadTileset(el, externalTilesetResolver, externalTemplateResolver, customTypeDefinitions), null); diff --git a/src/DotTiled/Serialization/Tmj/Tmj.TileLayer.cs b/src/DotTiled/Serialization/Tmj/Tmj.TileLayer.cs index 353f7fd..cdda654 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.TileLayer.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.TileLayer.cs @@ -9,7 +9,7 @@ internal partial class Tmj { internal static TileLayer ReadTileLayer( JsonElement element, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var compression = element.GetOptionalPropertyParseable("compression", s => s switch { diff --git a/src/DotTiled/Serialization/Tmj/Tmj.Tileset.cs b/src/DotTiled/Serialization/Tmj/Tmj.Tileset.cs index e0e2bd2..7f3d6be 100644 --- a/src/DotTiled/Serialization/Tmj/Tmj.Tileset.cs +++ b/src/DotTiled/Serialization/Tmj/Tmj.Tileset.cs @@ -12,7 +12,7 @@ internal partial class Tmj JsonElement element, Func? externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var backgroundColor = element.GetOptionalPropertyParseable("backgroundcolor", s => Color.Parse(s, CultureInfo.InvariantCulture), null); var @class = element.GetOptionalProperty("class", ""); @@ -162,7 +162,7 @@ internal partial class Tmj internal static List ReadTiles( JsonElement element, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) => + IReadOnlyCollection customTypeDefinitions) => element.GetValueAsList(e => { var animation = e.GetOptionalPropertyCustom?>("animation", e => e.GetValueAsList(ReadFrame), null); @@ -218,7 +218,7 @@ internal partial class Tmj internal static Wangset ReadWangset( JsonElement element, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var @clalss = element.GetOptionalProperty("class", ""); var colors = element.GetOptionalPropertyCustom>("colors", e => e.GetValueAsList(el => ReadWangColor(el, customTypeDefinitions)), []); @@ -241,7 +241,7 @@ internal partial class Tmj internal static WangColor ReadWangColor( JsonElement element, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var @class = element.GetOptionalProperty("class", ""); var color = element.GetRequiredPropertyParseable("color", s => Color.Parse(s, CultureInfo.InvariantCulture)); diff --git a/src/DotTiled/Serialization/Tmj/TmjMapReader.cs b/src/DotTiled/Serialization/Tmj/TmjMapReader.cs index c26311b..1d277b1 100644 --- a/src/DotTiled/Serialization/Tmj/TmjMapReader.cs +++ b/src/DotTiled/Serialization/Tmj/TmjMapReader.cs @@ -17,7 +17,7 @@ public class TmjMapReader : IMapReader private readonly string _jsonString; private bool disposedValue; - private readonly IReadOnlyCollection _customTypeDefinitions; + private readonly IReadOnlyCollection _customTypeDefinitions; /// /// Constructs a new . @@ -31,7 +31,7 @@ public class TmjMapReader : IMapReader string jsonString, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { _jsonString = jsonString ?? throw new ArgumentNullException(nameof(jsonString)); _externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver)); diff --git a/src/DotTiled/Serialization/Tmj/TsjTilesetReader.cs b/src/DotTiled/Serialization/Tmj/TsjTilesetReader.cs index aca5556..dde9075 100644 --- a/src/DotTiled/Serialization/Tmj/TsjTilesetReader.cs +++ b/src/DotTiled/Serialization/Tmj/TsjTilesetReader.cs @@ -15,7 +15,7 @@ public class TsjTilesetReader : ITilesetReader private readonly string _jsonString; private bool disposedValue; - private readonly IReadOnlyCollection _customTypeDefinitions; + private readonly IReadOnlyCollection _customTypeDefinitions; /// /// Constructs a new . @@ -27,7 +27,7 @@ public class TsjTilesetReader : ITilesetReader public TsjTilesetReader( string jsonString, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { _jsonString = jsonString ?? throw new ArgumentNullException(nameof(jsonString)); _externalTemplateResolver = externalTemplateResolver ?? throw new ArgumentNullException(nameof(externalTemplateResolver)); diff --git a/src/DotTiled/Serialization/Tmx/Tmx.Map.cs b/src/DotTiled/Serialization/Tmx/Tmx.Map.cs index 6dd5ea5..cabfdcc 100644 --- a/src/DotTiled/Serialization/Tmx/Tmx.Map.cs +++ b/src/DotTiled/Serialization/Tmx/Tmx.Map.cs @@ -13,7 +13,7 @@ internal partial class Tmx XmlReader reader, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var version = reader.GetRequiredAttribute("version"); diff --git a/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs b/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs index 7a375d9..4929ede 100644 --- a/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs +++ b/src/DotTiled/Serialization/Tmx/Tmx.ObjectLayer.cs @@ -13,7 +13,7 @@ internal partial class Tmx internal static ObjectLayer ReadObjectLayer( XmlReader reader, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var id = reader.GetRequiredAttributeParseable("id"); @@ -75,7 +75,7 @@ internal partial class Tmx internal static Model.Object ReadObject( XmlReader reader, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var template = reader.GetOptionalAttribute("template"); @@ -308,7 +308,7 @@ internal partial class Tmx XmlReader reader, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // No attributes diff --git a/src/DotTiled/Serialization/Tmx/Tmx.Properties.cs b/src/DotTiled/Serialization/Tmx/Tmx.Properties.cs index 98ee546..f641c4f 100644 --- a/src/DotTiled/Serialization/Tmx/Tmx.Properties.cs +++ b/src/DotTiled/Serialization/Tmx/Tmx.Properties.cs @@ -9,7 +9,7 @@ internal partial class Tmx { internal static Dictionary ReadProperties( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { return reader.ReadList("properties", "property", (r) => { @@ -45,7 +45,7 @@ internal partial class Tmx internal static List ReadPropertiesList( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { return reader.ReadList("properties", "property", (r) => { @@ -81,7 +81,7 @@ internal partial class Tmx internal static ClassProperty ReadClassProperty( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var name = reader.GetRequiredAttribute("name"); var propertyType = reader.GetRequiredAttribute("propertytype"); diff --git a/src/DotTiled/Serialization/Tmx/Tmx.TileLayer.cs b/src/DotTiled/Serialization/Tmx/Tmx.TileLayer.cs index 8b972a3..320019d 100644 --- a/src/DotTiled/Serialization/Tmx/Tmx.TileLayer.cs +++ b/src/DotTiled/Serialization/Tmx/Tmx.TileLayer.cs @@ -11,7 +11,7 @@ internal partial class Tmx internal static TileLayer ReadTileLayer( XmlReader reader, bool dataUsesChunks, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var id = reader.GetRequiredAttributeParseable("id"); var name = reader.GetOptionalAttribute("name") ?? ""; @@ -61,7 +61,7 @@ internal partial class Tmx internal static ImageLayer ReadImageLayer( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var id = reader.GetRequiredAttributeParseable("id"); var name = reader.GetOptionalAttribute("name") ?? ""; @@ -112,7 +112,7 @@ internal partial class Tmx internal static Group ReadGroup( XmlReader reader, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { var id = reader.GetRequiredAttributeParseable("id"); var name = reader.GetOptionalAttribute("name") ?? ""; diff --git a/src/DotTiled/Serialization/Tmx/Tmx.Tileset.cs b/src/DotTiled/Serialization/Tmx/Tmx.Tileset.cs index 198f32d..6fb1ff5 100644 --- a/src/DotTiled/Serialization/Tmx/Tmx.Tileset.cs +++ b/src/DotTiled/Serialization/Tmx/Tmx.Tileset.cs @@ -14,7 +14,7 @@ internal partial class Tmx XmlReader reader, Func? externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var version = reader.GetOptionalAttribute("version"); @@ -207,7 +207,7 @@ internal partial class Tmx internal static Tile ReadTile( XmlReader reader, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var id = reader.GetRequiredAttributeParseable("id"); @@ -256,12 +256,12 @@ internal partial class Tmx internal static List ReadWangsets( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) => + IReadOnlyCollection customTypeDefinitions) => reader.ReadList("wangsets", "wangset", r => ReadWangset(r, customTypeDefinitions)); internal static Wangset ReadWangset( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var name = reader.GetRequiredAttribute("name"); @@ -297,7 +297,7 @@ internal partial class Tmx internal static WangColor ReadWangColor( XmlReader reader, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { // Attributes var name = reader.GetRequiredAttribute("name"); diff --git a/src/DotTiled/Serialization/Tmx/TmxMapReader.cs b/src/DotTiled/Serialization/Tmx/TmxMapReader.cs index 5a99ff6..279c83d 100644 --- a/src/DotTiled/Serialization/Tmx/TmxMapReader.cs +++ b/src/DotTiled/Serialization/Tmx/TmxMapReader.cs @@ -17,7 +17,7 @@ public class TmxMapReader : IMapReader private readonly XmlReader _reader; private bool disposedValue; - private readonly IReadOnlyCollection _customTypeDefinitions; + private readonly IReadOnlyCollection _customTypeDefinitions; /// /// Constructs a new . @@ -31,7 +31,7 @@ public class TmxMapReader : IMapReader XmlReader reader, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { _reader = reader ?? throw new ArgumentNullException(nameof(reader)); _externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver)); diff --git a/src/DotTiled/Serialization/Tmx/TsxTilesetReader.cs b/src/DotTiled/Serialization/Tmx/TsxTilesetReader.cs index 0034150..0b69d4c 100644 --- a/src/DotTiled/Serialization/Tmx/TsxTilesetReader.cs +++ b/src/DotTiled/Serialization/Tmx/TsxTilesetReader.cs @@ -16,7 +16,7 @@ public class TsxTilesetReader : ITilesetReader private readonly XmlReader _reader; private bool disposedValue; - private readonly IReadOnlyCollection _customTypeDefinitions; + private readonly IReadOnlyCollection _customTypeDefinitions; /// /// Constructs a new . @@ -28,7 +28,7 @@ public class TsxTilesetReader : ITilesetReader public TsxTilesetReader( XmlReader reader, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { _reader = reader ?? throw new ArgumentNullException(nameof(reader)); _externalTemplateResolver = externalTemplateResolver ?? throw new ArgumentNullException(nameof(externalTemplateResolver)); diff --git a/src/DotTiled/Serialization/Tmx/TxTemplateReader.cs b/src/DotTiled/Serialization/Tmx/TxTemplateReader.cs index fbaf85c..ed7ba8e 100644 --- a/src/DotTiled/Serialization/Tmx/TxTemplateReader.cs +++ b/src/DotTiled/Serialization/Tmx/TxTemplateReader.cs @@ -17,7 +17,7 @@ public class TxTemplateReader : ITemplateReader private readonly XmlReader _reader; private bool disposedValue; - private readonly IReadOnlyCollection _customTypeDefinitions; + private readonly IReadOnlyCollection _customTypeDefinitions; /// /// Constructs a new . @@ -31,7 +31,7 @@ public class TxTemplateReader : ITemplateReader XmlReader reader, Func externalTilesetResolver, Func externalTemplateResolver, - IReadOnlyCollection customTypeDefinitions) + IReadOnlyCollection customTypeDefinitions) { _reader = reader ?? throw new ArgumentNullException(nameof(reader)); _externalTilesetResolver = externalTilesetResolver ?? throw new ArgumentNullException(nameof(externalTilesetResolver));