From 4e273cd521c3757f5d7b774fedc09bd076914831 Mon Sep 17 00:00:00 2001 From: Daniel Cronqvist Date: Sat, 31 Aug 2024 19:59:20 +0200 Subject: [PATCH] Remove unecessary duplicate of API --- .../Properties/HasPropertiesBaseTests.cs | 12 ++++++------ src/DotTiled/Properties/IHasProperties.cs | 15 --------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/DotTiled.Tests/Properties/HasPropertiesBaseTests.cs b/src/DotTiled.Tests/Properties/HasPropertiesBaseTests.cs index ea7d375..8676156 100644 --- a/src/DotTiled.Tests/Properties/HasPropertiesBaseTests.cs +++ b/src/DotTiled.Tests/Properties/HasPropertiesBaseTests.cs @@ -36,7 +36,7 @@ public class HasPropertiesBaseTests var hasProperties = new TestHasProperties(props); // Act & Assert - _ = Assert.Throws(() => hasProperties.MapClassPropertyTo("ClassInObject")); + _ = Assert.Throws(() => hasProperties.GetProperty("ClassInObject").MapPropertiesTo()); } [Fact] @@ -49,7 +49,7 @@ public class HasPropertiesBaseTests var hasProperties = new TestHasProperties(props); // Act & Assert - _ = Assert.Throws(() => hasProperties.MapClassPropertyTo("ClassInObject")); + _ = Assert.Throws(() => hasProperties.GetProperty("ClassInObject").MapPropertiesTo()); } [Fact] @@ -74,7 +74,7 @@ public class HasPropertiesBaseTests var hasProperties = new TestHasProperties(props); // Act - var mappedProperty = hasProperties.MapClassPropertyTo("ClassInObject"); + var mappedProperty = hasProperties.GetProperty("ClassInObject").MapPropertiesTo(); // Assert Assert.True(mappedProperty.MapToBool); @@ -121,7 +121,7 @@ public class HasPropertiesBaseTests var hasProperties = new TestHasProperties(props); // Act - var mappedProperty = hasProperties.MapClassPropertyTo("ClassInObject"); + var mappedProperty = hasProperties.GetProperty("ClassInObject").MapPropertiesTo(); // Assert Assert.Equal("Test", mappedProperty.NestedMapToString); @@ -162,7 +162,7 @@ public class HasPropertiesBaseTests var hasProperties = new TestHasProperties(props); // Act - var mappedProperty = hasProperties.MapClassPropertyTo("ClassInObject"); + var mappedProperty = hasProperties.GetProperty("ClassInObject").MapPropertiesTo(); // Assert Assert.Equal(TestEnum.TestValue1, mappedProperty.EnumMapToEnum); @@ -196,7 +196,7 @@ public class HasPropertiesBaseTests var hasProperties = new TestHasProperties(props); // Act - var mappedProperty = hasProperties.MapClassPropertyTo("ClassInObject"); + var mappedProperty = hasProperties.GetProperty("ClassInObject").MapPropertiesTo(); // Assert Assert.Equal(TestEnumWithFlags.TestValue1 | TestEnumWithFlags.TestValue2, mappedProperty.EnumWithFlagsMapToEnum); diff --git a/src/DotTiled/Properties/IHasProperties.cs b/src/DotTiled/Properties/IHasProperties.cs index cd413dd..705a7d2 100644 --- a/src/DotTiled/Properties/IHasProperties.cs +++ b/src/DotTiled/Properties/IHasProperties.cs @@ -32,14 +32,6 @@ public interface IHasProperties /// The property with the specified name. T GetProperty(string name) where T : IProperty; - /// - /// Maps a class property to a new instance of the specified type using reflection. - /// - /// - /// The property which you want to map to a class - /// - T MapClassPropertyTo(string name) where T : new(); - /// /// Maps all properties in this object to a new instance of the specified type using reflection. /// @@ -85,13 +77,6 @@ public abstract class HasPropertiesBase : IHasProperties return false; } - /// - public T MapClassPropertyTo(string name) where T : new() - { - var classProperty = GetProperty(name); - return CreateMappedInstance(classProperty.GetProperties()); - } - /// public T MapPropertiesTo() where T : new() {