From dc35216f410259f7da2d3babe66b7b0cfda8a5cd Mon Sep 17 00:00:00 2001 From: H1Gdev Date: Sat, 31 Aug 2019 23:30:02 +0900 Subject: [PATCH] Do not copy None, Inherit and NotSet at DeepCopy (#565) * Do not copy None, Inherit and NotSet at DeepCopy. * Add test. --- Source/Painting/SvgColourServer.cs | 3 +++ Tests/Svg.UnitTests/SvgElementDeepCopyTest.cs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/Source/Painting/SvgColourServer.cs b/Source/Painting/SvgColourServer.cs index eabb462..d38f734 100644 --- a/Source/Painting/SvgColourServer.cs +++ b/Source/Painting/SvgColourServer.cs @@ -73,6 +73,9 @@ namespace Svg public override SvgElement DeepCopy() { + if (this == None || this == Inherit || this == NotSet) + return this; + var newObj = base.DeepCopy() as SvgColourServer; newObj.Colour = this.Colour; return newObj; diff --git a/Tests/Svg.UnitTests/SvgElementDeepCopyTest.cs b/Tests/Svg.UnitTests/SvgElementDeepCopyTest.cs index 9a9f350..6ab3540 100644 --- a/Tests/Svg.UnitTests/SvgElementDeepCopyTest.cs +++ b/Tests/Svg.UnitTests/SvgElementDeepCopyTest.cs @@ -71,6 +71,14 @@ namespace Svg.UnitTests Assert.IsInstanceOf(dest); } + [Test] + public void TestDoNotDeepCopy() + { + Assert.AreSame(SvgPaintServer.None, SvgPaintServer.None.DeepCopy()); + Assert.AreSame(SvgColourServer.Inherit, SvgColourServer.Inherit.DeepCopy()); + Assert.AreSame(SvgColourServer.NotSet, SvgColourServer.NotSet.DeepCopy()); + } + /// /// Tests that the deep copy of a is done correctly where the /// text element has contains only text and now other elements like .